*! version 1.1.02 3Jan2019
help twostepweakiv

Title

twostepweakiv -- Valid two-step identification-robust confidence sets
for instrumental-variable (IV) estimation of linear model

Syntax

Standalone estimation (specifying model to be estimated):

twostepweakiv
estimator
depvar [varlist1]
(varlist2=varlist_iv) [weight]
[if exp] [in range]
[, project(varlist)
test_options grid_options size_options strong_options]

estimator

2sls
two-stage least squares estimator.

liml
limited-information maximum likelihood estimator.

md2s
two-step minimum distance estimator.

cue
continuous updating minimum distance estimator described in Magnusson (2010).

test_options

citestlist(testlist)
construct confidence sets for the full parameter vector based on the specified
tests (AR, K, K_2sls, LC, LC_2sls). If unspecified, default tests are Wald, AR,
K_2sls, and LC_2sls for 2sls and liml estimators; and Wald, AR,
K, and LC for md2s and cue estimators.

project(varlist)
when there is more than one weak endogenous variable, and we are interested in
inference for one endogenous regressor β only, we calculate confidence sets
using the refined projection method for β while treating the
other endogenous regressors η as free unknown parameters (nuisance parameters.)
See option strong if we are willing to make additional assumptions about η.
project(varlist) conducts inference for each of the variable specified in the varlist
based on the refined projection method. For example,
project(_all) reports refined projection-based confidence sets
for every weakly-identified coefficient. Unforunately,
this version of twostepweakiv does not support
projection-based confidence sets for two endogenous regressors e.g. project2(var1 var2)
from weakiv.

ptestlist(project_testlist)
construct confidence sets using refined projection method for β specified
in project based on the specified
tests (K, K_2sls, LC, LC_2sls). If unspecified, default tests are Wald and LC_2sls
for 2sls and liml estimators; and Wald and
LC for md2s and cue estimators.

grid_options

Note: The default grid is centered around the Wald point estimate
(or the CUE point estimate if the cuepoint estimate is specified)
with a width equal to five times the Wald confidence interval.
With weak/strong instruments,
this may often be too small/large a grid to estimate the confidence sets.

