*! version 4.004 March 2023
summclust

Title

Cluster specific summary statistics

Syntax

summclust varlist, cluster(varname) [ options]

varlistthe dependent variable, the independent variable of
interest, and other (binary or continuous) independent variables,

clusterthe clustering variable.

fevar(varlist) creates fixed effects for the included
variables, using i.varname.

absorb(varname) partials out this variable from the
regression before computing other statistics. This should only be used
for variables that are nested within the specified clusters. This
option is computationally faster than using fevar.

jackknife calculates the jackknife variance estimator
CV_3J in addition to CV_3.

addmeans displays additional summary statistics for
cluster variability based on alternative means.

gstar calculates the effective number of clusters G*()
and G*(1).

rho(scalar) calculates the effective number of
clusters, G*(rho), in addition to G*(0) and G*(1). This option can be
used with out without the gstar option. The value of rho must
be between 0 and 1.

table displays the cluster by cluster statistics.

sample allows for sample restrictions. For instance,
in order to restrict the analysis to individuals 25 years of age or
older based on a variable "age", sample(age>=25) should be added to
the list of options.

nograph suppresses creation of the figure, which is
otherwise shown by default.

regtable displays the full regression table similar to
Stata's regress table, but with CV_3 standard errors.

Updates

Description

summclust is a stand-alone command that summarizes
cluster variability and calculates a cluster jackknife variance
estimator. MacKinnon, Nielsen, and Webb (2023) documents it more fully
than this help file. The command calculates measures of cluster-level
influence and leverage. It can optionally calculate the effective
number of clusters. By default, it reports CV_1 and CV_3 standard
errors, and it can optionally report a CV_3J standard error. It
also, optionally, calculates additional measures of cluster-level
heterogeneity. By default, it produces a figure which can help
identify the source of cluster-level heterogeneity. Finally, it can
produce a full table of regression results.

summclust by default calculates the CV_3 standard error.
With well-behaved samples, this should match the standard error
calculated using either Stata's native jackknife: reg y x,
cluster(group) or reg y x, cluster(group) vce(jackknife)
commands. However, many samples are not well behaved. Specifically,
some of the omit-one-cluster subsamples may be singular. When they
are, summclust calculates two standard errors. One
drops the singular subsamples, as the native Stata routines do. The
other uses a generalized inverse. summclust provides guidance as
to which standard error is likely to be more reliable. When
regtable is specified, and singular subsamples are present, two
versions of the regression table are displayed. Similarly, if
jackknife is specified and there are singular subsamples, four
different standard errors are shown, either CV_3 or CV_3J, combined
with either the generalized inverse or one computed after
dropping the singular subsamples.

nograph suppresses creation of the figure, which is
otherwise shown by default. The figure shows four scatter plots:
leverage against observations per cluster, partial leverage against
observations per cluster, leverage against omit-one-cluster
coefficients, and partial leverage against omit-one-cluster
coefficients. This figure can be quite informative, but it is
computationally costly to produce. We therefore recommend invoking
this option after you have inspected the figure.

regtable when jackknife is specified, regtable uses the
CV_3J estimates to produce the regression table. Otherwise, CV_3
estimates are used.

Stored results

summclust stores the following in r():

Matrices

r(ng) The number of observations per cluster.

r(lever) The cluster-specific leverage.

r(part) The cluster-specific partial leverage.

r(betanog) The estimate of beta when the g_th
cluster is omitted.

Scalars

r(gstarzero) The effective number of clusters for the
coefficient of interest using rho=0.

r(gstarrho) The effective number of clusters for the
coefficient of interest using the scalar rho from the rho
option.

r(gstarone) The effective number of clusters for the
coefficient of interest using rho=1.

r(beta) The estimated beta for the coefficient of
interest.

r(cv1se) The CV_1 standard error for the coefficient of
interest.

r(cv1t) The CV_1 t-statistic for the coefficient of
interest.

r(cv1p) The P value for the null hypothesis that beta=0
for the coefficient of interest using the CV_1 standard error.

r(cv1lci) The lower bound of the 95% confidence interval
for beta using the CV_1 standard error.

r(cv1uci) The upper bound of the 95% confidence
interval for beta using the CV_1 standard error.

r(cv3se) The CV_3 standard error for the coefficient of
interest.

r(cv3t) The CV_3 t-statistic for the coefficient of
interest.

r(cv3p) The P value for the null hypothesis that beta=0
for the coefficient of interest using the CV_3 standard error.

r(cv3lci) The lower bound of the 95% confidence interval
for beta using the CV_3 standard error.

r(cv3uci) The upper bound of the 95% confidence interval
for beta using the CV_3 standard error.

r(cv3Jse) The CV_3J standard error for the coefficient
of interest.

r(cv3Jt) The CV_3J t-statistic for the coefficient of
interest.

r(cv3Jp) The P value for the null hypothesis that beta=0
for the coefficient of interest using the CV_3J standard error.

r(cv3Jlci) The lower bound of the 95% confidence interval
for beta using the CV_3J standard error.

r(cv3Juci) The upper bound of the 95% confidence
interval for beta using the CV_3J standard error.

summclust stores the following in mata:

Matrices

cvstuff The matrix with the standard errors, t-statistics,
etc.

clustsum The matrix with the measures of cluster
variability.

bonus The matrix with additional measures of cluster
variability. Only calculated when the option addmeans is
specified.

scall The matrix with the cluster-by-cluster statistics.
Only calculated when the option table is specified.

cnames The string matrix with the cluster names, to
match with elements in scall. Only calculated when the option
table is specified.

regresstab The matrix that is displayed when the
regresstab option is specified.

regresstab The additional matrix that is displayed when
the regresstab option is specified and there are singular
clusters.

Examples

nlswork -- using regress

. webuse nlswork, clear

. keep if inrange(age,20,40)

. reg ln_wage i.grade i.age i.birth_yr union race msp,
cluster(ind)

nlswork -- using summclust

. summclust ln_wage msp union race, fevar(grade age
birth_yr) cluster(ind)

adding industry fixed effects using absorb

. summclust ln_wage msp union race, fevar(grade age
birth_yr) absorb(ind) cluster(ind)

sample restrictions - using sample

. summclust ln_wage msp union race, fevar(grade age
birth_yr) sample(south==1) cluster(ind)

Effective Number of Clusters using gstar or rho.

. summclust ln_wage msp union race, fevar(grade age
birth_yr) cluster(ind) gstar

. summclust ln_wage msp union race, fevar(grade age
birth_yr) cluster(ind) rho(0.5)

All Output.

. summclust ln_wage msp union race, fevar(grade age
birth_yr) absorb(ind) cluster(ind) table addmeans jack rho(0.5) regtable

Author

Matthew D. Webb

matt.webb@carleton.ca

Citation

summclust is not an official Stata command. It is a
free contribution to the research community.

Please cite:

James G. MacKinnon, Morten Ø. Nielsen, and Matthew D. Webb.
2023. Leverage, Influence, and the Jackknife in Clustered Regression
Models: Reliable Inference Using summclust.