Share of Each User's Friends in Treatment for Network Exposure Analysis
Last updated: November 29, 2026
Quick Overview
In a cluster-randomized Facebook experiment, given an undirected friendship edge list, user arm assignments and a per-user outcome, compute each user's fraction of friends in treatment, bucket control users by that exposure, and report mean outcome per exposure bucket to look for spillover.
Meta
November 29, 20260
0
0 solved
In a cluster-randomized Facebook experiment, given an undirected friendship edge list, user arm assignments and a per-user outcome, compute each user's fraction of friends in treatment, bucket control users by that exposure, and report mean outcome per exposure bucket to look for spillover.
Many Meta features (sharing, messaging, Groups) have network effects, so a control user's outcome can change when their friends are treated. This onsite question tests building symmetric edge lists, joining arm labels onto neighbors, aggregating to per-user exposure, and the analytical judgment of how to read the exposure curve.
What the Interviewer Expects
- Symmetrize the undirected edge list and drop self-loops and duplicates
- Join the neighbor's arm and compute the treated friend fraction per user
- Keep users with zero friends with a defined exposure (NaN or separate bucket)
- Bucket exposure with pd.cut and summarize control outcomes per bucket
- Explain why the exposure gradient is correlational, not causal by itself
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would graph cluster randomization change how you estimate the total effect?
- Why are high-degree users over-represented in some exposure buckets, and how do you adjust?
- How would you define exposure using interaction-weighted ties instead of all friends?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
edges(u, v) lists each friendship once in arbitrary direction; arms(user_id, arm); outcome(user_id, y). Friends without an arm (not in the experiment) are excluded from the denominator. Buckets:...
Approach
Concatenate (u, v) and (v, u), drop self-loops and duplicates. Merge the neighbor's arm on v; inner-merge drops neighbors outside the experiment. Per user, exposure is the mean of arm == 'treatment'...