Least squares¶
In the app: Help → Help contents, Least squares.
Ordinary least squares chooses the coefficients that minimise the sum of squared residuals. It is unbiased when the regressors are uncorrelated with the error, and efficient when the errors are also homoskedastic and serially uncorrelated; robust (White) and HAC (Newey-West) covariances keep inference valid when they are not. Equations written in explicit form are estimated by nonlinear least squares. In code, pymetrix.ols(y, X) estimates without a formula (see "Regression without a formula").
Heteroskedasticity-robust standard errors come in six versions, which differ in small samples only. All use (X'X)^-1 X' diag(w_i u_i^2) X (X'X)^-1, with u_i the residuals and h_ii the leverages, the diagonal of X (X'X)^-1 X': HC0 (cov="hc0", White's own): w_i = 1; HC1 (cov="white"): w_i = n/(n-k), Stata's vce(robust) and EViews' White; HC2 (cov="hc2"): w_i = 1/(1 - h_ii); HC3 (cov="hc3"): w_i = 1/(1 - h_ii)^2, R's sandwich::vcovHC default; HC4 (cov="hc4"): w_i = 1/(1 - h_ii)^d_i, d_i = min(4, h_ii/hbar), hbar the mean leverage; HC5 (cov="hc5"): w_i = 1/(1 - h_ii)^(a_i/2), a_i = min(h_ii/hbar, max(4, 0.7 h_max/hbar)), as R's sandwich::vcovHC(type = "HC4") and "HC5". HC2 to HC5 inflate the residuals of high-leverage observations, which least squares fits too closely; Long and Ervin (2000) found HC3's tests the most reliable below about 250 observations, and Cribari-Neto's HC4 and HC5 discount the most leveraged observations more still. HC2 to HC5 are offered for linear OLS, weighted or restricted (with the restricted fit's leverages) or with absorbed fixed effects (fe(...): the leverage is that of the regression with the effects as dummies, the demeaned regressors' plus 1/n_g for one fe() term, from the dummies' sparse matrix for several, up to 5000 levels in all), but not for explicit-form equations or for IV; HC0 is offered for OLS and IV. An observation with leverage 1 (fitted exactly by a dummy of its own, such as a group of one under fe()) leaves HC2 to HC5 undefined.
Restricted least squares imposes linear restrictions on the coefficients, such as constant returns (a + b = 1) or a coefficient fixed at a value: type them under Method settings → Restrictions for OLS or IV (in code, OLS(restrictions=["a + b = 1"])), naming coefficients as the summary does (const, y, x[-1]), several separated by commas. The estimate is b - (X'X)^-1 R' [R (X'X)^-1 R']^-1 (R b - r), the same as substituting the restrictions into the equation; standard errors follow the chosen covariance, with one residual degree of freedom more for each restriction, and a coefficient fixed by a restriction has a standard error of zero. Restrictions must be linear; a nonlinear one belongs in an explicit-form equation, written in. The fit reports the test of the restrictions: the Wald test of R b = r on the unrestricted fit, with the same kind of standard errors, as F = W/q on q and n - k degrees of freedom (the summary's note; fit.stats["restrictions_f"] and its p-value, and the chi-squared form "restrictions_wald"). With conventional standard errors it is the F test that compares the restricted and unrestricted sums of squared residuals.
See also¶
References¶
- Greene, W. H. (2018). Econometric Analysis, 8th ed., chapters 2 ("The linear regression model"), 3 ("Least squares regression") and 4 ("Estimating the regression model by least squares"). Pearson. (search)
- White, H. (1980). A heteroskedasticity-consistent covariance matrix estimator and a direct test for heteroskedasticity. Econometrica 48(4), 817-838. doi:10.2307/1912934
- MacKinnon, J. G. and White, H. (1985). Some heteroskedasticity-consistent covariance matrix estimators with improved finite sample properties. Journal of Econometrics 29(3), 305-325. (search)
- Long, J. S. and Ervin, L. H. (2000). Using heteroscedasticity consistent standard errors in the linear regression model. The American Statistician 54(3), 217-224. (search)
- Cribari-Neto, F. (2004). Asymptotic inference under heteroskedasticity of unknown form. Computational Statistics & Data Analysis 45(2), 215-233. (search)
- Cribari-Neto, F., Souza, T. C. and Vasconcellos, K. L. P. (2007). Inference under heteroskedasticity and leveraged data. Communications in Statistics - Theory and Methods 36(10), 1877-1888. (search)