help twopm (SJ15-1: st0368)

Title

twopm -- Two-part models

Syntax

Same regressors in first and second parts

twopm
depvar
[indepvars]
[if] [in]
[weight], firstpart(f_options) secondpart(s_options)
[twopm_options]

Different regressors in first and second parts (caution: see Remarks below)

twopm
equation1 equation2
[if] [in]
[weight], firstpart(f_options) secondpart(s_options)
[twopm_options]

where equation1 and equation2 are specified as

(depvar [=] [indepvars])

twopm_options

* firstpart(f_options) specify the model
for the first part

* secondpart(s_options) specify the model
for the second part

vce(vcetype) vcetype may be conventional,
robust, cluster clustvar, bootstrap, or
jackknife

robust synonym for vce(robust)

cluster(clustvar) synonym for vce(cluster clustvar)

suest combine the estimation results of first and second parts to derive
a simultaneous (co)variance matrix of the sandwich or robust type

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

nocnsreport do not display constraints

display_options control spacing
and display of omitted variables and base and empty cells

* firstpart(f_options) and secondpart(s_options) are required.

indepvars may contain factor variables; see fvvarlist.

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

bootstrap, by, jackknife, nestreg,
rolling, statsby, stepwise, and svy
are allowed; see prefix.

Weights are not allowed with the bootstrap prefix.

aweights are not allowed with the jackknife prefix.

vce() and weights are not allowed with the svy prefix.

iweights, aweights, and pweights
are allowed; see weight.

See twopm postestimation for features available after estimation.

f_options

logit [, logit_options] specify
the model for the binary, first-part outcome as a logistic regression

probit [, probit_options] specify
the model for the binary, first-part outcome as a probit regression

s_options

glm [, glm_options] specify the
model for the second-part outcome as a generalized linear model

regress [, regress_options]
specify the model for the continuous, second-part outcome as a linear regression estimated using ordinary least squares

Description

twopm fits a two-part regression model of depvar on indepvars.
The first part models the probability that depvar>0 using a binary choice
model (logit or probit). The second part models the distribution
of depvar | depvar>0 using linear (regress) and generalized
linear models (glm).

Options

firstpart(f_options) specifies the first part of the model for a binary
outcome. It should be logit or probit. Each can be specified
with its options except vce(), which should be specified as a
twopm option. firstpart() is required.

secondpart(s_options) specifies the second part of the model for a
positive outcome. It should be regress or glm. Each can be
specified with its options except vce(), which should be specified as a
twopm option. secondpart() is required.

vce(vcetype) specifies the type of standard error reported, including
types that are derived from asymptotic theory, that are robust to some kinds
of misspecification, that allow for intragroup correlation, and that use
bootstrap or jackknife methods; see [R] vce_option.

vce(conventional), the default, uses the conventionally derived variance
estimators for the first and second parts of the model.

Note that options related to the variance estimators for both parts must be
specified using vce(vcetype) in the twopm syntax.
Specifying vce(robust) is equivalent to specifying vce(cluster
clustvar).

robust is the synonym for vce(robust).

cluster(clustvar) is the synonym for vce(cluster
clustvar).

suest combines the estimation results of the first and second parts of
the model to derive a simultaneous (co)variance matrix of the sandwich or
robust type. Typical applications of suest are tests for cross-part
hypotheses using test or testnl.

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

nocnsreport; see
[R] estimation options

display_options:
noomitted,
vsquish,
noemptycells,
baselevels,
allbaselevels;
see [R] estimation options.

Options for the first part: logit

noconstant, offset(varname),
constraints(constraints), collinear; see
[R] estimation options.

asis forces retention of perfect predictor variables and their
associated perfectly predicted observations and may produce instabilities in
maximization; see [R] probit.

