PracHub
QuestionsPremiumLearningGuidesInterview PrepCoaches
|Home/Analytics & Experimentation/Roblox

Compute diff-in-diff and pretrend flag

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of difference-in-differences estimation, simple pretrend detection, and related data-processing competencies for experiment-like observational datasets.

  • easy
  • Roblox
  • Analytics & Experimentation
  • Data Scientist

Compute diff-in-diff and pretrend flag

Company: Roblox

Role: Data Scientist

Category: Analytics & Experimentation

Difficulty: easy

Interview Round: Take-home Project

You are given individual-level observational data for an experiment-like setting with: - `period[i]` ∈ {0,1}: 0 = pre period, 1 = post period - `treatment[i]` ∈ {0,1}: 1 = treated group, 0 = control group - `outcome[i]` ∈ ℝ: numeric outcome All three arrays have the same length `N`, and row `i` corresponds to one observation. ## Tasks 1. Compute the **Difference-in-Differences (DiD) estimate** of the treatment effect: \[ \text{DiD} = (\bar{Y}_{T,post} - \bar{Y}_{T,pre}) - (\bar{Y}_{C,post} - \bar{Y}_{C,pre}) \] where the bars denote sample means over the corresponding subsets. 2. Compute a **pretrend flag** using the following simplified rule: - Let \(d_{pre} = |\bar{Y}_{T,pre} - \bar{Y}_{C,pre}|\). - Given a real number `threshold`, return `pretrend=True` if \(d_{pre} > \text{threshold}\), else `False`. ## Output Return: - `did_estimate` (float) - `pretrend` (boolean) ## Assumptions / edge cases - If any of the required cells (T/C × pre/post) has zero observations, specify and implement a reasonable behavior (e.g., raise an error or return NaN).

Quick Answer: This question evaluates understanding of difference-in-differences estimation, simple pretrend detection, and related data-processing competencies for experiment-like observational datasets.

Related Interview Questions

  • How to estimate feature impact on usage time - Roblox (easy)
  • How to estimate a feature’s causal impact on time spent - Roblox (medium)
  • Compute DID estimate and pretrend flag - Roblox (hard)
  • Compute minimum sample size for A/B test - Roblox (hard)
  • Compute DiD and validate parallel trends - Roblox (hard)
Roblox logo
Roblox
Oct 3, 2025, 12:00 AM
Data Scientist
Take-home Project
Analytics & Experimentation
4
0
Loading...

You are given individual-level observational data for an experiment-like setting with:

  • period[i] ∈ {0,1}: 0 = pre period, 1 = post period
  • treatment[i] ∈ {0,1}: 1 = treated group, 0 = control group
  • outcome[i] ∈ ℝ: numeric outcome

All three arrays have the same length N, and row i corresponds to one observation.

Tasks

  1. Compute the Difference-in-Differences (DiD) estimate of the treatment effect:

DiD=(YˉT,post−YˉT,pre)−(YˉC,post−YˉC,pre)\text{DiD} = (\bar{Y}_{T,post} - \bar{Y}_{T,pre}) - (\bar{Y}_{C,post} - \bar{Y}_{C,pre})DiD=(YˉT,post​−YˉT,pre​)−(YˉC,post​−YˉC,pre​)

where the bars denote sample means over the corresponding subsets.

  1. Compute a pretrend flag using the following simplified rule:
  • Let dpre=∣YˉT,pre−YˉC,pre∣d_{pre} = |\bar{Y}_{T,pre} - \bar{Y}_{C,pre}|dpre​=∣YˉT,pre​−YˉC,pre​∣ .
  • Given a real number threshold , return pretrend=True if dpre>thresholdd_{pre} > \text{threshold}dpre​>threshold , else False .

Output

Return:

  • did_estimate (float)
  • pretrend (boolean)

Assumptions / edge cases

  • If any of the required cells (T/C × pre/post) has zero observations, specify and implement a reasonable behavior (e.g., raise an error or return NaN).

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Analytics & Experimentation•More Roblox•More Data Scientist•Roblox Data Scientist•Roblox Analytics & Experimentation•Data Scientist Analytics & Experimentation
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.