1/12
Learn

Regression and its coefficients, the way the rounds ask

An Airbnb coding round asked candidates to aggregate user activity, fit a regression and interpret the coefficients (1 source), and a Netflix statistics round asked why you add controls to a regression (1 report). This lesson's practice problem puts both in code with numpy, in three levels:

  1. ols(columns, y): the intercept and one slope per column, fitted all at once. r_squared(columns, y): the share of y's variation the fit explains.
  2. standard_errors(columns, y): the classical standard errors, and the robust ones, HC1.
  3. omitted_variable_bias(x, z, y): the slope without a control, with it, and the bias the formula predicts. percent_effect(b): a coefficient on log(y) as a percent.
CallReturns
ols([[1, 2, 3, 4]], [3, 5, 7, 9])[1.0, 2.0]: the intercept first, then one slope per column
r_squared for eight points on a steady climb0.9965
omitted_variable_bias(x, z, y) on 300 simulated rows3.517, 1.934 and 1.584: the first minus the second is the third
percent_effect(0.3)0.350, a 35% change

The lesson follows the shop's discounts and spending: least squares, controls and the bias they remove, good and bad controls, dummies and logs, and robust standard errors. Six steps end with a small task in the editor.