maximize_options:
difficult, technique(algorithm_spec),
iterate(#), [no]log, trace,
gradient, showstep,
hessian,
showtolerance,
tolerance(#),
ltolerance(#),
nrtolerance(#),
nonrtolerance,
from(init_specs); see [R] maximize. These options are seldom
used.

Options for the first part: probit

noconstant, offset(varname),
constraints(constraints), collinear; see
[R] estimation options.

asis specifies that all specified variables and observations be retained
in the maximization process. This option is typically not specified and may
introduce numerical instability. Normally, probit drops variables that
perfectly predict success or failure in the dependent variable along with
their associated observations. In those cases, the effective coefficient on
the dropped variables is infinity (negative infinity) for variables that
completely determine a success (failure). Dropping the variable and perfectly
predicted observations does not affect the likelihood or estimates of the
remaining coefficients and increases the numerical stability of the
optimization process. Specifying this option forces retention of perfect
predictor variables and their associated observations.

maximize_options:
difficult, technique(algorithm_spec),
iterate(#), [no]log, trace,
gradient, showstep,
hessian,
showtolerance,
tolerance(#),
ltolerance(#),
nrtolerance(#),
nonrtolerance,
from(init_specs); see [R] maximize. These options are seldom
used.

Options for the second part: glm

family(twopm##familyname:familyname) specifies the
distribution of depvar. The default is family(gaussian).

familyname Description

gaussian Gaussian (normal)

igaussian inverse Gaussian

binomial[varnameN|#N] Bernoulli/binomial

poisson Poisson

nbinomial[#k|ml] negative binomial

gamma gamma

link(twopm##linkname:linkname) specifies the link function; the
default is the canonical link for the family() specified.

linkname Description

identity identity

log log

logit logit

probit probit

cloglog cloglog

power # power

opower # odds power

nbinomial negative binomial

loglog log-log

logc log-complement

noconstant, exposure(varname), offset(varname),
constraints(constraints), collinear; see
[R] estimation options.
constraints(constraints) and collinear are not allowed with
irls.

mu(varname) specifies varname as the initial estimate for the mean
of depvar. This option can be useful with models that experience
convergence difficulties, such as family(binomial) models with power or
odds-power links. init(varname) is a synonym.

disp(#) multiplies the variance of depvar by # and divides the
deviance by #. The resulting distributions are members of the
quasilikelihood family.

scale(x2|dev|#) overrides the default scale parameter.
This option is allowed only with Hessian (information matrix) variance
estimates.

The default is scale(1) for the discrete distributions (binomial,
Poisson, and negative binomial), and scale(x2) is assumed for the
continuous distributions (Gaussian, gamma, and inverse Gaussian).

scale(x2) specifies that the scale parameter be set to Pearson's
chi-squared (or generalized chi-squared) statistic divided by the residual
degrees of freedom, which is recommended by McCullagh and Nelder (1989) as a
good general choice for continuous distributions.

scale(dev) sets the scale parameter to the deviance divided by the
residual degrees of freedom. This option provides an alternative to
scale(x2) for continuous distributions and overdispersed or
underdispersed discrete distributions.

scale(#) sets the scale parameter to #. For example, using
scale(1) in family(gamma) models results in exponential-errors
regression. Additional use of link(log) rather than the default
link(power -1) for family(gamma) reproduces Stata's streg,
dist(exp) nohr command (see [ST] streg) if all the observations
are uncensored.

ml requests that optimization be performed using Stata's ml
commands and is the default.

irls requests iterated, reweighted least-squares optimization of the
deviance instead of Newton-Raphson optimization of the log likelihood. If the
irls option is not specified, the optimization is performed using
Stata's ml commands, in which case all options of ml maximize are
also available.

maximize_options:
difficult,
technique(algorithm_spec),
iterate(#),
[no]log,
trace,
gradient,
showstep,
hessian,
showtolerance,
tolerance(#),
ltolerance(#),
nrtolerance(#),
nonrtolerance,
from(init_specs); see [R] maximize.
These options are seldom used.

Setting the optimization type to technique(bhhh) resets the default
vcetype to vce(opg).

fisher(#) specifies the number of Newton-Raphson steps that should use
the Fisher-scoring Hessian or expected information matrix before switching to
the observed information matrix. This option is useful only for
Newton-Raphson optimization (and not when using irls).

search specifies that the command search for good starting values. This
option is useful only for Newton-Raphson optimization (and not when using
irls).

Options for the second part: regress

log specifies that the linear regression be estimated on the logarithm
of the second-part, continuous outcome.

noconstant; see
[R] estimation options.

display_options:
noomitted,
vsquish,
noemptycells,
baselevels,
allbaselevels;
see [R] estimation options.

Remarks

twopm is designed to estimate models in which the positive outcome is
continuous. It does not deal with discrete or count outcomes. It also does
not allow boxcox or other models that may be appropriate for
continuous outcomes.

The statistical logic of the two-part model is that there is a vector of
variables, indepvars, that explain depvar. Therefore, variables
that enter the specification for the first part should, in general, also enter
the specification for the second part. In some situations, there may be
legitimate theoretical (conceptual) or statistical reasons that lead to
different lists of independent variables. For completeness, twopm has a
syntax that allows for different covariates in each equation, but we do not
recommend the use of this. There is typically no justification for different
regressors in each of the two parts. Moreover, the two equations' syntax
cannot be used when the svy prefix is specified.

Examples

Setup

. webuse womenwk

. replace wage = 0 if wage==.

Two-part model with logit and glm with Gaussian family and identity link

. twopm wage educ age married children, firstpart(logit) secondpart(glm)

Two-part model with probit and glm with gamma family and log link

. twopm wage educ age married children, firstpart(probit) secondpart(glm, family(gamma) link(log))

Two-part model with probit and linear regression

. twopm wage educ age married children, firstpart(probit) secondpart(regress)

Two-part model with probit and linear regression of log(depvar>0)

. twopm wage educ age married children, firstpart(probit) secondpart(regress, log)

Two-part model with different covariates in first and second parts

. twopm (wage = educ age children) (wage = educ age married), firstpart(probit) secondpart(glm, family(gamma) link(log))

Stored results

If probit is specified as the first part, twopm stores the
following in e():

Scalars

e(N_probit) number of observations

e(N_cds_probit) number of completely determined successes

e(N_cdf_probit) number of completely determined failures

e(k_probit) number of parameters

e(k_eq_probit) number of equations in e(b)

e(k_eq_model_probit) number of equations in model (Wald test)

e(k_dv_probit) number of dependent variables

e(k_autoCns_probit) number of base, empty, and omitted constraints

e(df_m_probit) model degrees of freedom

e(r2_p_probit) pseudo-R-squared

e(ll_probit) log likelihood

e(ll_0_probit) log likelihood, contant-only model

e(N_clust_probit) number of clusters

e(chi2_probit) chi-squared

e(p_probit) significance

e(rank_probit) rank of e(V)

e(ic_probit) number of iterations

e(rc_probit) return code

e(converged_probit) 1 if converged, 0 otherwise

Macros

e(offset_probit) offset

e(chi2type_probit) Wald or LR; type of model chi-squared test

e(opt_probit) type of optimization

e(which_probit) max or min; whether optimizer is to perform
maximization or minimization

e(ml_method_probit) type of ml method

e(user_probit) name of likelihood-evaluator program

e(technique_probit) maximization technique

e(singularHmethod_probit) m-marquardt or hybrid; method
used when Hessian is singular

e(crittype_probit) optimization criterion

e(asbalanced_probit) factor variables fvset as asbalanced

e(asobserved_probit) factor variables fvset as asobserved

If logit is specified as the first part, twopm stores the
following in e():

Scalars

e(N_logit) number of observations

e(N_cds_logit) number of completely determined successes

e(N_cdf_logit) number of completely determined failures

e(k_logit) number of parameters

e(k_eq_logit) number of equations in e(b)

e(k_eq_model_logit) number of equations in model (Wald test)

e(k_dv_logit) number of dependent variables

e(k_autoCns_logit) number of base, empty, and omitted constraints

e(df_m_logit) model degrees of freedom

e(r2_p_logit) pseudo-R-squared

e(ll_logit) log likelihood

e(ll_0_logit) log likelihood, contant-only model

e(N_clust_logit) number of clusters

e(chi2_logit) chi-squared

e(p_logit) significance

e(rank_logit) rank of e(V)

e(ic_logit) number of iterations

e(rc_logit) return code

e(converged_logit) 1 if converged, 0 otherwise

Macros

e(offset_logit) offset

e(chi2type_logit) Wald or LR; type of model chi-squared test

e(opt_logit) type of optimization

e(which_logit) max or min; whether optimizer is to perform
maximization or minimization

e(ml_method_logit) type of ml method

e(user_logit) name of likelihood-evaluator program

e(technique_logit) maximization technique

e(singularHmethod_logit) m-marquardt or hybrid; method
used when Hessian is singular

e(crittype_logit) optimization criterion

e(asbalanced_logit) factor variables fvset as asbalanced

e(asobserved_logit) factor variables fvset as asobserved

If glm is specified as the second part, twopm stores the following
in e():

Scalars

e(N_glm) number of observations

e(k_glm) number of parameters

e(k_eq_glm) number of equations in e(b)

e(k_eq_model_glm) number of equations in model (Wald test)

e(k_dv_glm) number of dependent variables

e(k_autoCns_glm) number of base, empty, and omitted constraints

e(df_m_glm) model degrees of freedom

e(df_glm) residual degrees of freedom

e(phi_glm) scale parameter

e(aic_glm) model AIC

e(bic_glm) model BIC

e(ll_glm) log likelihood, if NR

e(N_clust_glm) number of clusters

e(chi2_glm) chi-squared

e(p_glm) significance

e(deviance_glm) deviance

e(deviance_s_glm) scaled deviance

e(deviance_p_glm) Pearson deviance

e(deviance_ps_glm) scaled Pearson deviance

e(dispers_glm) dispersion

e(dispers_s_glm) scaled dispersion

e(dispers_p_glm) Pearson dispersion

e(dispers_ps_glm) scaled Pearson dispersion

e(nbml_glm) 1 if negative binomial parameter estimated via ML,
0 otherwise

e(vf_glm) factor set by vfactor(), 1 if not set

e(power_glm) power set by power(), opower()

e(rank_glm) rank of e(V)

e(ic_glm) number of iterations

e(rc_glm) return code

e(converged_glm) 1 if converged, 0 otherwise

Macros

e(varfunc_glm) name of variance function used

e(varfunct_glm) Gaussian, Inverse Gaussian,
Binomial, Poisson, Neg. Binomial,
Bernoulli, Power, or Gamma

e(varfuncf_glm) variance function

e(link_glm) name of link function used

e(linkt_glm) link title

e(linkf_glm) link form

e(m_glm) number of binomial trials

e(offset_glm) offset

e(chi2type_glm) Wald or LR; type of model chi-squared
test

e(cons_glm) set if noconstant specified

e(hac_kernel_glm) HAC kernel

e(hac_lag_glm) HAC lag

e(opt_glm) ml or irls

e(opt1_glm) optimization title, line 1

e(opt2_glm) optimization title, line 2

e(which_glm) max or min; whether optimizer is to perform
maximization or minimization

e(ml_method_glm) type of ml method

e(user_glm) name of likelihood-evaluator program

e(technique_glm) maximization technique

e(singularHmethod_glm) m-marquardt or hybrid; method used
when Hessian is singular

e(crittype_glm) optimization criterion

e(asbalanced_glm) factor variables fvset as asbalanced

e(asobserved_glm) factor variables fvset as asobserved

twopm stores the following in e():

Macros

e(cmd) twopm

e(cmdline) command as typed

e(depvar) name of dependent variable

e(wtype) weight type

e(wexp) weight expression

e(title) title in estimation output

e(clustvar) name of cluster variable

e(vce) vcetype specified in vce()

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

e(properties) b V

e(estat_cmd) program used to implement estat

e(predict) program used to implement predict

Matrices

e(b) coefficient vector

e(gradient) gradient vector

e(V) variance-covariance matrix of the estimators

e(V_modelbased) model-based variance

Functions

e(sample) marks estimation sample (first part)

Reference

McCullagh, P., and J. A. Nelder. 1989. Generalized Linear Models 2nd ed.
London: Chapman & Hall/CRC.

Authors

Federico Belotti

Centre for Economic and International Studies

University of Rome Tor Vergata

Rome, Italy

federico.belotti@uniroma2.it

Partha Deb

Hunter College and Graduate Center, CUNY

New York, NY

and National Bureau of Economic Research

Cambridge, MA

partha.deb@hunter.cuny.edu

Willard G. Manning

University of Chicago

Chicago, IL

w-manning@uchicago.edu

Edward C. Norton

University of Michigan

Ann Arbor, MI

and National Bureau of Economic Research

Cambridge, MA

ecnorton@umich.edu

Also see

Article: Stata Journal, volume 15, number 1: st0368

Help: twopm postestimation (if installed)