Evaluating Initial vs Subsequent Video Length Differences
Statistics & ExperimentsModel answerLast updated
Construct a paired statistical workflow, cohort design, time-trend adjustment, and SQL data extraction to analyze if a user's inaugural upload is shorter than later posts.
Context
Product teams at a video sharing platform suspect that creators upload noticeably shorter videos when posting for the very first time compared to their subsequent activity.
Question
How would you design a quantitative study to evaluate whether initial uploads are shorter than later ones? In your response, make sure to cover:
- Hypothesis & Metric Framing: Define the unit of analysis, metric transformations, and formal hypotheses.
- Cohort & Data Filtering: Detail inclusion criteria, cohort construction, and edge-case handling to prevent survival and selection biases.
- Statistical Testing & Confounders: Select and justify non-parametric/parametric paired tests, discuss time-based confounding, and propose robust controls.
- Data Extraction (SQL): Write clean SQL using window functions to extract the necessary metrics.
- Execution & Interpretation: Provide Python/pseudo-code demonstrating statistical execution and explain how to state the final conclusions clearly to stakeholders.
Hints
Hint 1
Avoid pooling all first videos against all later videos; variance across different creator types will mask true effects unless paired within user.
Hint 2
Durations exhibit severe right-skewness. Consider logarithmic transformations to stabilize variance and interpret results as percentage differences.
Hint 3
Because upload #1 chronologically precedes upload #2, overall platform shifts over calendar time can easily mimic an inaugural drop.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Metric Definition & Hypothesis Framing
Unit of Analysis: Within-User Pairing
Comparing an un-paired pool of all initial uploads against all later uploads is flawed. A platform hosts widely different creator personas (e.g., short-form clip creators vs. multi-hour livestreamers). A cross-sectional comparison introduces massive between-user variance and risks selection bias if high-tenure users have different base video lengths.
Instead, the unit of analysis must be within-user (paired). Each user serves as their own control baseline.
Logarithmic Scale & Metric Formulation
Video durations follow a heavy right-skewed distribution. Applying a logarithmic transformation stabilizes variance and minimizes the leverage of extreme outliers (such as 10-hour stream archives).
For each creator $u$:
- $d_{\text{first}}(u) = \ln(\text{duration of upload } #1 \text{ in seconds})$
- $d_{\text{later}}(u) = \frac{1}{K-1} \sum_{k=2}^{K} \ln(\text{duration of upload } k \text{ in seconds})$
The primary per-user metric is the paired log difference: $$\Delta(u) = d_{\text{first}}(u) - d_{\text{later}}(u)$$
Exponentiating $\Delta(u)$ gives the relative duration ratio: $\exp(\Delta(u)) - 1 \approx \text{percentage difference}$.
Formal Hypotheses
- Null Hypothesis ($H_0$): The median paired difference $\text{Median}(\Delta(u)) \ge 0$ (first uploads are equal to or longer than later uploads).
- Alternative Hypothesis ($H_1$): The median paired difference $\text{Median}(\Delta(u)) < 0$ (first uploads are systematically shorter).
2. Cohort Construction & Data Slicing
To protect against bias and temporal distortion, apply the following cohort rules:
- New Creator Cohort Window (Preventing Left-Censoring): Select creators whose true first-ever account upload occurred within a bounded date window (e.g., Jan 1, 2024 to June 30, 2024). Relying on historical data without a known account creation boundary misidentifies old creators' recent uploads as their "first."
- Activity Threshold: Include only creators with at least $2$ valid uploads. Note the percentage of dropped single-upload creators; single-post users represent a distinct sub-population that cannot participate in paired evaluation.
- Observation & Post Cap Window: Limit $d_{\text{later}}$ to uploads $2 \dots 10$ submitted within $90\text{ days}$ of the initial upload. This prevents hyper-active power users from skewing the mean and limits long-term tenure evolution.
- Data Exclusions:
- Non-positive or excessive durations ($\le 0$ seconds or $> 12\text{ hours}$).
- Failed, private, deleted, or flagged spam/bot uploads.
- Identified duplicate video re-uploads.
3. Statistical Testing & Confounder Controls
Testing Strategy
- Wilcoxon Signed-Rank Test (Primary): Non-parametric test operating on paired differences $\Delta(u)$. It makes no normality assumption and is resilient against lingering extreme values.
- Paired $t$-test on Log Durations (Secondary): Supported by the Central Limit Theorem for large user samples ($N > 10,000$). Direct estimation of the geometric mean change.
- Bootstrapped Confidence Intervals: Resample users (not individual videos) with replacement over 2,000 iterations to build a 95% non-parametric percentile confidence interval for $\text{Median}(\Delta(u))$.
Critical Confounder: Macro Calendar Trends
Because upload #1 always occurs prior to upload #2+, any upward platform-wide trend in video duration (e.g., introducing longer video support, product UI nudges, seasonality) will cause initial videos to appear shorter purely due to calendar timing.
Adjustment Method: Run a video-level fixed-effects regression: $$\ln(\text{duration}{i,u,t}) = \beta_0 + \beta_1 \cdot \mathbb{I}(\text{is_first}{i,u}) + \alpha_u + \gamma_t + \varepsilon_{i,u,t}$$ Where:
- $\alpha_u$ represents user fixed effects.
- $\gamma_t$ captures weekly calendar fixed effects.
- Standard errors are clustered by
user_id.
Sensitivity / Placebo Check
Evaluate Upload #2 vs. Uploads #3–10. If Upload #2 shows a statistically equivalent drop relative to subsequent posts, the effect reflects a general multi-video ramp-up trajectory rather than an isolation effect tied exclusively to the first video.
4. SQL Extraction Query
WITH cohort_creators AS (
SELECT
user_id,
MIN(created_at) AS first_upload_at
FROM platform_videos
WHERE status = 'published'
GROUP BY user_id
HAVING MIN(created_at) BETWEEN '2024-01-01' AND '2024-06-30'
),
ordered_uploads AS (
SELECT
v.user_id,
v.duration_seconds,
v.created_at,
ROW_NUMBER() OVER (
PARTITION BY v.user_id
ORDER BY v.created_at ASC, v.video_id ASC
) AS upload_rank
FROM platform_videos v
INNER JOIN cohort_creators c ON v.user_id = c.user_id
WHERE v.status = 'published'
AND v.duration_seconds > 0
AND v.duration_seconds <= 43200
AND v.created_at <= c.first_upload_at + INTERVAL '90 days'
),
user_summary AS (
SELECT
user_id,
MAX(CASE WHEN upload_rank = 1 THEN LN(duration_seconds) END) AS log_dur_first,
AVG(CASE WHEN upload_rank BETWEEN 2 AND 10 THEN LN(duration_seconds) END) AS log_dur_later,
COUNT(CASE WHEN upload_rank BETWEEN 2 AND 10 THEN 1 END) AS count_later
FROM ordered_uploads
GROUP BY user_id
)
SELECT
user_id,
log_dur_first,
log_dur_later,
(log_dur_first - log_dur_later) AS delta_log_dur
FROM user_summary
WHERE count_later >= 1;
5. Python Execution & Analytical Reporting
import numpy as np
import pandas as pd
from scipy import stats
# Load query output
df = pd.read_csv("paired_user_durations.csv")
delta = df["delta_log_dur"].to_numpy()
# 1. Wilcoxon Signed-Rank Test
wilcoxon_stat, wilcoxon_p = stats.wilcoxon(delta, alternative="less")
# 2. Bootstrap Confidence Interval for Median Log Difference
rng = np.random.default_rng(seed=42)
boot_medians = [
np.median(rng.choice(delta, size=len(delta), replace=True))
for _ in range(2000)
]
ci_lower_log, ci_upper_log = np.percentile(boot_medians, [2.5, 97.5])
# Convert log differences into percentage effect sizes
median_pct_change = (np.exp(np.median(delta)) - 1) * 100
ci_lower_pct = (np.exp(ci_lower_log) - 1) * 100
ci_upper_pct = (np.exp(ci_upper_log) - 1) * 100
print(f"Median Effect Size: {median_pct_change:.2f}%")
print(f"95% Non-parametric CI: [{ci_lower_pct:.2f}%, {ci_upper_pct:.2f}%]")
print(f"Wilcoxon p-value: {wilcoxon_p:.4e}")
Final Conclusion Framing
Present findings by highlighting business significance, confidence bounds, and robustness checks:
"Among $N$ new creators who joined in H1 2024 and posted at least 2 videos within 90 days, initial uploads were a median of 15.4% shorter than their subsequent uploads (95% CI: [-17.2%, -13.5%]; Wilcoxon $p < 0.001$). After controlling for calendar-week time trends via fixed-effects regression, the inaugural video reduction remained statistically significant at -13.8%."