help mtefe (SJ18-1: st00!!)

Title

mtefe -- Marginal treatment effects with factor variables

Syntax

mtefe depvar [indepvars]
(_t = _iv)
[if] [in] [weight] [, options]

Model
polynomial(#) specify the degree of the polynomial for the polynomial models; default is the joint normal

splines(numlist) allow for splines at knots specified by numlist in parametric models

semiparametric specify the semiparametric model

restricted(varlist) control variables restricted to be the same in treated and untreated state

link(string) link function can be probit, logit, or lpm; default is link(probit)

Estimation
separate fit the model using the separate approach rather than local instrumental variables (LIVs)

mlikelihood fit the model using maximum likelihood rather than local IVs; only for joint normal model

trimsupport(#) trim off # share of the treated and untreated sample from the thinnest tails of support

fullsupport estimate marginal treatment effect (MTE) over the full unit interval even when using semiparametric models

prte(varname) estimate policy-relevant treatment effects based on the propensity scores in varname

Inference
bootreps(#) use bootstrap with # repetitions

norepeat1 do not reestimate the propensity scores, mean of X, and parameter weights for each replication

vce(vcetype) standard error specification -- robust or cluster clustvar

level(#) specify confidence level

Semiparametric
degree(#) specify degree of local polynomial smooth in semiparametric models

ybwidth(#) specify bandwidth of local polynomial smooth for the outcome in semiparametric models

xbwidth(#) specify bandwidth of local polynomial smooth for X variables in the semiparametric model

gridpoints(#) evaluate the local polynomial smooths of X on p at # points rather than precise propensity scores

kernel(string) kernel for use in the semiparametric models

Other
first report the first-step estimates

second report the underlying second-stage (rarely used)

noplot do not graph common support and MTE plots

savefirst(string) save the first-stage estimates to disk as string.ster

savepropensity(newvar) save the estimated propensity scores in a new variable newvar

savekp save the variables of the K(p) [and K0(p)] functions in the dataset for postestimation

saveweights(string) save the weights for the mean of X in in the subpopulations for the treatment effect parameters in variables with prefix string

norescale Does not rescale the weights of the treatment effect parameters to sum to 1 in cases with limited support.

fweights and pweights are allowed unless bootstrapping; see weight.

Description

mtefe calculates MTEs derived using a variety of parametric and
semiparametric models and three estimation methods.

Options

Model

polynomial(#) specifies the k(p) or k_j(p) functions to be polynomials
of degree #. Required for the parametric and semiparametric polynomial
models. Note that mtefe specifies the degree of the MTE directly,
rather than the degree of K(p) like margte, so a polynomial of L+1 in
margte will be equivalent to L in mtefe.

splines(numlist) allows for splines with knots at k1, k2, ... kQ as
specified in numlist. Specifies splines for degree 2 and above in k(p) or k_j(p).
Required for models with splines. Degree of polynomial must be greater than 1.

semiparametric specifies that the models be fit using semiparametric
methods -- semiparametric polynomial, semiparametric polynomial with splines,
or semiparametric using double residual regression.

restricted(varlist) specifies control variables that are included in the
first stage and second stage, but these are restricted to have the same effect
in the treated and untreated state.

link(string) specifies the first-stage model. string may be
probit, logit, or lpm. The default is
link(probit).

Estimation

separate specifies that the model be fit using the separate approach or
principled stratification. Otherwise, estimation is done using local IVs unless
is specified.

mlikelihood specifies that the model be fit using maximum likelihood.
This is appropriate only for the standard normal model. The evaluator is an
adapted version of the maximum likelihood evaluator from Lokshin and Sajaia
(2004), see movestay.

trimsupport(#) trims the sample after estimating the propensity scores
to deal with issues of common support. After estimating the propensity scores,
this option estimates the density of p separately in each sample. It then
removes individuals from the points of least support until a total share #
of each sample has been removed. Common support is calculated at the points of
the propensity score distribution where the two samples have overlapping
support, estimation proceeds excluding the individuals with estimated
scores outside the range of the relevant subsample and the first stage is re-estimated
on the trimmed sample. This procedure drops exactly # share of the total sample,
but the final estmation sample will include observations outside the common support in
the fat tail of each subsample of treated and control.

fullsupport specifies that the MTE is estimated over the full unit
interval even when using semiparametric models. By default, the MTE will only
be estimated at points of overlapping support in the treated and untreated
samples. Therefore, using fullsupport relies on extrapolation in the
local linear regressions, and may be unstable. This option has no effect
when using parametric models. Use with caution.

prte(varname) fits the specified MTE model and calculates the PRTE for a
hypothetical policy change that generated the propensity score distribution in
variable varname.

Inference

bootreps(#) uses the bootstrap for inference, performing #
bootstrap replications. Otherwise, analytic standard errors are calculated,
ignoring the estimation error from the first stage. See the remark on standard
errors below.

norepeat1 specifies that the first stage, treatment effect parameter weights
and means of X are not reestimated for each bootstrap repetition, thus ignoring
the estimation error from the first stage in the bootstrap. See the remark on
standard errors below.

vce(vcetype) specifies standard errors -- robust or cluster
clustvar. Works for both analytic standard errors and bootstrapped ones.

level(#) uses a confidence level of #% for confidence intervals and
MTE plots. The default is level(95).

Semiparametric

degree(#) specifies the degree of the local polynomial regressions used
in the semiparametric models. When using the semiparametric polynomial model,
this option is overruled by the degree specified in the polynomial()
option plus one, so this option is relevant only for the semiparametric model.
The degree of polynomial smooth is always 1 for the local polynomial
regressions of the covariates on p, so this affects only the degree in the
local polynomial regression of Y on p. The default is degree(2).

ybwidth(#) specifies the bandwidth of the local polynomial smooth of Y
on p in semiparametric models. The default is ybwidth(0.2).

xbwidth(#) specifies the bandwidth of the local polynomial smooth of the
covariates on p in semiparametric models. The default is lpoly's
rule-of-thumb.

gridpoints(#) is used with the fully semiparametric model only. Instead
of running the local polynomial regressions of covariates on p at each and
every estimated propensity score, this option allows for estimating it at
# separate points spread out between the minimum and maximum of the
propensity score distribution and then assigns every individual the predicted
value from the closest point in this set before calculating the residuals. In
large samples, this may provide large improvement in computation time.
Does not affect the local polynomial regressions of Y on p that are always
performed at the points of common support.

kernel(string) uses string as the kernel in all local polynomial
regressions. string may be epanechnikov, biweight,
cosine, gaussian, parzen, rectangle, or
triangle. The default is kernel(epanechnikov).

Other

first reports the first-stage estimates.

second reports the output from the second-stage estimating equation,
which might not be particularly easy to read because of temporary variables.
Use primarily for investigating the log-likelihood iterations when using
maximum likelihood.

noplot suppresses the drawing of common support and MTE plots.

norescale specifies that the treatment effect parameter weights are not rescaled
to sum to 1 in cases with limited support. When support is limited, regular non-marginal
treatment effect parameters (ATE, ATT, ATUT, LATE and PRTE) cannot be estimated.
Instead, mtefe by default rescales the weights to sum to 1 within the support, creating
a parameter that can be interpreted analogously to the original, but for people with unobserved
resistance within the support. If norescale is specified instead, the weights are not rescaled.

savefirst(string) saves the first-stage estimates to disk using the
filename string.ster. If suboption margins is specified,
mtefe instead saves the marginal effects for all variables.

savepropensity(newvar) saves the predicted propensity scores from the
first stage to a new variable called newvar.

savekp saves the variables used in K(p) and, if separate or
mlikelihood is specified, K0(p) in the dataset for postestimation use.
Relevant only for parametric models.

saveweights(string) saves the estimated weights for mean of X in the relevant
subopulations for the treatment effect parameters in variables with the prefix
string. Weights are calculated for the ATT, ATUT, LATE, MPRTE1 and, if
specified in the option prte(), PRTE.

Remarks

The model

The MTEs are derived from the generalized Roy model

Y = (1 - D)Y_0 + DY_1

Y_j = Xb_j + U_j for j=0,1

D = 1(Zg>V)	for Z=X,Z_

where Y_1 is the outcome in the treated state, Y_0 is the outcome in the
untreated state, D is a binary treatment indicator, and 1[A] is the indicator
function for event A. Zg is an index that can be interpreted as a latent
utility of treatment.

Transforming the treatment condition gives P(Z)>U_d, where P(Z) is the
propensity score, or the probability of treatment given Z, and U_d=F(V) is the
percentiles of V, the unobserved resistance to treatment.

Estimation of MTE requires the (standard) IV assumptions of conditional
independence of the errors (U_0,U_1,V) from Z_ conditional on X. This allows us
to estimate the MTE within the support of P(Z) conditional on X. In practical
applications, however, this support is often very limited, and most applied work
therefore require an additional separability assumption: E(U_j | X,V) =
E(U_j | V). This last assumption implies that the level of MTE, but not the
slope, is a function of X and allows us to identify the MTE over the
unconditional support of P(Z). In many cases, even the unconditional support of
P(Z) can be limited, and the MTE can only be estimated for parts of the unit interval.
See the note on support below for how mtefe treats these cases.

The MTE measures the average treatment effect for people at a particular
margin of indifference, or with a particular resistance to treatment. It can
be expressed as

MTE(x,u) = E(Y_1-Y_0|X=x,U_d=u) = X(b_1-b_0)+k(u)

where

k(u) = E(U_1-U_0|U_d=u)

We can trace out the distribution of the MTE over U_d, MTE(x,u), within the
support of p.

Estimation using local IV

It can be shown that the derivative of the conditional expectation of Y with
respect to p identifies the MTE (Heckman and Vytlacil 2007a,b). Given the
separability assumption, we have

E = Xb_0 + X(b_1-b_0)p +K(p)

where

K(p) = pE(U_1 - U_0|U_d < p)

Thus, if we make assumptions on the K(p) function, we can estimate the
conditional expectation of Y and form its derivative to construct the MTE.

Estimation using the separate approach

When using the separate approach, we estimate the conditional expectation
separately in the treated and untreated sample. We apply the appropriate
selection correction, depending on the model, to account for the endogenous
selection into treatment. Following the notation of Brinch, Mogstad, and
Wiswall (2017),

E(Y_j|X,D=j,p) = Xb_j + K_j(p)

where

K_1(p) = E(U_1|U_d < p)

K_0(p) = E(U_0|U_d >= p)

Thus, if we make assumptions on the K_j(p) functions, we can estimate the
conditional expectation. Then, we form the MTE as

MTE(x,u)=E(Y_1-Y_0|X = x, U_d = u) = X(b_1-b_0)+k_1(p)-k_0(p)

where

k_1(p) = K_1(p)+pK_1'(p)

k_0(p) = K_0(p)-(1-p)K_0'(p)

As with the local IV method, the exact specification of the K-functions
depends on the model.

Estimation using maximum likelihood

Alternatively, the joint normal MTE model can be estimated using maximum
likelihood because we know the full distribution of the errors. In that case,
the log-likelihood function can be expressed as

l=D[ln+ln((1/s1)f(U_1/s1))] +(1-D)[ln((1/s0)f(U_0/s0))+ln]

where f and F are standard normal density and cumulative density functions
and

eta_j = /sqrt(1-rho_j^2)

which can be maximized to find the parameters of the model. For details, see
the movestay command, which inspired the log-likelihood estimation in
mtefe, and Lokshin and Sajaia (2004).

A note on standard errors

Local IVs and the separate approach as implemented by mtefe are two-step
methods. In the first step, the propensity scores are estimated and predicted
and the treatment-effect parameter weights are estimated based on these
estimates. In the subsequent step, the rest of the parameters of the model are
estimated, and lastly, the MTE estimates themselves are constructed from the
estimates of b_1-b_0 and k(p).

In this setting, analytic standard errors are inappropriate because they
ignore the uncertainty from three sources: a) the uncertainty from the
propensity score estimates by simply treating p as a variable, b) the
uncertainty from the estimation of the treatment-effect parameter weights, and
c) the uncertainty from the estimates of X, the set of values for which we
evaluate the MTE and the treatment effect parameters.

If we are interested in the MTE at the (unknown) mean of X in the population,
it is appropriate to include the uncertainty in the estimate of the mean of X
in the estimates of the MTEs.

For all these reasons, the most conservative way to estimate standard errors
of MTE models are through the bootstrap. The bootstrap in mtefe takes
all the above mentioned sources of uncertainty into account by reestimating
the first step for each bootstrap replication, unless the options
norepeat1 is specified.

Nonetheless, the default standard errors reported by mtefe are
calculated analytically, ignoring these sources of uncertainty. Users are
warned about this after estimation unless bootstrap is applied with the
bootreps() option. When cluster bootstrapping the standard errors
(using bootreps() and the vce(cluster clustvar) options together), users
should be wary of specifications that also include the cluster variable
in one of the independent variable lists. mtefe handles the most common
application of this, when the cluster variable is included as fixed effects
in one of the independent variable lists, but with other (arguable uncommon)
specifications such as the cluster variable included as a continuous regressor
and a fixed effect, users should be careful.

When using maximum likelihood estimation of the joint normal model, all model
parameters are estimated in one step. This implies that the analytic standard
errors are more appropriate, because they now account for the uncertainty of
the first-step estimates, but they still do not account for the uncertainty in
the estimation of the mean or the estimates of the treatment-effect parameter
weights.

A note on the support of P(Z)

Under the separability assumption, the MTE can be identified
semiparametrically over the support of P(Z). If the support is limited,
identification outside the common support will necessarily rely on
extrapolation. By default, mtefe estimates the MTE over the full unit
interval if a parametric model is specified. If a semiparametric model is
specified, however, mtefe estimates the MTE only at points where there
are at least one treated and one untreated individual, unless the option
fullsupport is specified. In addition, the option trimsupport()
allows the user to trim a fraction of # from the tails of each sample, in
practice strengthening the conditions for what constitutes support.
Individuals with propensity scores outside the support for the relevant sample
are dropped, and the first stage is reestimated when trimsupport() is
specified. This option trumps the fullsupport option.

In cases where the MTE is not estimated over the full unit interval, conventional
non-marginal treatment effect parameters (ATE, ATT, ATUT, LATE and PRTE) cannot
be estimated, as they depend on the MTE over the full unit interval. In these cases,
the user should be careful when interpreting the treatment effect estimates.
mtefe by default rescales the treatment effect parameter weights to sum to 1 within
the support, producing a parameter that can be interpreted analogously to the original but for
people with unobserved resistance within the support. These parameters are identical to the
originals only if the weighted average over the MTE outside of the support is equal to the
weighted average within the support. Alternatively, if norescale is specified, mtefe does
not rescale the weights when producing the parameter estimates. This parameter is equal
to the original only if the MTE is equal to 0 outside of the support.

Examples

To fix ideas, the mtefe_gendata program simulates data on log wages for
people with varying experience, living in different districts or labor
markets, and with and without college education. College education is
endogenous, so we need an instrument to identify causal effects.
Unfortunately, even the distance to college is not a valid instrument because
there is correlation across districts; rural labor markets with longer
distances to colleges are different than urban ones. Within districts,
however, the distance to college is unrelated to unobservables, so the
instrument is valid conditional on fixed effects.

Generate simulated data of 10,000 observations distributed in 10
districts

. mtefe_gendata, obs(10000) districts(10)

The parametric normal model, fit using local IV

. mtefe lwage exp exp2 i.district (col=distCol)

The parametric polynomial of degree 1, estimated using the separate
approach

. mtefe lwage exp exp2 i.district (col=distCol), separate pol(1)

The polynomial model of degree 2, using a linear probability model for the
propensity score

. mtefe lwage exp exp2 i.district (col=distCol), polynomial(2) link(lpm)

The parametric normal model, fit using maximum likelihood

. mtefe lwage exp exp2 i.district (col=distCol), mlikelihood

The semiparametric polynomial model with 50 bootstrap replications

. mtefe lwage exp exp2 i.district (col=distCol), pol(1) bootreps(50)

The joint normal model where the fixed effects are restricted to be the same in
the treated and untreated state (note: violation of exclusion)

. mtefe lwage exp exp2 (col=distCol), restricted(i.district)

The semiparametric model, using a smaller evaluation grid to save computational time

. mtefe lwage exp exp2 i.district (col=distCol), semiparametric gridpoints(100)

Calculating the PRTE for a policy that mandates a maximum distance to college
of 40 miles, normal model

. probit col distCol exp exp2 i.district

. rename distCol tempdistcol

. gen distCol=min(40,tempdistcol)

. predict double p_prte

. drop distCol

. rename tempdistcol distCol

. mtefe lwage exp exp2 i.district (col=distCol), prte(p_prte)

. mtefeplot, prte

The polynomial model of degree 2 with two splines at 0.25 and 0.75, fit using
the local IV

. mtefe lwage exp exp2 i.district (col=distCol), polynomial(2) splines(0.25 0.75)

Stored results

mtefe stores the following in e():

Scalars

e(N) number of observations

e(IV) regular two-stage least-squares estimate

e(polynomial) degree of polynomial in polynomial models

e(p_U) p-value for a test of unobserved heterogeneity -- the coefficients on k(p)

e(p_X) p-value for a test of observed heterogeneity -- the b_1-b_0 coefficients

Macros

e(cmd) mtefe

e(cmdline) command as typed

e(depvar) name of dependent variable

e(title) title in estimation output

e(title2) secondary title in estimation output

e(method) estimation method

e(properties) b V; V

Matrices

e(b) coefficient vector, including MTE and treatment parameters

e(V) variance-covariance matrix of b, empty if using semiparametric methods and no bootstrap

e(trimminglimits) trimming limits if using the trimsupport() option.

e(support) vector of common support over p

e(mte) vector of MTE estimates

e(mtexs_ate) vector of x values for which the main MTE and ATE
were calculated

e(mteatt) MTE curve for the treated individuals

e(weightsatt) estimated weights at each point of support for the ATT

e(mtexs_att) vector of x values for which the ATT was calculated

e(mteatut) MTE curve for the untreated individuals

e(weightsatut) estimated weights at each point of support for the ATUT

e(mtexs_atut) vector of x values for which the ATUT was calculated

e(mtelate) MTE curve for the compliers

e(weightslate) estimated weights at each point of support for the LATE

e(mtexs_atut) vector of x values for which the LATE was calculated

e(mteprte) MTE curve for the policy compliers if specified in prte()

e(weightsprte) estimated weights at each point of support for the PRTE (if specified in prte())

e(mtexs_atut) vector of x values for which the PRTE was calculated (if specified in prte())

e(dkdp) estimates of k(u) at the points of support

e(weightsmprte1) estimated weights at each point of support for the MPRTE1 parameter

e(weightsmprte2) estimated weights at each point of support for the MPRTE2 parameter

e(weightsmprte3) estimated weights at each point of support for the MPRTE3 parameter

e(tescales) scales of the non-marginal treatment effect parameters in situations with limited support

Functions

e(sample) marks estimation sample

If semiparametric is specified, the following matrices are stored:

Matrices

e(bandwidth) bandwidths used in local polynomial smooths, alternatively as e(bandwidth1) and e(bandwidth0) if the separate approach is used

e(degree) degree in local polynomial smooth

If separate or mlikelihood is specified, the following matrices
are stored:

Matrices

e(Y1) average outcomes in the treated state

e(Y0) average outcomes in the untreated state

Note: bootstrap stores its own output in e() as well. See
bootstrap.

Note: Various options store results as variables as well. These include
saveweights(), where the variable prefix is user specified;
savepropensity, where the new variable name is user specified; and
savekp, where the variable names are predetermined to work with
postestimation predictions.

References

Brave, S., and T. Walstrum. 2014. Estimating marginal treatment effects using parametric and semiparametric methods. Stata Journal 14: 191-217.

Brinch C., M. Mogstad, and M. Wiswall. 2017. Beyond LATE with a discrete instrument. Journal of Political Economy 125: 985-1039.

Heckman, J. J., and E. J. Vytlacil. 2007a. Econometric evaluation of social
programs, part I: Causal models, structural models and econometric policy
evaluation. In Handbook of Econometrics, vol. 6B, ed. J. J. Heckman and E.
E. Leamer, 4779-4874. Amsterdam: Elsevier.

------. 2007b. Econometric evaluation of social programs, part II: Using the
marginal treatment effect to organize alternative econometric estimators to
evaluate social programs, and to forecast their effects in new environments. In
Handbook of Econometrics, vol. 6B, ed. J. J. Heckman and E. E. Leamer,
4875-5143. Amsterdam: Elsevier.

Lokshin, M. and Z. Sajaia. 2004.
Maximum likelihood estimation of endogenous switching regression models.
Stata Journal 4: 282-289.

Thanks for citing mtefe as follows

Andresen, Martin E., (2018). "MTEFE: Stata module to estimate marginal treatment effects". This version VERSION_DATE.

where you can check your version date as follows:

. which mtefe

Author

Martin Eckhoff Andresen

Statistics Norway

Oslo, Norway

martin.eckhoff.andresen@gmail.com

This program is inspired by margte by Brave and Walstrum (2014), who
deserve a huge thanks. The maximum likelihood evaluator is adapted from
the movestay command by Lokshin and Sajaia. Edwin Leuven, Katrine Løken,
Magne Mogstad also deserve thanks for various help and bug reports.

Also see

Development version: net install mtefe, from("https://raw.githubusercontent.com/martin-andresen/mtefe/master")

Article: Stata Journal, volume 18, number 1: st0516

Help: mtefeplot, locpoly3, nearmrg (required for gridpoints()), movestay, margte (if installed)