Econometrics skill for OLS regression and linear models. Activates when the user asks about: "run OLS", "linear regression", "ordinary least squares", "interpret regression results", "heteroskedasticity", "multicollinearity", "regression assumptions", "robust standard errors", "GLS", "WLS", "fit a regression model", "check regression diagnostics", "OLS假设", "最小二乘法", "线性回归", "回归系数", "残差检验", "异方差", "多重共线性", "普通最小二乘", "稳健标准误", "回归诊断"
This skill provides comprehensive guidance for OLS regression and linear models in empirical research. It covers model specification, assumption testing, diagnostic checks, and result interpretation, with code examples in Python, R, and Stata.
When assisting with OLS regression, follow this sequence:
Violation of assumptions 4–5 does not bias OLS but affects standard errors. Violation of assumption 4 (endogeneity) biases estimates — recommend IV methods.
import statsmodels.api as sm
import statsmodels.formula.api as smf
# With robust standard errors
model = smf.ols('y ~ x1 + x2 + x3', data=df).fit(cov_type='HC3')
print(model.summary())
library(lmtest)
library(sandwich)
model <- lm(y ~ x1 + x2 + x3, data = df)
coeftest(model, vcov = vcovHC(model, type = "HC3"))
reg y x1 x2 x3, robust
Run all diagnostics after fitting. See references/ols-reference.md for full test details.
| Issue | Test | Quick Fix |
|---|---|---|
| Heteroskedasticity | Breusch-Pagan, White test | Robust SE |
| Autocorrelation | Durbin-Watson, Breusch-Godfrey | Newey-West SE |
| Multicollinearity | VIF > 10 | Drop/combine variables |
| Non-normality of errors | Jarque-Bera | Check outliers; large N mitigates |
| Omitted variable bias | Ramsey RESET | Respecify model |
For detailed test formulas, code, and extended examples, see references/ols-reference.md.