If you retain nothing else from this page, retain these 24 lines.
smf.ols("y ~ x1 + C(g)", data=df).fit()Formula API: intercept, factors, NaNs handled.
sm.OLS(y, sm.add_constant(X)).fit()Array API: you must add the constant.
Model(endog, exog) → y FIRSTsklearn is fit(X, y). This is reversed.
mod → .fit() → resNothing is computed until .fit().
res.summary()R², F, coef, P>|t|, DW, Cond. No.
res.params / bse / pvalues / conf_int()The four numbers you report.
fit(cov_type='HC3')Heteroskedasticity. Coefs unchanged, SEs fixed.
fit(cov_type='cluster', cov_kwds={'groups': g})Grouped data.
I(x**2)In a formula, ** is interaction syntax, not power.
C(g, Treatment(reference='b'))Pick the baseline level yourself.
res.get_prediction(new).summary_frame()mean_ci = average; obs_ci = a new observation.
res.get_influence().summary_frame()Cook's D > 4/n, leverage > 2k/n.
vif(sm.add_constant(X).values, i)VIF is meaningless without the constant.
family from y, link comes freeBinary→Binomial, counts→Poisson/NegBin.
np.exp(logit.params)Odds ratios. params are log-odds.
logit.predict() → probabilitiesNot 0/1 labels.
res.get_margeff().summary()Log-odds nobody understands → probability points.
adfuller: H0 = unit rootkpss: H0 = stationary. OPPOSITE nulls.
ACF cuts off → MA(q)PACF cuts off → AR(p).
SARIMAX(order=(p,d,q), seasonal_order=(P,D,Q,s))The old ARMA class was removed.
res.get_forecast(12).conf_int()dynamic=False flatters backtests.
acorr_ljungbox(res.resid)Residuals white noise? Then you're done.
multipletests(pvals, method='fdr_bh')50 tests at 0.05 = 2.5 false positives.
Rank-deficient exog does NOT raisepinv gives you an answer anyway. Check cond number.