gridmult(#)
multiplier of Wald confidence-interval for grid. The default is gridmult(5).

gridmin(numlist)
lower limit(s) for grid search (in dimensions corresponding to endogenous regressors).

gridmax(numlist)
upper limit(s) for grid search (in dimensions corresponding to endogenous regressors).

gridpoints(numlist)
number(s) of equally spaced grid points (in dimensions corresponding to endogenous regressors)
over which to calculate the confidence sets;
The default number of gridpoints is
100, 25, 11, 7 and 5
for the cases of 1, 2, 3, 4 and 5 endogenous regressors, respectively.
For testing a point null hypothesis e.g. 0, set grid point to 1 and gridmin=gridmax=0.

cuepoint
report cue point estimates for weakly-identified endogenous regressors
and include them in grid.

size_options

level(#)
confidence level as a percentage (same for all tests performed);
The default is level(95) for size 5% tests; if specified, level(#)
with values 99, 95 or 90 allows for faster computation because weights used in LC and LC_2sls tests
are pre-tabulated only for these values. For other values, see gammalevel(#).

gammalevel(#)
distortion level for two-step confidence sets based on LC or LC_2sls test as a percentage;
The default is gammalevel(5) for a 5% coverage distortion; if specified,
gammalevel(#) with values 1, 2, 5, 10, 15, or 20 allows for faster computation because weights used in LC and LC_2sls tests
are pre-tabulated only for these values. For values not pre-tabulated, we include simulation code to calculate the corresponding weights and critical values, which can be slow.

strong_options

strong(varlist)
specifies strongly-identified endogenous regressors η when there is more than
one weak endogenous variable, and treats the rest of endogenous regressor β
as potentially weakly-identified. If unspecified, then all endogenous regressors
are assumed to be potentially weakly-identified. If strong specified and
cuestrong is not evoked, then at each grid point β0
for the potentially weakly-identified endogenous regressor β,
we calculate md2s estimates for strongly-identified endogenous
regressors η under the null hypothesis H0:β=β0.
We then evaluate test statistics for β, plugging the md2s estimates
η in the strongly-identified endogenous regressors.

cuestrong
uses cue point estimates for strongly-identified endogenous regressors
(specified in strong(varlist)) and include these point estimates in grid.
That is, at each grid point β0 for the potentially weakly-identified endogenous
regressor β, we calculate cue for strongly-identified endogenous regressors
η under the null hypothesis H0:β=β0.
We then evaluate test statistics for β, plugging the cue estimates
η in the strongly-identified endogenous regressors.
Note that this option may be computationally intensive.

Contents

Description

Tests and confidence sets

Examples

Saved results

Acknowledgements

References

Citation of twostepweakiv

Description

Building on the existing Stata package weakiv, twostepweakiv construct tests for weak instruments and two-step
identification-robust confidence sets for the coefficients on endogenous variables
by comparing non-robust Wald confidence sets to robust confidence sets
based on the linear combination test proposed by Andrews (2016).

twostepweakiv can be used to estimate linear IV minimum-distance models.
twostepweakiv supports a range of variance-covariance estimators for linear IV models
including heteroskedastic-, autocorrelation-, and one- and two-way cluster-robust VCEs.

twostepweakiv constructs confidence set for the coefficient on endogenous
variable of interest when there are multiple endogenous variables using a refined
projection method as in Andrews (2018).
There are several options available for models with 2 or more endogenous regressors.
(a) The user can specify, using the strong(.) option,
that some coefficients are strongly identified,
in which case twostepweakiv will report tests for the
weakly-identified subset of coefficients.
(b) The project(.) option requests the reporting
of refined projection-based confidence sets
for the specified endogenous regressors.

twostepweakiv should be used as a standalone estimator
where the user provides the specification of the model.
twostepweakiv works by calling ivreg2 first to parse the specification
and then estimate a minimum-distance model
depending what the user has specified as estimator.
twostepweakiv passes all user-specified model estimation options
to the estimation command:
variable lists, VCE specification, estimation method, etc.

twostepweakiv requires avar (Baum and Schaffer 2013) to be installed.
twostepweakiv will prompt the user for installation of
avar if necessary.
avar is an essential component and twostepweakiv will not run without it.
Since twostepweakiv calls ivreg2 and ivreg2 requires ranktest
to be installed, twostepweakiv will prompt the user to install it if necessary.

Estimator notes:

All estimators are formulated as minimum distance (MD) estimators following
weakiv and Finlay and Magnusson (2009).
We drop the robust option in ivreg2 because the choice of estimator
implies the choice of weight matrix (2sls and liml for inefficient
weight matrix and md2s and cue for efficient weight matrix).
The choice of VCE estimator is not necessarily the same as the choice of the weight matrix.
By default, we calculate VCE estimators robust to heteroskedasticity regardless
of choice of estimator, so that test statistics are robust to heteroskedasticity
in all cases. Other types of VCE estimators can be specified in cluster
for clustered VCE estimator and, kernel for kernel-based VCE estimator.
More details can be found in ivreg2.

Tests and confidence sets

twostepweakiv calculates minimum distance (MD)
versions of weak-instrument-robust tests of the coefficients
on the endogenous variables in a linear instrumental variables (IV) estimation.
When the IV model contains more instruments than endogenous regressors
(the model is overidentified),
twostepweakiv can also conduct the K test and a linear combination
of K test and AR test: the LC. twostepweakiv allows
inefficient weight matrices in K statistics, which is used to construct
confidence sets for 2sls estimators based on K_2sls or LC_2sls test.

In the construction of the MD versions of these tests,
any exogenous regressors are first partialled out.
For further discussion of these tests,
see Andrews (2018),
Finlay and Magnusson (2009),
Kleibergen (2002, 2005),
Magnusson (2010),
and the references therein.

The LC test combines the K and AR statistics.
Unlike the K test,
the LC test does not suffer from the problem of spurious power losses.
It can also be used to construct valid two-step identification-robust
confidence sets proposed by Andrews (2018).
For more details on how to construct the LC or LC_2sls test,
see the documentation. The default behavior of twostepweakiv is to set the
size of all tests at 5%. For valid two-step identification-robust
confidence sets, the default behavior is to set the distortion cutoff at 5%.

twostepweakiv inverts the above tests to obtain and report
identification-robust confidence sets by grid search.

twostepweakiv can also accommodate models with multiple endogenous regressors,
where some coefficients are weakly identified and some are strongly identified.
twostepweakiv supports this via the strong(.) and
project(.) options.

The strong(.) option essentially removes the strongly-identified coefficients from the testing,
and twostepweakiv reports tests and confidence sets
for the remaining weakly-identified coefficient(s).
Testing in this case follows the method of Kleibergen (2004);
see Mikusheva (2013) for a concise description.
Briefly, the method uses the standard formulae for weak-identification-robust statistics,
but for the strongly-identified coefficients replaces hypothesized values
with estimates obtained under the null from an efficient estimator.
The default efficient estimators are 2-step efficient MD;
the cuestrong replaces these with
the CUE estimators
(note that the CUE estimator requires numerical optimization
and grid searches in particular will be slow with this option).
To obtain confidence sets,
the procedure is repeated for each hypothesized value
of the weakly-identified coefficient(s).

The project(.) option implements refined projection-based
confidence sets for the listed weakly-identified endogenous variable.
Unlike the conventional projection method, we alter test statistic
(specifically the K statistic) to focus inference for the listed weakly-identified endogenous variable.
Thus we refer to this method the refined projection method.
See Chaudhuri and Zivot (2011) and Andrews (2018) for a discussion and references.
The refined projection-based confidence sets implemented by
twostepweakiv require grid search.
To get an accurate projection-based CI for a variable,
the user should specify a suitably large number of grid points
in that dimension.

Examples

Setup

. clear

. use http://www.stata.com/data/jwooldridge/eacsap/mroz.dta

. gen byte poshours=(hours>0)

Constructs a valid two-step identification-robust confidence set for educ
in the lwage equation based on Wald and LC_2sls tests (default is LC_2sls
due to 2sls estimator, which uses inefficient weight matrix). Confidence sets
based on AR and K_2sls tests are also reported.

. twostepweakiv 2sls lwage exper expersq (educ = fatheduc motheduc)

Constructs valid two-step identification-robust confidence sets
for two weakly-identified endogenous regressors respectively based on refined projection method;
Report CUE and center grid on CUE point estimator.

. twostepweakiv 2sls lwage exper expersq (educ hours = fatheduc motheduc kidslt6 kidsge6), cuepoint project(_all)

Constructs valid two-step identification-robust confidence sets
for two weakly-identified endogenous regressors respectively based on conventional
projection method, with a grid of 10x15=900 points.
Note how the projection-based CI for educ corresponds to the range of the x axis under the confidence set,
and the projection-based CI for exper corresponds to the range of the y axis to the left of the confidence set.

. twostepweakiv 2sls lwage (educ exper = fatheduc motheduc kidslt6 kidsge6), citestlist(lc_2sls) gridpoints(10 15)

Note that the conventional projection-based confidence set for educ is
output as the range of the x axis under the joint confidence set, which can be calculated
by the following code.
The conventional projection-based confidence set for exper corresponds to
the range of the y axis under the joint confidence set, which can be calculated similarly.

matrix table = e(citable)
matrix p1citable = J(10,2,.) //create a matrix with grid points of educ and rejection indicator
matrix colnames p1citable = null1 lc_2sls_r
forval i = 1/10 {
local r1=15*(`i'-1)+1 //for each grid point of x, there are 15 grid points of y
local r2=15*(`i')
matrix p1citable[`i',1]=table[`r1',"null1"]
matrix lc_2sls_r_vector = table[`r1'..`r2',"lc_2sls_r"]
mata: st_matrix("r",sum(st_matrix("lc_2sls_r_vector")):==15) //a grid point x0 is rejected if all grid points of (x0,y) are rejected
matrix p1citable[`i',2]=r
}
matrix list p1citable

matrix table = e(citable)
local citablerowname : colfullnames table
mata : st_matrix("table", sort(st_matrix("table"), 2)) //citable is sorted by grid points of x, now need to resort by y
matrix colnames table = `citablerowname'
matrix p2citable = J(15,2,.) //create a matrix with grid points of educ and rejection indicator
matrix colnames p2citable = null2 lc_2sls_r
forval i = 1/15 {
local r1=10*(`i'-1)+1 //for each grid point of y, there are 10 grid points of x
local r2=10*(`i')
matrix p2citable[`i',1]=table[`r1',"null2"]
matrix lc_2sls_r_vector = table[`r1'..`r2',"lc_2sls_r"]
mata: st_matrix("r",sum(st_matrix("lc_2sls_r_vector")):==10) //a grid point y0 is rejected if all grid points of (x,y0) are rejected
matrix p2citable[`i',2]=r
}
matrix list p2citable

Request test of specific point null: education coeff=0.1 and exper coeff=0.05.
Test statistics and p-values (if calculated) are reported in e(citable).

. twostepweakiv md2s lwage (educ exper = fatheduc motheduc kidslt6 kidsge6), gridmin(0.1 0.05) gridmax(0.1 0.05) gridpoints(1 1) citestlist(ar k lc)

. matrix list e(citable)

Constructs valid two-step identification-robust confidence sets
for hours while educ assumed strongly identified.

. twostepweakiv 2sls lwage exper expersq (educ hours = fatheduc motheduc kidslt6 kidsge6), strong(educ)

Specify a test level of 90% and a distortion cutoff of 10% .

. twostepweakiv 2sls lwage exper expersq (educ = fatheduc motheduc), level(90) gammalevel(10)

Time-series setup

. clear

. use http://fmwww.bc.edu/ec-p/data/wooldridge/phillips.dta

. tsset year, yearly

Constructs a valid two-step identification-robust confidence set for unem
based on Wald and LC_2sls tests (default is LC_2sls
due to 2sls estimator, which uses inefficient weight matrix). Confidence sets
based on AR and K tests are also reported. Tests are calculated with the Newey-Set HAC covariance
estimator with bandwidth equal to 3.

. twostepweakiv 2sls cinf (unem = l(1/3).unem), bw(3)

Saved results

twostepweakiv saves the following in e():

Scalars

e(kwt) weight on K in K-J test

e(endo_ct) number of endogenous regressors

e(wendo_ct) number of weakly-identified endogenous

e(sendo_ct) number of strongly-identified endogenous

e(overid) degree of overidentification

e(small) =1 if small-sample adjustments used, =0 otherwise

e(N) sample size

e(N_clust) number of clusters (if cluster-robust VCE used)

e(ar_level) level in percent used for AR confidence interval

e(k_level) level in percent used for K confidence interval

e(wald_level) level in percent used for Wald confidence interval

e(gamma_level) gamma_min used for LC_2sls confidence interval

e(gamma_hat) distortion cutoff for LC_2sls confidence interval

e(points) number of points in grid used to estimate confidence sets

e(clrsims) number of draws used in simulations to obtain p-values for CLR test

Macros

e(ar_cset) confidence set based on AR test

e(k_cset) confidence set based on K or K_2sls test

e(wald_cset) confidence set based on Wald test

e(lc_cset) confidence set based on LC or LC_2sls test

e(pxx_yy_cset) as above, projection-based confidence set for variable xx, test yy

e(inexog) list of exogenous regressors (excluding any included in the tests)

e(exexog) list of excluded instruments

e(depvar) dependent variable

e(endo) endogenous variable(s)

e(wendo) weakly-identified endogenous variable(s)

e(sendo) strongly-identified endogenous variable(s)

e(pwendo) endogenous vars with projection-based confidence sets

e(pwendo_nlist) corresponding numbers for e(pwendo); used to identify projection-based confidence sets in e(.) (see above)

e(gridpoints) list of grid points in each dimension

e(model) linear IV

e(waldcmd) iv_command estimator used to estimate standard IV model: 2sls, md2s,liml or cue

e(level) default confidence level in percent used for tests of null = 100*(1-alpha)

e(method) md

e(cmd) twostepweakiv

Matrices

e(citable) table with test statistics, p-values, and rejection
indicators for every grid point over which hypotheses are tested.
If strong(.) is used, the estimated coefficients
for the strongly-identified regressors are also recorded.

e(pxxcitable) grid table with rejection indicators
for projection-based inference;
xx will be 1 or 2 numbers corresponding to the endogenous regressor(s)

e(F) first stage F statistics for all endogenous regressors.

e(wbeta) weakly-identified coefficients from IV model used for Wald tests

e(var_wbeta) VCE from IV model used for Wald tests

e(sbeta) if strong(.) is used, estimated strongly-identified coefficients at null

e(ebeta) Wald point estimates for full set of endogenous regressors

e(cuebeta) if cuepoint is used, CUE point estimates for full set of endogenous regressors

Acknowledgements

twostepweakiv builds on and extends the command weakiv by Finlay, Magnusson and Schaffer (2013).
The main differences and extensions are:
(a) construct valid two-step identification-robust confidence sets based on Andrews (2018) for MD models;
(b) implement linear combination test based on Andrews (2016) and support K test with inefficient weight matrix;
(c) support for MD versions of estimators and tests;
(d) support for refined projection-based inference;
(e) changes in terminology, syntax etc.

References

Andrews, I. 2016.
Conditional Linear Combination Tests for Weakly Identified Models.
Econometrica 84(6):21552182.

Andrews, I. 2018.
Valid Two-Step Identification-Robust Confidence Sets for GMM.
Review of Economics and Statistics 100 (2) :337-348.

Anderson, T. W. and Rubin, H. 1949.
Estimation of the Parameters of Single Equation in a Complete
System of Stochastic Equations.
Annals of Mathematical Statistics 20:4663.

Baum, C.F. and Schaffer, M.E. 2013.
AVAR: module to perform asymptotic covariance estimation for iid and
non-iid data robust to heteroskedasticity, autocorrelation, 1- and 2-way
clustering, and common cross-panel autocorrelated disturbances.
http://ideas.repec.org/c/boc/bocode/s457689.html.

Chernozhukov, V. and Hansen, C. 2005.
The Reduced Form:
A Simple Approach to Inference with Weak Instruments.
Working paper, University of Chicago, Graduate School of Business.
http://dx.doi.org/10.2139/ssrn.937943.

Chernozhukov, V. and Hansen, C. 2008.
The Reduced Form:
A Simple Approach to Inference with Weak Instruments.
Economics Letters 100(1):68-71.

Finlay, K. and Magnusson, L.M. 2009.
Implementing weak-instrument robust tests for
a general class of instrumental-variables models.
Stata Journal 9(3):398-421.
http://www.stata-journal.com/article.html?article=st0171.

Guggenberger, P., Kleibergen, F., Mavroeidis, S. and Chen, L. 2012.
On the Asymptotic Sizes of Subset AndersonRubin and Lagrange Multiplier Tests
in Linear Instrumental Variables Regression.
Econometrica, 80:2649-2666.

Jann, B. 2009.
ESTOUT: Stata module to make regression tables.
http://ideas.repec.org/c/boc/bocode/s439301.html.

Kleibergen, F. 2002.
Pivotal Statistics for Testing Structural Parameters in Instrumental Variables Regression.
Econometrica, 70:1781-1803.

Kleibergen, F. 2004.
Testing Subsets of Structural Parameters in the Instrumental Variables Regression Model.
Review of Economics and Statistics, 86:418-423.

Kleibergen, F. 2005.
Testing Parameters in GMM Without Assuming that They Are Identified.
Econometrica, 73:1103-1123.

Kleibergen, F. and Paap, R. 2006.
Generalized Reduced Rank Tests Using the Singular Value Decomposition.
Journal of Econometrics, 133:97-126.

Mander, A. 2005.
SURFACE: Stata module to draw a 3D wireform surface plot.
http://ideas.repec.org/c/boc/bocode/s448501.html.

Magnusson, L.M. 2010.
Inference in limited dependent variable models robust to weak identification.
Econometrics Journal, 13:S56-S79.

Mikusheva, A. 2013.
Survey on statistical inferences in weakly-identified instrumental variables models.
Applied Econometrics, 29:117-131.
http://econpapers.repec.org/article/risapltrx/0206.htm.

Moreira, M. 2003.
A Conditional Likelihood Ratio Test for Structural Models.
Econometrica, 71:1027-1048.

Mikusheva, A. and Poi, B. 2006.
Tests and confidence sets with correct size when instruments are potentially weak.
Stata Journal 6(3):335-347.
http://www.stata-journal.com/article.html?article=st0033_2.

Citation of twostepweakiv

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

Sun, L., 2018.
twostepweakiv: valid two-step identification-robust confidence sets
for instrumental-variable (IV) estimation of linear models.
https://github.com/lsun20/TwoStep.

Author

Liyang Sun, MIT, USA
lsun20@mit.edu

Help: ivreg2, weakiv