*! version 2.6.2 03aug2022

*! Sebastian Kripfganz, www.kripfganz.de

Title

xtdpdgmm -- GMM linear dynamic panel data estimation

Syntax

xtdpdgmm depvar [indepvars] [if] [in] [, options]

options

Model
iv(iv_spec) standard instruments; can be specified more than once

gmmiv(gmmiv_spec) GMM-type instruments; can be specified more than once

nl(nl_spec) add nonlinear moment conditions derived from error covariance structure

collapse collapse GMM-type into standard instruments

curtail(#) curtail the lag range for GMM-type instruments

model(model_spec) set the default model for the instruments and VCE

nolevel ignore specifications for the model in levels

norescale do not rescale the transformed moment conditions

wmatrix(wmat_spec) specify initial weighting matrix

center center moments in the optimal weighting matrix

* onestep|twostep use the one-step or two-step estimator

* igmm use the iterated GMM estimator

* cugmm use the continuously-updating GMM estimator

teffects add time effects to the model

noconstant suppress constant term

SE/Robust
vce(vce_spec) specify the vcetype for the SE estimation

small make degrees-of-freedom adjustment and report small-sample statistics

Reporting
overid compute overidentification statistics for reduced models

auxiliary display all coefficients as auxiliary parameters

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

noheader suppress output header

notable suppress coefficient table

nofooter suppress output footer

display_options control

Minimization
noanalytic do not use analytical closed-form solutions

from(init_spec) initial values for the coefficients

nodots display an iteration log instead of dots for each step of the iterated GMM estimator

igmm_options control the iterated GMM process; seldom used

minimize_options control the minimization process; seldom used

* You can specify at most one of these options. onestep is the default unless option nl(nl_spec) is specified, in which case twostep is the default.

iv_spec is

varlist [, lagrange(#_1 [#_2]) difference bodev model(model_spec) [no]rescale]

gmmiv_spec is

varlist [, lagrange(#_1 [#_2]) [no]collapse difference bodev model(model_spec) [no]rescale iid]

nl_spec is

noserial|iid|predetermined [, [no]collapse [no]rescale lag(#) weight(#)]

wmat_spec is

[unadjusted|independent|separate|identity] [, ratio(#)]

vce_spec is

[conventional|robust|cluster clustvar] [, model(model_spec) wc|dc]

model_spec is

level|difference|fodev|mdev|mean

init_specs is one of

matname [, skip copy]

# [# ...], copy

You must xtset your data before using xtdpdgmm; see [XT] xtset.

All varlists may contain factor variables; see fvvarlist.

depvar and all varlists may contain time-series operators; see tsvarlist.

See xtdpdgmm postestimation for features available after estimation and xtdpdgmmfe for a wrapper of xtdpdgmm with simplified syntax.

xtdpdgmm is a community-contributed program. The current version requires Stata version 13 or higher; see version history and updates.

Description

xtdpdgmm implements generalized method of moments (GMM) estimators for linear dynamic panel data models. GMM estimators can be specified with linear moment conditions in the spirit of Anderson and Hsiao (1981), Arellano and Bond (1991),
Arellano and Bover (1995), Blundell and Bond (1998), and Hayakawa, Qi, and Breitung (2019). xtdpdgmm can also incorporate the nonlinear moment conditions suggested by Ahn and Schmidt (1995) or Chudik and Pesaran (2022),
which can yield efficiency gains and more robust results for highly persistent data.

The model can be estimated with the one-step, two-step, iterated, or continuously-updating GMM estimator. The two-step estimator uses an optimal weighting matrix which is estimated from the one-step residuals.
The iterated GMM estimator, suggested by Hansen, Heaton, and Yaron (1996), further updates the weighting matrix until convergence.
The continuously-updating GMM estimator, also proposed by Hansen, Heaton, and Yaron (1996), updates the weighting matrix jointly with the coefficients.

For estimators other than the continuously-updating GMM estimator, the Windmeijer (2005) finite-sample standard error correction is implemented.
Alternatively, the Lee (2014), Hansen and Lee (2021), and Hwang, Kang, and Lee (2022) doubly-corrected misspecification-robust standard errors are available as well.

Possible model transformations include first differences, deviations from within-group means, and forward-orthogonal deviations. With the latter, backward-orthogonal deviations of the instrumental variables are possible.
Instruments for different model transformations can be combined flexibly to form a 'system GMM' estimator.

Options

Model

iv(varlist [, suboptions]) and gmmiv(varlist [, suboptions]) specify standard and GMM-type instruments, respectively. You may specify as many sets of standard instruments as you need.
Allowed suboptions for both type of instruments are lagrange(#_1 [#_2]), difference, bodev, model(level|difference|fodev|mdev|mean), and [no]rescale.
GMM-type instruments allow the additional suboptions [no]collapse and iid.

lagrange(#_1 [#_2]) specifies the range of lags of varlist to be used as instruments. Negative integers are allowed to include leads. The default depends on the type of instruments.

Used with option iv(), the default is lagrange(0 0). Specifying iv(varlist, lagrange(#_1 #_2)) is equivalent to specifying iv(L(#_1/#_2).(varlist))
unless suboption bodev is specified; see tsvarlist. lagrange(#_1) with only one argument is equivalent to lagrange(#_1 #_1) with two identical arguments.

Used with option gmmiv(), the default is lagrange(1 .) in combination with model(difference), and lagrange(0 .) otherwise.
Unless restricted with option curtail(), a missing value for #_1 requests all available leads to be used until #_2, while a missing value for #_2 requests all available lags to be used starting with #_1.
Thus, lagrange(. .) uses all available observations. lagrange(#_1) with only one argument is equivalent to lagrange(#_1 .).

collapse and nocollapse used with option gmmiv() request to either collapse or to not collapse the GMM-type instruments into standard instruments. The suboption collapse is useful to reduce the number of instruments,
in particular if all available lags are used. With a limited number of lags, gmmiv(varlist, lagrange(#_1 #_2) collapse) is equivalent to iv(varlist, lagrange(#_1 #_2)).
The suboption nocollapse can be used to override the default set by the global option collapse.

difference requests a first-difference transformation of varlist. This is equivalent to specifying iv(D.(varlist)); see tsvarlist.

bodev requests a backward-orthogonal deviations transformation of varlist. This is only possible in combination with model(fodev).

model(model) specifies if the instruments apply to the model in levels, model(level), in first differences, model(difference), in forward-orthogonal deviations, model(fodev),
in deviations from within-group means, model(mdev), or in within-group means, model(mean). The default is model(level) unless otherwise specified with the global option model(model).

rescale and norescale request to either rescale or to not rescale the moment conditions such that the transformed error term retains the same variance under the assumption that the untransformed idiosyncratic error component
is independent and identically distributed. These suboptions are seldom used and only have an effect in combination with model(fodev), model(mdev), or model(mean).
They similarly affect the transformation of varlist when suboption bodev is specified. rescale is the default unless otherwise specified with the global option norescale.

iid used with option gmmiv() specifies instruments valid under an error-components structure with an independent and identically distributed idiosyncratic error component.
If specified as gmmiv(L.depvar, iid), these are the additional instruments implied by the linear moment conditions derived by Ahn and Schmidt (1995) under the assumption of homoskedastic errors.
If specified as gmmiv(L.depvar, difference iid), these are the additional instruments which can replace the nonlinear moment conditions derived by Chudik and Pesaran (2022).
This suboption is seldom used and it implies the other suboptions model(difference) and lagrange(0 0).

nl(noserial|iid|predetermined [, suboptions]) adds nonlinear moment conditions that are valid under an error-components structure with specific assumptions on the idiosyncratic error component.
Allowed suboptions are [no]collapse, [no]rescale, lag(#), and weight(#).

nl(noserial) adds the nonlinear moment conditions suggested by Ahn and Schmidt (1995) under the absence of serial correlation in the idiosyncratic error component.

nl(iid) adds the nonlinear moment conditions suggested by Ahn and Schmidt (1995) under homoskedasticity and the absence of serial correlation in the idiosyncratic error component.
It further adds linear moment conditions of the form gmmiv(L.depvar, iid [collapse]) that are valid under this assumption.

nl(predetermined) adds the nonlinear moment conditions suggested by Chudik and Pesaran (2022) under the absence of serial correlation in the idiosyncratic error component.
It requires that all indepvars are predetermined or strictly exogenous.

collapse requests to add up the moment conditions to form a single moment condition. nocollapse can be used to override the default set by the global option collapse.

rescale and norescale request to either rescale or to not rescale the moment conditions such that the transformed error term retains the same variance
under the assumption that the untransformed idiosyncratic error term is independent and identically distributed. These suboptions are seldom used and only have an effect in combination with nl(iid).
rescale is the default unless otherwise specified with the global option norescale.

lag(#) specifies the minimum lag of the first-differenced error term in the moment conditions under the absence of serial correlation. The default is lag(1).
This option is only allowed in combination with nl(noserial).

weight(#) specifies the weight of the nonlinear moment conditions in the initial weighting matrix relative to the linear moment conditions. The default is weight(1).
Specifying weight(0) implies that the nonlinear moment conditions are ignored in the first estimation step.

collapse requests to collapse all GMM-type instruments into standard instruments and to collapse the nonlinear moment conditions into a single moment condition.

curtail(#) requests to curtail the lag range for GMM-type instruments if either #_1 or #_2 in the gmmiv() suboption lagrange(#_1 [#_2]) are specified as missing values.
If #_1 is missing, no leads will be used. If #_2 is missing, all available lags until # will be used. Thus, lagrange(. .) is equivalent to lagrange(0 #).
curtail(.) can be specified to only restrict #_1.

model(model) sets the default model used to generate the instruments specified with options iv() and gmmiv() and the default model for the conventional variance estimator specified with option vce().
model is allowed to be level, difference, fodev, mdev, or mean. The default is model(level) unless option nolevel is specified, in which case the default is model(difference).

nolevel requests that all model specifications refer to a transformed model. This changes the default from model(level) to model(difference).
All instruments which are explicitly specified for model(level) or model(mean) are ignored. With this option, instruments for the time dummies created with option teffects are no longer specified for the model in levels
but for the default model set with option model(model). The degrees-of-freedom adjustment with option small is corrected for the reduction of time periods in the transformed model or the absorbed group-specific effects.
Groups with only a single observation are removed from the estimation sample. A regression intercept is still estimated for the model in levels unless option noconstant is specified.

norescale requests not to rescale the moment conditions. By default, the moment conditions for model(fodev), model(mdev), and model(mean) are rescaled by a group-specific factor
such that the transformed error term retains the same variance under the assumption that the untransformed idiosyncratic error term is independent and identically distributed.
A similar transformation is applied to the nonlinear moment conditions added with option nl(iid). In combination with option center,
norescale ignores an adjustment to the mean of the moment functions in the optimal weighting matrix, which is applied by default when the number of observations differs across clusters, as in the case of unbalanced panel data.

wmatrix([wmat_type] [, ratio(#)]) specifies the weighting matrix to be used to obtain one-step GMM estimates or initial estimates for two-step or iterated GMM estimation.
wmat_type is either unadjusted, independent, separate, or identity.

wmatrix(unadjusted), the default, is optimal for an error-components structure with a group-specific component and an independent and identically distributed idiosyncratic component
if none of the instruments refer to the model in levels or if the variance ratio of the group-specific error component to the idiosyncratic error component is known,
and only if there are no nonlinear moment conditions. The variance ratio can be specified with the suboption ratio(#). The default is ratio(0).
Nonlinear moment conditions are always treated as independent in the initial weighting matrix.

wmatrix(independent) is the same as wmatrix(unadjusted) but treats the model in levels and the transformed models as independent, thus ignoring the covariance between the respective error terms.

wmatrix(separate) is the same as wmatrix(unadjusted) but treats the model in levels and the transformed models as separate models with an independent and identically distributed error term for the transformed models,
thus ignoring the covariance between the respective error terms and the serial correlation of the transformed error terms.

wmatrix(identity) is the identity matrix. This option is seldom used.

center requests to center the moment functions in the computation of the optimal weighting matrix.

onestep, twostep, igmm, and cugmm specify which estimator is to be used. At most one of these options can be specified.

onestep requests the one-step GMM estimator to be computed which is based on the initial weighting matrix specified with option wmatrix(wmat_spec). This is the default unless option nl(nl_spec) is specified.
In a model without nonlinear moment conditions and with weighting matrix wmatrix(unadjusted), the one-step estimator corresponds to the two-stage least squares estimator.

twostep requests the two-step GMM estimator to be computed which is based on an optimal weighting matrix. This is the default if option nl(nl_spec) is specified.
An unrestricted (cluster-robust) optimal weighting matrix is computed using one-step GMM estimates. The unrestricted weighting matrix allows for intragroup correlation at the level specified with vce(cluster clustvar).
By default, clustvar equals panelvar.

igmm requests the iterated GMM estimator to be computed. At each iteration step, an unrestricted (cluster-robust) optimal weighting matrix is computed using the GMM estimates from the previous step.
Iterations continue until convergence is achieved for the coefficient vector or the weighting matrix, or the maximum number of iterations is reached; see igmm_options.

cugmm requests the continuously-updating GMM estimator to be computed. As a function of the model's coefficients, the unrestricted (cluster-robust) weighting matrix is updated jointly with the coefficients.

teffects requests that time-specific effects are added to the model. Time dummies are instrumented by themselves for the model in levels unless option nolevel is specified,
in which case the time dummies are instrumented for the model specified by option model(model). The first time period in the estimation sample is treated as the base period
unless options nolevel and model(fodev) are jointly specified, in which case the last time period is treated as the base period.

noconstant; see [R] estimation options.

SE/Robust

vce(vcetype [, model(model) wc|dc]) specifies the type of standard error reported, which includes types that are derived from asymptotic theory (conventional),
that are robust to some kinds of misspecification (robust), and that allow for intragroup correlation (cluster clustvar). model is allowed to be level, difference, fodev, mdev, or mean.

vce(conventional) uses the conventionally derived variance estimator. It is robust to some kinds of misspecification if the two-step GMM estimator is used or if nonlinear moment conditions are employed.
After one-step estimation, the error variance is by default computed from the level residuals, model(level), unless it is specified that it is to be computed from the residuals in first differences, model(difference),
the residuals in forward-orthogonal deviations, model(fodev), the residuals in deviations from within-group means, model(mdev), or the within-group means of the residuals, model(mean).
The sandwich estimator is used for one-step GMM estimation with nonlinear moment conditions, but without the Windmeijer (2005) correction. vce(conventional) is the default, although in most cases vce(robust) would be recommended.

vce(robust) and vce(cluster clustvar) use the sandwich estimator for one-step GMM estimation with only linear moment conditions. Suboption wc, the default, applies the Windmeijer (2005) finite-sample correction
to the conventional two-step or iterated GMM estimator. For GMM estimation with nonlinear moment conditions, the sandwich estimator with the respective Windmeijer (2005) correction is computed for one-step, two-step, and iterated estimation.
Alternatively, the Lee (2014), Hansen and Lee (2021), and Hwang, Kang, and Lee (2022) doubly-corrected misspecification-robust standard errors are available with suboption dc.
No correction is applied for continuously-updating GMM estimation. vce(robust) is equivalent to vce(cluster panelvar).

small requests that a degrees-of-freedom adjustment be made to the variance-covariance matrix and that small-sample t and F statistics be reported.
The adjustment factor is (N-1)/(N-K) * M/(M-1), where N is the number of observations, M the number of clusters specified with vce(cluster clustvar), and K the number of coefficients.
When option nolevel is specified, the adjustment factor is corrected for the reduction of time periods in the transformed model or the absorbed group-specific effects.
By default, no degrees-of-freedom adjustment is made and z and Wald statistics are reported. This option does not affect the computation of the optimal weighting matrix.

Reporting

overid requests to compute the overidentification statistics for the reduced models, leaving out one subset of moment conditions at a time.
These statistics can subsequently be used to compute Sargan-Hansen difference tests of the overidentifying restrictions with the postestimation command estat overid; see xtdpdgmm postestimation.
This option is not needed to compute the Sargan-Hansen test for the full model.

auxiliary displays all coefficients as auxiliary parameters and suppresses display of the vcetype. This option is seldom used.
It allows the subsequent use of postestimation commands that require equation-level scores; see [R] suest.

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

coeflegend; see [R] estimation options.

noheader suppresses display of the header above the coefficient table that displays the number of observations and moment conditions.

notable suppresses display of the coefficient table.

nofooter suppresses display of the footer below the coefficient table that displays the instruments corresponding to the linear moment conditions.

display_options: noci, nopvalues, noomitted, vsquish, noemptycells, baselevels, allbaselevels, nofvlabel, fvwrap(#), fvwrapon(style), cformat(%fmt),
pformat(%fmt), sformat(%fmt), and nolstretch; see [R] estimation options.

Minimization

noanalytic requests that the coefficient estimates are obtained numerically instead of using analytical closed-form solutions. This option is seldom used.
It is implied when the model contains nonlinear moment conditions under the option nl(nl_spec) or if the continuously-updating GMM estimator is used, because closed-form solutions do not exist in this case.

from(init_specs) specifies initial values for the coefficients; see [R] maximize. By default, initial values are set to zero unless the continuously-updating GMM estimator is used.
In the latter case, the default initial values are the two-stage least squares estimates, ignoring any nonlinear moment conditions.

nodots specifies that an iteration log is displayed instead of dots. By default, one dot character is displayed for each step of the iterated GMM estimator.
For the one-step and two-step estimator, display of an iteration log is the default.

igmm_options: igmmiterate(#), igmmeps(#), and igmmweps(#); see [R] gmm. These options are seldom used and only have an effect if the iterated GMM estimator is used.

minimize_options: iterate(#), nolog, showstep, showtolerance, tolerance(#), ltolerance(#), nrtolerance(#), and nonrtolerance; see [R] maximize.
These options are seldom used.

Remarks

Remarks are presented under the following headings:

Model transformations

Instrument transformations

Strictly exogenous, predetermined, and endogenous variables

Nonlinear moment conditions

Curtailing and collapsing of the instruments

Rescaling of the moment conditions

Time effects

Time-invariant regressors

Model transformations

xtdpdgmm estimates panel data models of the type

y = X b + u + e

referred to as the untransformed model, model(level), where y denotes the vector containing all observations of depvar, X the matrix of indepvars, b the regression coefficients, u the group-specific error component,
and e the idiosyncratic error component. To remove the group-specific error component, a model transformation D can be applied which is orthogonal to u (i.e. D u = 0):

D y = D X b + D e

Matrix D can yield a first-difference transformation, model(difference), forward-orthogonal deviations, model(fodev), deviations from within-group means, model(mdev), or within-group means, model(mean).

Instrumental variables can be specified for the untransformed model and/or for one or more of the transformed models. However, it is important to keep in mind that the estimation is not performed separately for different models.
In fact, instead of transforming the estimation equation, xtdpdgmm internally transforms the instruments Z for the transformed models back into instruments for the untransformed model.
Technically, this is achieved by forming instruments D' Z for the untransformed model, where D' is the transpose of the above transformation matrix.

These transformed instruments D' Z can be obtained as new Stata variables with option iv of the postestimation command predict; see xtdpdgmm postestimation.
The new variables could subsequently be used as standard instruments to replicate the xtdpdgmm results with alternative Stata commands such as ivregress; see [R] ivregress.

Instrument transformations

The model transformations should not be confused with transformations of the instrumental variables. To specify first-differenced instruments D Z for the first-differenced model,
the options difference and model(difference) need to be combined. Internally, xtdpdgmm then constructs transformed instruments D' D Z for the untransformed model as explained above.

Taking lags and first differences of a variable is interchangeable such that the specifications iv(L#D.(varlist)), iv(L#.(varlist), d), iv(D.(varlist), l(#)),
and iv(varlist, d l(#)) all create identical instruments. This is not true for the combination of lags and backward-orthogonal deviations.
The specification iv(L#.(varlist), bod m(fod)) creates backward-orthogonal deviations of the #-th lag of varlist, as suggested by Hayakawa, Qi, and Breitung (2019),
while iv(varlist, bod l(#) m(fod)) creates the #-th lag of the backward-orthogonal deviations of varlist.

Strictly exogenous, predetermined, and endogenous variables

Strictly exogenous variables are variables that are uncorrelated with the idiosyncratic error component of all time periods.
Predetermined variables, also referred to as weakly exogenous variables, are variables that are uncorrelated with the idiosyncratic error component of the current and all following time periods but which might be correlated with past errors.
Endogenous variables are variables that are uncorrelated with the idiosyncratic error component of all following time periods but which might be correlated with current or past errors.

Strictly exogenous variables are valid instruments with lagrange(. .) for any model transformation.
Predetermined variables are valid instruments with lagrange(0 .) for model(level) or model(fodev), but only lagrange(1 .) for model(difference).
Endogenous variables are valid instruments with lagrange(1 .) for model(level) or model(fodev), but only lagrange(2 .) for model(difference).

If the idiosyncratic error term is serially correlated in the untransformed model, the classification of variables into these three groups can become problematic.
Some variables might become correlated with the error term in the following periods, which would require an adjustment of the valid lag range.
As a general rule, if the serial correlation of the idiosyncratic error term in levels is of order #, then the starting lag needs to be increased by # as well.
Alternatively, the list of indepvars could be amended to obtain a dynamically complete model with serially uncorrelated errors.

Variables are only valid instruments for the untransformed model, model(level), or the model in within-group means, model(mean), if they are uncorrelated with the group-specific error component.
This might often be an unreasonable assumption if the instruments are not first-differenced with option difference, as proposed by Blundell and Bond (1998).
However, there is no guarantee that first-differenced instruments for the untransformed model are uncorrelated with the group-specific error component. This remains an assumption to be justified by the user.

When instruments are combined for multiple model transformations, some of them might become redundant.
A model specification approach that sequentially classifies variables as endogenous, predetermined, or strictly exogenous is proposed by Kiviet (2020).

Nonlinear moment conditions

A serially uncorrelated idiosyncratic error term in the model in levels is a necessary condition for the validity of the instruments in most dynamic panel data models.
In that case, the nonlinear moment conditions added by the option nl(noserial) only require the mild additional assumption that both the group-specific error component and the initial observations of varlist and indepvars are
uncorrelated with the first-differenced idiosyncratic error component. The moment conditions added by the option nl(iid) require an additional homoskedasticity assumption.
Both types of nonlinear moment conditions were proposed by Ahn and Schmidt (1995).

When there is evidence that the idiosyncratic error term is serially correlated, valid nonlinear moment conditions could still be formed by choosing a minimum lag of the first-differenced error term in the nonlinear moment conditions
by specifying nl(noserial, lag(#)). If the serial correlation of the idiosyncratic error term in levels is of order # minus 1, then lag(#) would still produce valid moment conditions.

Chudik and Pesaran (2022) proposed alternative nonlinear moment conditions, which are added by the option nl(predetermined). In addition to a serially uncorrelated idiosyncratic error term, they require that all indepvars are
predetermined or strictly exogenous. It further requires that the deviations of the initial observations of depvar from its long-run mean are uncorrelated with the first-differenced idiosyncratic error component.
This is a weaker assumption than the corresponding requirement for nl(noserial) on the group-specific error component and the initial observations.
Under an additional homoskedasticity assumption, the nonlinear moment conditions proposed by Chudik and Pesaran (2022) can be replaced by linear moment conditions with the gmmiv() suboption iid.

Adding the nonlinear moment conditions might improve the (asymptotic) efficiency of the GMM estimator and could help to identify the coefficients.
However, the nl(noserial) or nl(predetermined) moment conditions might become redundant if instruments for model(level) in the spirit of Blundell and Bond (1998) are added.

Even if the weighting matrix for the one-step GMM estimator was optimal in the absence of nonlinear moment conditions, after adding them it is no longer optimal.
For efficient estimation, the two-step, iterated, or continuously-updating GMM estimator should be used.
It is not recommended to use the noconstant option in combination with nl(noserial) or nl(iid) even if all other moment conditions refer to transformed models.

xtdpdgmm minimizes the GMM criterion function numerically with the Gauss-Newton technique if some of the moment conditions are nonlinear, if the continuously-updating GMM estimator is used, or if the option noanalytic is specified.
Otherwise, the estimates are obtained from the analytical closed-form solutions of the first-order conditions.

Curtailing and collapsing of the instruments

Depending on the specification, the number of GMM-type instruments grows linearly or quadratically in the number of time periods. The total number of moment conditions thus easily becomes large relative to the number of groups in the sample.
As summarized by Roodman (2009), such an instrument proliferation can have severe consequences including biased coefficient and standard error estimates and weakened specification tests.

The most common approaches to reduce the number of instruments, as discussed by Roodman (2009) and Kiviet (2020), are curtailing the lags used to form GMM-type instruments with the lagrange() suboption,
or collapsing the GMM-type into standard instruments with the collapse suboption. The latter approach can also be applied to the nonlinear moment conditions which effectively creates a sum over all time-specific moment conditions.

Rescaling of the moment conditions

The moment conditions under deviations from within-group means with suboption model(mdev) are rescaled by the square root of the ratio T_i / (T_i - 1), where T_i is the number of observations for group i,
unless the option norescale is specified. This ensures that the variance of the error term is left unchanged by the transformation under the assumption that the untransformed error term is independent and identically distributed.
Similarly, the moment conditions for the model in within-group means with suboption model(mean) are rescaled by the square root of T_i.
Rescaling for model(mdev) or model(mean) has no effect with balanced panel data.

For the moment conditions under forward-orthogonal deviations with suboption model(fodev), a scaling factor with the same purpose was suggested by Arellano and Bover (1995).
A similar factor is also used to rescale the instrumental variables under backward-orthogonal deviations with suboption bodev and to rescale the nonlinear moment conditions specified with option nl(iid).
This rescaling can be switched off again with the option norescale.

Time effects

The option teffects adds dummy variables i.timevar, after removing collinear dummies, to indepvars and as standard instruments for the untransformed model, iv(i.timevar, model(level)).
This may not be desired in some cases if all other moment conditions refer to transformed models, for example if the weighting matrix of the one-step GMM estimator for the transformed model is already optimal,
which typically requires a homoskedasticity assumption. In this case, the option nolevel can be used to create standard instruments for the transformed model instead.

Time dummies and their instruments can also be specified manually. However, they should generally only be specified as instruments for a single model transformation or the untransformed model, not both.
Otherwise, some of these instruments would be (asymptotically) redundant.

Time-invariant regressors

If time-invariant regressors are included in indepvars, the identification of their coefficients requires at least as many instruments specified for model(level) or model(mean) as there are time-invariant regressors.
These should generally be in addition to any first-differenced instruments or time dummies to avoid spurious estimates of those coefficients, as discussed by Kripfganz and Schwarz (2019).

Example

Setup

. webuse abdata

Anderson-Hsiao IV estimators with strictly exogenous covariates

. xtdpdgmm L(0/1).n w k, iv(L2.n w k, d) m(d) nocons

. xtdpdgmm L(0/1).n w k, iv(L2.n) iv(w k, d) m(d) nocons

Arellano-Bond one-step GMM estimator with strictly exogenous covariates and curtailed/collapsed instruments

. xtdpdgmm L(0/1).n w k, gmm(L.n, l(1 4)) iv(w k, d) m(d) c nocons

Arellano-Bover two-step GMM estimator with predetermined covariates and curtailed/collapsed instruments

. xtdpdgmm L(0/1).n w k, gmm(L.n w k, l(0 3)) m(fod) c two vce(r)

Ahn-Schmidt two-step GMM estimators with predetermined covariates and curtailed/collapsed instruments

. xtdpdgmm L(0/1).n w k, gmm(L.n w k, l(1 4)) m(d) nl(noser) c two vce(r)

. xtdpdgmm L(0/1).n w k, gmm(L.n w k, l(1 4)) m(d) nl(iid) c two vce(r)

Chudik-Pesaran two-step GMM estimator with predetermined covariates and curtailed/collapsed instruments

. xtdpdgmm L(0/1).n w k, gmm(L.n w k, d l(1 4)) m(d) nl(pre) c two vce(r)

Blundell-Bond two-step, iterated, and continuously-updating GMM estimators with predetermined covariates and curtailed/collapsed instruments

. xtdpdgmm L(0/1).n w k, gmm(L.n w k, l(1 4) m(d)) iv(L.n w k, d) c two vce(r)

. xtdpdgmm L(0/1).n w k, gmm(L.n w k, l(1 4) m(d)) iv(L.n w k, d) c igmm vce(r)

. xtdpdgmm L(0/1).n w k, gmm(L.n w k, l(1 4) m(d)) iv(L.n w k, d) c cu

Hayakawa-Qi-Breitung IV estimator with predetermined covariates

. xtdpdgmm L(0/1).n w k, iv(L.n w k, bod) m(fod) nocons

Replication of a static (weighted) fixed-effects estimator

. xtdpdgmm n w k, iv(w k) m(md)

. by id: egen weight = count(e(sample))

. replace weight = sqrt(weight/(weight-1))

. xtreg n w k [aw=weight], fe

Replication of a static (unweighted) fixed-effects estimator

. xtdpdgmm n w k, iv(w k) m(md) nores

. xtreg n w k, fe

Saved results

xtdpdgmm saves the following in e():

Scalars

e(N) number of observations

e(df_r) residual degrees of freedom; not always saved

e(N_g) number of groups

e(N_clust) number of clusters

e(g_min) smallest group size

e(g_avg) average group size

e(g_max) largest group size

e(f) value of the objective function

e(chi2_J) Hansen's J-statistic

e(chi2_J_u) Hansen's J-statistic with updated weighting matrix; not always saved

e(rank) rank of e(V)

e(zrank) number of linear moment functions

e(zrank_nl) number of nonlinear moment functions

e(df_a) absorbed degrees of freedom; not always saved

e(sigma2e) estimate of sigma_e^2; not always saved

e(steps) number of steps

e(ic) number of iterations in final step

e(converged) = 1 if convergence achieved, 0 otherwise

Macros

e(cmd) xtdpdgmm

e(cmdline) command as typed

e(ivar) variable denoting groups

e(tvar) variable denoting time

e(estat_cmd) xtdpdgmm_estat

e(predict) xtdpdgmm_p

e(marginsok) predictions allowed by margins

e(teffects) time effects created with option teffects

e(wmatrix) wmat_spec specified with option wmatrix()

e(estimator) onestep, twostep, or igmm

e(clustvar) name of cluster variable

e(vce) conventional or robust

e(vcetype) title used to label Std. Err.

e(vcecor) type of variance correction; not always saved

e(properties) b V

e(depvar) name of dependent variable

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix of the estimators

e(V_modelbased) model-based variance; not always saved

e(W) weighting matrix

e(ilog) iteration log (up to 20 iterations)

Functions

e(sample) marks estimation sample

Version history and updates

xtdpdgmm is a community-contributed program. To determine the currently installed version, type

. which xtdpdgmm, all

To update the xtdpdgmm package to the latest version, type

. //www.kripfganz.de/stata/") replace"'

If the connection to the previous website fails, alternatively type

. ssc install xtdpdgmm, replace

The SSC version is less frequently updated and may not be the latest available version. The current version of the xtdpdgmm package requires Stata version 13 or higher.
For backward compatibility and replicability of results obtained with earlier versions, the following older versions can be installed as well. Note that these versions may use different syntax and may still contain bugs
that were fixed in subsequent versions. If you intend to install different versions alongside each other, you can set different installation paths with net set ado dirname; see [R] net.

To install the xtdpdgmm version 1.1.3 as of 24sep2018, requiring Stata version 12.1 or higher, type

. //www.kripfganz.de/stata/xtdpdgmm_v1/")"'

Author

Sebastian Kripfganz, University of Exeter, http://www.kripfganz.de

Acknowledgement

The development of this program benefited from discussions with the Stata community, with special thanks to Mark E. Schaffer for numerous helpful comments.

References

Ahn, S. C., and P. Schmidt. 1995.
Efficient estimation of models for dynamic panel data.
Journal of Econometrics 68: 5-27.

Anderson, T. W., and C. Hsiao. 1981.
Estimation of dynamic models with error components.
Journal of the American Statistical Association 76: 598-606.

Arellano, M., and S. R. Bond. 1991.
Some tests of specification for panel data: Monte Carlo evidence and an application to employment equations.
Review of Economic Studies 58: 277-297.

Arellano, M., and O. Bover. 1995.
Another look at the instrumental variable estimation of error-components models.
Journal of Econometrics 68: 29-51.

Blundell, R., and S. R. Bond. 1998.
Initial conditions and moment restrictions in dynamic panel data models.
Journal of Econometrics 87: 115-143.

Chudik, A., and M. H. Pesaran. 2022.
An augmented Anderson-Hsiao estimator for dynamic short-T panels.
Econometric Reviews 41: 416-447.

Hansen, B. E., and S. Lee. 2021.
Inference for iterated GMM under misspecification.
Econometrica 89: 1419-1447.

Hansen, L. P., J. Heaton, and A. Yaron. 1996.
Finite-sample properties of some alternative GMM estimators.
Journal of Business & Economic Statistics 14: 262-280.

Hayakawa, K., M. Qi, and J. Breitung. 2019.
Double filter instrumental variable estimation of panel data models with weakly exogenous variables.
Econometric Reviews 38: 1055-1088.

Hwang, J., B. Kang, and S. Lee. 2022.
A doubly corrected robust variance estimator for linear GMM.
Journal of Econometrics 229: 276-298.

Kiviet, J. F. 2020.
Microeconometric dynamic panel data methods: Model specification and selection issues.
Econometrics and Statistics 13: 16-45.

Kripfganz, S., and C. Schwarz. 2019.
Estimation of linear dynamic panel data models with time-invariant regressors.
Journal of Applied Econometrics 34: 526-546.

Lee, S. 2014.
Asymptotic refinements of a misspecification-robust bootstrap for generalized method of moments estimators.
Journal of Applied Econometrics 178: 398-413.

Roodman, D. 2009.
A note on the theme of too many instruments.
Oxford Bulletin of Economics and Statistics 71: 135-158.

Windmeijer, F. 2005.
A finite sample correction for the variance of linear efficient two-step GMM estimators.
Journal of Econometrics 126: 25-51.