Diagnose and interpret regression assumptions
OLS for Signups with Diagnostics and Alternatives
You are given a cleaned dataset with the following columns:
signups: non-negative integer count targetspend: numericclicks: integercpc: numeric (cost per click)region: categorical
Task: Using Python and statsmodels, draw a 100,000-row sample without replacement and fit an Ordinary Least Squares (OLS) model to predict signups using spend, clicks, cpc, and region dummy variables.
Then:
- If you use
log1p(signups)as the dependent variable, show how to back-transform predictions to the original scale and interpret thespendcoefficient. - Check model assumptions using:
- Residuals vs. fitted plot
- Q–Q plot
- Breusch–Pagan test for heteroskedasticity
- Durbin–Watson test for autocorrelation
- Variance Inflation Factors (VIFs) to assess multicollinearity
- If heteroskedasticity is present, refit the model with HC3 robust standard errors and comment on how p-values and confidence intervals change.
- Report the adjusted R², the 95% confidence interval for the
spendcoefficient, and interpret theregiondummy coefficients relative to the baseline. - Explain when a Poisson or Negative Binomial Generalized Linear Model (GLM) would be preferable for
signupsand how to test for overdispersion.
Provide the minimal code necessary to reproduce these diagnostics.
AI interview prep
Core dilemma
Balancing the simplicity and interpretability of OLS with the inherent count nature of the `signups` variable, and rigorously diagnosing/addressing violations of OLS assumptions, particularly heteroskedasticity and potential count-data specific issues.
3 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Diagnose and interpret regression assumptions
OLS for Signups with Diagnostics and Alternatives
You are given a cleaned dataset with the following columns:
signups: non-negative integer count targetspend: numericclicks: integercpc: numeric (cost per click)region: categorical
Task: Using Python and statsmodels, draw a 100,000-row sample without replacement and fit an Ordinary Least Squares (OLS) model to predict signups using spend, clicks, cpc, and region dummy variables.
Then:
- If you use
log1p(signups)as the dependent variable, show how to back-transform predictions to the original scale and interpret thespendcoefficient. - Check model assumptions using:
- Residuals vs. fitted plot
- Q–Q plot
- Breusch–Pagan test for heteroskedasticity
- Durbin–Watson test for autocorrelation
- Variance Inflation Factors (VIFs) to assess multicollinearity
- If heteroskedasticity is present, refit the model with HC3 robust standard errors and comment on how p-values and confidence intervals change.
- Report the adjusted R², the 95% confidence interval for the
spendcoefficient, and interpret theregiondummy coefficients relative to the baseline. - Explain when a Poisson or Negative Binomial Generalized Linear Model (GLM) would be preferable for
signupsand how to test for overdispersion.
Provide the minimal code necessary to reproduce these diagnostics.