Compute DID estimate and pretrend flag

Quick Overview

This Analytics & Experimentation question evaluates basic causal-inference and data-manipulation skills by requiring computation of a difference-in-differences (DID) estimate and a binary pretrend flag from panel-like arrays, at an implementation-level focused on summary statistics and edge-case handling.

Compute DID estimate and pretrend flag

Company: Roblox

Role: Data Scientist

Category: Analytics & Experimentation

Difficulty: hard

Interview Round: Take-home Project

You are given three equal-length arrays describing observations from a panel-like dataset: - `period[i]` ∈ {0,1}: 0 = pre period, 1 = post period - `treat[i]` ∈ {0,1}: 1 = treated group, 0 = control group - `y[i]` (float): outcome Tasks: A) Compute the **difference-in-differences (DID)** estimate of the treatment effect: \[ \text{DID} = (\bar y_{post,treated} - \bar y_{pre,treated}) - (\bar y_{post,control} - \bar y_{pre,control}) \] B) Compute a simple **pretrend flag**: - Let \(d_{pre} = \bar y_{pre,treated} - \bar y_{pre,control}\). - Given a scalar `threshold` ≥ 0, return `pretrend=True` if \(|d_{pre}| > threshold\), else `False`. Assumptions/requirements: - Use simple means over the subsets implied by (`period`, `treat`). - Describe how you would handle missing cells (e.g., no treated observations in pre period).

Quick Answer: This Analytics & Experimentation question evaluates basic causal-inference and data-manipulation skills by requiring computation of a difference-in-differences (DID) estimate and a binary pretrend flag from panel-like arrays, at an implementation-level focused on summary statistics and edge-case handling.

|Home/Analytics & Experimentation/Roblox
Roblox logo
Roblox
Nov 24, 2025, 12:00 AM
hardData ScientistTake-home ProjectAnalytics & Experimentation
11
0

You are given three equal-length arrays describing observations from a panel-like dataset:

  • period[i] ∈ {0,1}: 0 = pre period, 1 = post period
  • treat[i] ∈ {0,1}: 1 = treated group, 0 = control group
  • y[i] (float): outcome

Tasks:

A) Compute the difference-in-differences (DID) estimate of the treatment effect:

DID=(yˉpost,treatedyˉpre,treated)(yˉpost,controlyˉpre,control)\text{DID} = (\bar y_{post,treated} - \bar y_{pre,treated}) - (\bar y_{post,control} - \bar y_{pre,control})

B) Compute a simple pretrend flag:

  • Let dpre=yˉpre,treatedyˉpre,controld_{pre} = \bar y_{pre,treated} - \bar y_{pre,control} .
  • Given a scalar threshold ≥ 0, return pretrend=True if dpre>threshold|d_{pre}| > threshold , else False .

Assumptions/requirements:

  • Use simple means over the subsets implied by ( period , treat ).
  • Describe how you would handle missing cells (e.g., no treated observations in pre period).
Loading comments...