*! version 0 18jan2017

Title

reg_sandwich -- Linear regression with small-sample corrections for cluster-robust standard errors and t-tests

Syntax

reg_sandwich
depvar [indepvars] [if] [in] [weight],
cluster(varname)
[absorb(varname) | noconstant]
[level({#})]

Mandatory

cluster(varname) varname for clustered sandwich estimator.

Optional

absorb(varname) categorical variable to be absorbed.

noconstant suppress constant term.

* absorb and noconstant cannot be used simultaneously.

level(#) set confidence level; default is level(95).

aweights and pweights are
allowed; see weight.

reg_sandwich uses the supporting mata function
reg_sandwich_ttests.mo

* please note that reg_sandwich uses the mata workspace for intermediate calculations and to store large matrices for F-testing.
This can potentially cause conflict with existing matrices. This affects matrices named
W, Wj, X, Xj, ej, sq_inv_Bj, Bj, Tj, evals, evecs, Aj, Pj_Theta_Pj_relevant, Pj_relevant, Dj, PPj, XWAeeAWX, M
and names of the form X*, PP*, P*_relevant, where * can be any real integer.

see also test_sandwich

Description

reg_sandwich fits a linear regression using regress, optionally passing aweights or pweights (see weight). If absorb is provided, the regression are fitted using areg. Standard errors are based on a version of the bias-reduced linearization estimator proposed by Bell and McCaffrey (2002) and further developed by Tipton and Pustejovsky (2015) and Pustejovsky and Tipton (2016). t-tests for each coefficient in the model are calculated based on a Satterthwaite-type approximation, as described in Pustejovsky and Tipton (2016).

Note that if absorb is provided, the absorbed fixed effects are NOT taken into account when calculating the bias-reduced linearization estimator. That is, the small-sample corrections are calculated based on the matrix of covariates after absorbing the fixed effects. This can create (typically very small) differences in the cluster-robust standard errors and hypothesis tests depending on whether fixed effects are absorbed or are included as dummy variables.

Arguments

Mandatory

cluster(varname) varname for clustered sandwich estimator. See [R] vce_option.

Optional

(These two optional cannot be used simultaneously)

absorb(varname)} specifies the categorical variable, which is to be included in the regression as if it were specified by dummy variables. See areg.

noconstant suppresses the constant term (intercept) in the model.

Reporting

level(#); see [R] estimation options.

Examples

. use http://masteringmetrics.com/wp-content/uploads/2015/01/deaths.dta

. keep if dtype == 2 & agegr == 2

. xi, noomit: reg_sandwich mrate legal beertaxa beerpercap winepercap i.year, nocon cluster(state)

. xi, noomit: reg_sandwich mrate legal beertaxa beerpercap winepercap i.year [aweight=pop], nocon cluster(state)

. xi, noomit: reg_sandwich mrate legal beertaxa beerpercap winepercap i.year [pweight=pop], nocon cluster(state)

. xi: reg_sandwich mrate legal beertaxa beerpercap winepercap i.year, cluster(state) absorb(state)

. xi, noomit: reg_sandwich mrate legal beertaxa beerpercap winepercap i.year [aweight=pop], cluster(state) absorb(state)

. xi, noomit: reg_sandwich mrate legal beertaxa beerpercap winepercap i.year [pweight=pop], cluster(state) absorb(state)

Saved results

re_sandwich saves the following in e():

Scalars

e(N) number of observations

e(r2) R-squared

e(r2_a) adjusted R-squared

e(rss) residual sum of squares

e(mss) model sum of squares

e(rmse) root mean squared error

Macros

e(cmd) reg_sanfwich

e(cmdline) command as typed

e(depvar) depvar

e(indepvar) expanded list of depvars, after correcting for multicolinerity

e(constant_used) 0 if false, 1 if true

e(wtype) weight type

e(wexp) weight expression

e(clustvar) name of cluster variable

e(absvar) name of absorb variable (if absorb option is used)

e(vce) cluster

e(vcetype) Robust

e(properties) b V

e(type_VCE) OLS if unweighetd, WLSa if using aweigths and WLSp if using pweights

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix of the estimators

e(dfs) Degrees of freedom for effects

Functions

e(sample) marks estimation sample

re_sandwich saves the following in the mata workspace:

e(MXWTWXM) auxiliary matrix used for F-testing

e(PThetaP_relevant) auxiliary matrix used for F-testing

e(P_relevant) auxiliary matrix used for F-testing

e(PP) auxiliary matrix used for F-testing (used for p-weights only)

Citation

reg_sandwich is not an official Stata command. It is a free contribution to the research community, like a paper.
Please cite it as such:

Tyszler, M., Pustejovsky, J. E., & Tipton, E. 2017. REG_SANDWICH: Stata module to compute cluster-robust (sandwich) variance estimators with small-sample corrections for linear regression, Statistical Software Components S458352, Boston College Department of Economics. URL: https://ideas.repec.org/c/boc/bocode/s458352.html

Authors

Marcelo Tyszler. Sustainable Economic Development and Gender, Royal Tropical Institute, Netherlands. m.tyszler@kit.nl

James E. Pustejovsky (Package maintainer). Department of Education Psychology, University of Texas at Austin. pusto@austin.utexas.edu

Elizabeth Tipton. Department of Human Development, Teachers College, Columbia University. tipton@tc.columbia.edu

References

Pustejovsky, James E. & Elizabeth Tipton (2016).
Small sample methods for cluster-robust variance estimation and hypothesis testing in fixed effects models.
Journal of Business and Economic Statistics. In Press. DOI: 10.1080/07350015.2016.1247004

Tipton, Elizabeth and James E. Pustejovsky (2015). Small-sample adjustments for tests of moderators and model fit
using robust variance estimation in meta-regression. Journal of Educational and Behavioral Statistics December 2015 vol. 40 no. 6 604-634.
DOI: 10.3102/1076998615606099

Bell, R. M., & Daniel M. McCaffrey (2002). Bias reduction in standard errors for linear regression with multi-stage samples.
Survey Methodology, 28(2), 169–181.
Retrieved from http://www.statcan.gc.ca/pub/12-001-x/2002002/article/9058-eng.pdf