*! version 1.0 29jan2019
help xtlhazard

Title

xtlhazard -- Adjusted First-Differences Estimation of the Linear Discrete-Time Hazard Model

Syntax

xtlhazard depvar indepvars [if] [in] [weight] [, options]

Variables

depvar binary variable indicating absorbing state

indepvars explanatory variables

options

Model
difference(#) set order of differencing; difference(1) that is first-differences is the default

noabsorbing forces estimation if depvar is inconsitent with model

tolerance(#) set tolerance for luinv(); tolerance(3) is the default

edittozero(#) use Mata function edittozero() to set matrix entries close to zero to zero; edittozero(0) that is no editing is the default

SE/Robust
vce(vcetype) vcetype may be robust, cluster clustvar, model [, force], or ols; vce(robust) is the default

Reporting
noeomitted do not consider omitted collinear variables in e(b) and e(V)

level(#) set confidence level; default as set by set level

noci suppress confidence intervals

nopvalues suppress p-values and their test statistics

noomitted do not display omitted collinear variables

vsquish suppress blank space separating factor variables or time-series variables

noemptycells do not display empty interaction cells of factor variables

baselevels display base levels of factor variables

allbaselevels display all base levels for factor variables and interactions

nofvlabel display factor-variable level values rather than value labels

fvwrap(#) allow # lines when wrapping long value labels

fvwrapon(style) apply style for wrapping long value labels; style may be word or width

cformat(%fmt) format for coefficients, standard errors, and confidence limits

pformat(%fmt) format for p-values

sformat(%fmt) format for test statistics

nolstretch do not automatically widen coefficient table for long variable names

Generate
ieffect(newvar) generate variable newvar containing estimated individual fixed-effects

The data needs to be xtset before using xtlhazard, timevar needs to be specified; see [XT] xtset.

indepvars may contain factor variables and and time-series operators; see fvvarlist and tsvarlist. factor variables and and time-series operators are not allowed for depvar.

bootstrap is allowed, by and svy are not allowed; see [U] prefix.

pweights, fweights, aweights and iweights are allowed, with pweight being the default.

Many standard postestimation commands, such as predict, margins, test, testnl, lincom, and nlcom are available; see [R] regress postestimation.
predict, res is not allowed; use predict, score for obtaining residuals.

Description

xtlhazard implements the adjusted first-differences estimator for the linear discrete-time hazard model proposed by Tauchmann (2019). This procedure addresses the issue that,
conventional linear fixed-effects panel estimators (within-transformation, first-differences; see [XT] xtreg),
fail to eliminate unobserved time-invariant heterogeneity and are biased and inconsistent if depvar is a binary dummy indicating an absorbing state.
This even applies if the unobserved time-invariant heterogeneity is uncorrelated with the regressors in the population.
Besides conventional survivor bias - from which also pooled OLS suffers even if the unobserved heterogeneity is uncorrelated with the regressors - these estimators suffer from a second source of bias.
This second bias, which is severe in many settings, originates from the transformation of the data itself und is present even in the absence of any unobserved heterogeneity.
The adjusted first-differences estimator eliminates this second source of bias and confines the asymptotic bias to survivor bias under the assumption
that the unobserved heterogeneity is uncorrelated with changes in the regressors in the population, while allowing for correlations with their levels.
Technically, xtlhazard rescales the coefficients from unadjusted first-differences estimation (with constant terms) by the matrix inv(I+inv(d.X'd.X)*d.X'l.X), which ('s transpose) is stored in e(Adjust).
By specifying the option difference(#), one makes the estimation procedure use higher-order rather than first-differences.
This allows confining the asymptotic bias to survivor bias under the alternative assumption of unobserved heterogeneity being uncorrelated with higher-order differences of the explanatory variables.

Variables

Dependent Variable

depvar needs to be a binary (either numeric or string) indicator.
Its (alphanumerically) smaller value indicates that a unit is still at risk, while the (alphanumerically) larger value indicates that the absorbing state is reached.
A 0/1 indicator is hence the most obvious choice for coding depvar.
Sequences of depvar, observed at the individual level, such as 0,..,0,1 and 0,..,0,0 are consistent with the data generating process that is assumed by xtlhazard.
This also applies to sequences of the form 0,..,0,1,..,1. Yet, for a sequence of this type, observations for periods later than the first occurrence of 1 do not enter the estimation procedure.
Sequences like 0,1,0,... or 1,0,1,... are inconsistent with the assumed DGP. Here depvar = 1 is not an absorbing state and xtlhazard is an inappropriate estimation routine.
xtreg ...,fe or regress D.(...) are supposedly better suited.
For this reason xtlhazard breaks and returns an error message if depvar is recognized to indicate a (potentially) repeated event, unless the option noabsorbing is specified.

Options

Model

difference(#) specifies the order of the differences-transformation that is applied to the variables.
The default is difference(1) that is taking first differences. difference(2) makes xtlhazard take differences of differences, difference(3) induces taking differences of differences of differences, et cetera.
While considering higher-order differences allows for estimation under alternative, presumably weaker, assumptions, it makes the identification rest on very little variation. This may result in imprecisely estimated and potentially misleading coefficients.

noabsorbing forces xtlhazard to produce estimation results even if the observed distribution of depvar is inconsistent with using a hazard model; see variables.
In this case, xtlhazard is most likely severly biased and represents an inappropriate estimation procedure. Users are hence strongly discouraged from specifying noabsorbing in serious empirical applications.
If noabsorbing is specified and the data are inconsistent with data generating process assumed by xtlhazard, a warning is issued and the value 1 is saved in e(irregular).
If noabsorbing is specified and depvar is consistent with the assumed data generating process, e(irregular) saves the value 0.

tolerance(#) temporarily sets the tolerance level for the Mata functions luinv() and rank().
The tolerance level matters, since the adjusted first-differences estimator does not exist if (I+inv(d.X'd.X)*d.X'l.X) is singular.
Due to numeric imprecision, there will always by a (small) numerical deviation from singularity.
tolerance(#) determines how big this deviation must be in order to regard (I+inv(d.X'd.X)*d.X'l.X) nonsingular; see [M-1] tolerance.
The default value used by xtlhazard is 3, which is less generous in assuming nonsingularity than Mata's standard default level of 1.
If according to the specified tolerance level (I+inv(d.X'd.X)*d.X'l.X) is singular, xtlhazard breaks and issues an error message.
If this happens, rerunning xtlhazard with tolerance(0) may help in figuring out which variable(s) cause the problem.
With tolerance(0), xtlhazard will produce some results.
Extremely large reported coefficients and standard errors may indicate which variable(s) render(s) (I+inv(d.X'd.X)*d.X'l.X) (almost) singular.

edittozero(#) invokes the Mata function edittozero() to set entries in the adjustment matrix and in its inverse, which are close to zero, to zero; see [M-5] edittozero().
In certain settings, some entries are known to be zero but deviate from this value in empirical applications due to numerical imprecision. One may exploit the margin for improving precision by specifying edittozero().
Yet, this gain in precision is likely to be negligible.

SE/Robust

vce(vcetype) specifies the method used for estimating standard errors. robust, cluster clustvar, model [, force], and ols are available as vcetype.
The default ist robust. With vcetype robust, xtlhazard calculates a Huber-White covariance matrix for unadjusted first-differences estimation and adjusts it appropriately using inv(I+inv(d.X'd.X)*d.X'l.X).
vcetype cluster clustvar proceeds in the same way, yet is calculates cluster robust standard errors for the unadjusted coefficients.
Theory does not suggest clustering at the level of panelvar, since according to the assumed DGP the errors are serially uncorrelated.
vcetype model estimates standard errors taking the type of heteroscedasticity into account that is inherent to the assumed DGP.
This will rarely succeed in practice, because of some estimated error variances taking negative values.
One may force xtlhazard to calculate model standard errors by specifying vce(model, force). This makes xtlhazard set negative variance estimates to the value of zero.
This is likely to result in severely underestimated standard errors. Using vcetype model is hence not recommended.
This also applies to vcetype ols, which ignores the heteroscedasticity inherent to any linear probability model.
xtlhazard does not include an internal bootstrapping routine.
Yet the prefix command bootstrap still allows obtaining bootstrap standard errors. When using bootstrap clustering at the level of panelvar is essential.
I.e. the bootstrap options cluster() and idcluster() are required.

Reporting

noeomitted makes xtlhazard ignore omitted collinear variables and empty cells in e(b), e(V), e(Adjust), and e(invAdjust).
By default, as it is the standard for stata's estimation routines, the matrices saved in e() contain columns of zeroes if the model includes collinear variables.
With factor variables in indepvars, this will regularly be the case. While this is no obstacle to using stata's postestimation commands, matrix algebra using these matrices may be hampered.
For instance, one can retrieve the coefficients and the covariance matrix of unadjusted first-differences estimation as e(b)*inv(e(Adjust)) and inv(e(Adjust))'*e(V)*inv(e(Adjust)).
This will, however, not work if e(Adjust) includes columns and rows of zeroes, since its (regular) inverse then does not exist.

See [R] estimation options for a more detailed description of the display_options listed above.
They are essentially the same as for eretun display, to which they are passed through. Maximum likelihood related reporting options are not available since xtlhazard is not an ML estimator.

Generate

ieffects(newvar) generates the new variable newvar that contains estimates of individual fixed effects. Individual fixed effects are estimated as group means of residuals.

Example

Load Stata example data set cancer.dta.

. sysuse cancer, clear

Bring data in panel format required for using xtlhazard; see [ST] discrete, [ST] stset, and [ST] stsplit.

. gen id = _n

. stset studytime, failure(died) id(id)

. stsplit nt, every(1)

xtset data.

. xtset id _t

Use xtlhazard to estimate quadratic baseline hazards as deviation from placebo group.

. xtlhazard _d i(2 3).drug#c._t i.drug#c._t#c._t

Same as above with bootstrapped standard errors.

. gen _id = id

. bootstrap, cluster(_id) idcluster(id): xtlhazard _d i(2 3).drug#c._t i.drug#c._t#c._t

Saved results

xtlhazard saves the following in e():

Scalars

e(N) number of observations (excluding waves eliminated by taking differences)

e(N_g) number of groups (cross-sectional units in panel)

e(difference) order of differencing

e(chi2) model chi-squared

e(p) model significance, p-value

e(r2) pseudo R-squared for differences (variance of differenced predictions over variance of depvar)

e(r2_a) adjusted pseudo R-squared (differences)

e(r2_lev) pseudo R-squared for levels (variance of predictions over variance of depvar)

e(r2_a_lev) adjusted pseudo R-squared (levels)

e(df_m) model degrees of freedom

e(rank) rank of inverse adjustment matrix

e(tolerance) tolerance level for luinv() and rank()

e(level) confidence level

e(irregular) indicator saved with option noabsorbing: 0 if depvar is regular, 1 if depvar is irregular, -1 if depvar is regular but obs after absorbing state is reached enter estimation sample

e(wgtsum) sum of weights (only saved if weights are specified)

e(N_clust) number of clusters (only saved with vcetype cluster)

Macros

e(tvar) name of timevar

e(ivar) name of panelvar

e(marginsok) predictions allowed by margins

e(predict) program used to implement predict

e(chi2type) Wald

e(depvar) name of depvar

e(vcest) vcetype specified in vce()

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

e(wtype) weight type (only saved if weights are specified)

e(wexp) = weight expression (only saved if weights are specified)

e(title) Adjusted first-differences linear discrete-time hazard estimation

e(cmdline) command as typed

e(cmd) xtlhazard

e(predict) program used to implement predict

e(properties) b V

Matrices

e(b) vector of estimated coefficients

e(V) estimated coefficient variance-covariance matrix

e(Adjust) adjustment matrix, i.e. inv(I+inv(d.X'd.X)*d.X'l.X)' for first-differences

e(invAdjust) inverse adjustment matrix, i.e. (I+inv(d.X'd.X)*d.X'l.X)' for first-differences

Functions

e(sample) marks estimation sample (first period not included)

References

Tauchmann, H. (2019). Linear discrete time hazard estimation using Stata, presentation at the 2019 German Stata Users Group Meeting.

Tauchmann, H. (2019). Fixed Effects Estimation of the Discrete-Time Linear-Probability Hazard Model: an Adjusted First-Differences Estimator,
FAU Discussion Papers in Economics #9/2019.

Also see

Manual: [R] regress, [ST] discrete, [ST] stcox, [ST] streg, [ST] stset, [ST] stsplit, [XT] xtreg, [XT] xtset

Help: [R] regress, [ST] stcox, [ST] streg, [ST] stset, [ST] stsplit, [XT] xtreg, [XT] xtset

Online: dthaz, hshaz, pgmhaz8

Author

Harald Tauchmann

Friedrich-Alexander-Universität Erlangen-Nürnberg (FAU)

Nürnberg,
Germany

E-mail: harald.tauchmann@fau.de

Disclaimer

This software is provided "as is" without warranty of any kind, either expressed or implied. The entire risk as to the quality and
performance of the program is with you. Should the program prove defective, you assume the cost of all necessary servicing, repair or
correction. In no event will the copyright holders or their employers, or any other party who may modify and/or redistribute this software,
be liable to you for damages, including any general, special, incidental or consequential damages arising out of the use or inability to
use the program.

Acknowledgements

I gratefully acknowledge comments and suggestions by Helene Könnecke, Sabrina Schubert, Irina Simankova and the participants of the 2019 German Stata Users Group Meeting.