help vcemway (SJ19-4: st0582)

Title

vcemway -- A one-stop solution for robust inference with
multiway clustering

Syntax

vcemway
cmdline_main,
cluster(varlist)
[vmcfactor(type)
vmdrf(#)
vmsuest(type)
cmdline_options]

cmdline_main refers to the main component of an estimation command line,
such as xtreg y X Z.

Description

vcemway adjusts a Stata estimation command's standard errors and
covariance matrix for multiway clustering in varlist. The command works
with any Stata command that allows one-way clustering via the built-in option
cluster(varname). When vcemway results are active, any
call to postestimation commands that use e(V) (for example,
test, nlcom, and margins) will also produce results
that are robust to multiway clustering.

The required option cluster(varlist) accepts varlist
that lists two or more variables identifying the clustering dimensions of
interest. The optional options vmcfactor(type) and
vmdfr(#) allow the researcher to supply his or her preferred
small-sample correction factor and residual degrees of freedom: see below.

Options

cluster(varlist) accepts varlist that lists the names of m >= 2
variables that identify the clustering dimensions of interest. As we will
explain shortly, the optional options vmcfactor() and vmdfr() allow
the researcher to supply his or her preferred small-sample correction factor
and residual degrees of freedom. In the remaining syntax diagram,
cmdline_main refers to the main component of an estimation command line
that the researcher would like to execute, such as xtreg y X Z; and
cmdline_options refers to required and optional options in that command
line, such as re and nonest. To complete this example, we see
that executing vcemway xtreg y X Z, cluster(id1 id2 id3) re nonest will
report a linear random-effects regression with standard errors that have been
adjusted for clustering in the three variables and computed using the default
settings (see below) for options vmcfactor() and vmdfr().
cluster() is required.

vmcfactor(type) specifies the type of small-cluster correction factor.
type may be default, minimum, or none.

As Cameron, Gelbach, and Miller (2011) show, a covariance matrix robust to
multiway clustering can be written as a linear combination of several
covariance matrices that are robust to one-way clustering in different
dimensions. With one-way clustering, Stata applies a small-sample correction
factor of * {(N - 1)/(N - #)}, where n_g is the number of
groups in a particular one-way clustering dimension, N is the number of
observations in the estimation sample, and # is the number of estimated
coefficients for some commands (for example, regress) and 1 for others
(for example, ml, maximize). The small-cluster correction factor
henceforth refers to the first term in the product, n_g/(n_g - 1).

Unless specified otherwise, vcemway assumes the default type that
uses Stata's one-way clustered covariance matrices without further
modification. That is, each V_g incorporates its own small-cluster correction
factor of n_g/(n_g - 1).

The minimum type requests the use of a conservative correction factor
that is identical across all component matrices. Specifically, every V_g is
recalculated by replacing n_g/(n_g - 1) with G/(G - 1), where G is the size of
the smallest clustering dimension. For instance, suppose that
cluster(id1 id2 id3) has been specified, and there are 180, 30, and 78
clusters in id1, id2, and id3, respectively. G will be 30
in this case.

Finally, the none type requests the use of no small-cluster correction.
In this case, every V_g is recalculated by replacing n_g/(n_g - 1) with 1.

vmdfr(#) specifies the residual degrees of freedom for t and F tests.
The default setting varies from command to command. In case the estimation
command in question reports large-sample test statistics (for example,
ivregress and ml, maximize), # is set to missing so that the
researcher can carry out large-sample tests instead of t and F tests. In case
the estimation command reports small-sample statistics (for example,
regress), # is set to (G - 1), where G is the size of the smallest
clustering dimension.

vmsuest(type) is required only when the user wishes to apply vcemway with suest.
In this case, type must be set to yes to form a command line such as vcemway suest modelA modelB, cluster(id1 id2) vmsuest(yes).

cmdline_options specifies required and optional options in that command
line, such as re or fe. To complete this example, we see that
executing vcemway xtreg y X Z, cluster(id1 id2 id3) re nonest will
report a linear random-effects regression, with standard errors adjusted for
three-way clustering.

Examples

Ordinary least-squares regression with two-way clustering:

. webuse nlswork

. vcemway regress ln_wage grade ttl_exp c.ttl_exp#c.ttl_exp, cluster(idcode year)

Random-effects generalized least-squares regression with two-way
clustering:

. webuse nlswork

. vcemway xtreg ln_wage grade ttl_exp c.ttl_exp#c.ttl_exp, cluster(idcode year) re nonest

Random-effects generalized least-squares regression with two-way clustering,
using a more conservative small-cluster correction factor:

. webuse nlswork

. vcemway xtreg ln_wage grade ttl_exp c.ttl_exp#c.ttl_exp, cluster(idcode year) re nonest vmcfactor(minimum)

Stored results

vcemway stores the following in e():

Scalars

e(N_clustk) number of clusters in the kth variable in varlist

e(rank) rank of multiway clustered covariance matrix

e(df_r) residual degrees of freedom for t and F tests

Macros

e(vcemway) yes

e(clustvark) name of the kth variable in varlist

e(clustvar) names of all variables in varlist

e(vmcfactor) type of small-cluster correction factor
(default, minimum, or none)

Matrices

e(V) multiway clustered covariance matrix

e(V_raw) original version of e(V), in case it has been
reconstructed by replacing negative eigenvalues with zeros to achieve
positive semidefiniteness

Caveats

As with one-way clustering, an adjustment for multiway clustering should be
applied with careful attention to the model of interest. For nonlinear models
such as probit, the presence of cluster-specific random effects is a
form of model misspecification that can render parametric estimators
inconsistent. It may be inappropriate to consider the probit model with
multiway clustered standard errors as a substitute for a modeling solution
such as the crossed random-effects probit model that meprobit
supports. See Cameron and Miller (2015, sec. VII.C) and references therein
for further information on multiway clustering with nonlinear models.

In some cases, multiway clustering may not produce suitably robust test
statistics for linear models either. For example, consider paired or "dyadic"
data, where each observation is on a distinct country pair, . While
two-way clustering on variables identifying A and B adjusts for error
correlation in and and in and
, it fails to account for correlation in and
. The last two country pairs share neither A nor B because USA
appears in alternate positions. vcemway does not support more general
clustering methods for dyadic data (Aronow, Samii, and Assenova 2015; Cameron
and Miller 2014).

Correia (2015) advises that when fitting linear models with multiway fixed
effects, the researcher should drop singleton groups in each dimension of
fixed effects iteratively until no singleton group remains before clustering
standard errors in those dimensions. Including singleton groups that comprise
one observation may have undue effects on statistical inferences by making
small-sample correction factors smaller than otherwise. His
community-contributed command
reghdfe
(Correia 2014) allows for multiway clustering for linear models with multiway
fixed effects and automates this advice.

References

Aronow, P. M., C. Samii, and V. A. Assenova. 2015. Cluster-robust variance
estimation for dyadic data. Political Analysis 23: 564-577.

Cameron, A. C., J. B. Gelbach, and D. L. Miller. 2011. Robust inference with
multiway clustering. Journal of Business & Economic Statistics 29: 238-249.

Cameron, A. C., and D. L. Miller. 2014. Robust inference for dyadic data.
http://faculty.econ.ucdavis.edu/faculty/cameron/research/dyadic_cameron_miller_december2014_with_tables.pdf.

------. 2015. A practitioner's guide to cluster-robust inference.
Journal of Human Resources 50: 317-372.

Correia, S. 2014. reghdfe: Stata module to perform linear or
instrumental-variable regression absorbing any number of high-dimensional
fixed effects. Statistical Software Components S457874, Department of
Economics, Boston College. https://ideas.repec.org/c/boc/bocode/s457874.html.

------. 2015. Singletons, cluster-robust standard errors and fixed
effects: A bad mix. http://scorreia.com/research/singletons.pdf.

Authors

Ariel Gu

Durham University Business School

Durham University

Durham, UK

ariel.gu@durham.ac.uk

Hong Il Yoo

Durham University Business School

Durham University

Durham, UK

h.i.yoo@durham.ac.uk

Also see

Article: Stata Journal, volume 19, number 4: st0582

Help: ivreg2, reghdfe, boottest (if installed),
[R] vce_option, [R] _robust