Title

sdcasepick -- Second difference calculation based on units with similar baseline probabilities

Syntax

sdcasepick treatment [if] [in], groupvar(varname) [prvar(varname)
prub(#) prlb(#) basevalue(#) refvalue(#) round(#) expression(exp)
outcome(#) level(#) seconddifference verbose dropprvar ivlist(varlist)
overgroup oos]

Description

After the user estimates a logit (or other binary choice)
regression that includes a binary group indicator
(or a categorical variable if two of its categories are the groups of interest)
sdcasepick allows the user to specify any covariate of
interest z included in the previously estimated regression and
a range of baseline probabilities; within that range, it finds
the pair of observations (one in each group) in the estimation
sample that are closest in terms of baseline probability,
defined as Pr(Y=1|x,z=baseline value).

It can also be used after estimating a mutinomial logit, in which case
the relevant quantity is Pr(Y=m|x,z=baseline value).

Optionally, it then calculates first and second differences
(and associated standard errors) by setting the other covariates
at the values in this closest pair of observations.

Required inputs

treatment : the covariate of interest, z.

groupvar(varname) : the binary (0/1) group indicator. This option must be
specified. This variable need not be in the previously estimated model;
see Examples for illustration.

Optional inputs

prvar(varname) : the variable containing the predicted
probabilities of interest for each in-sample observation, typically
Pr(Y=1|x,z). (After mlogit: Pr(Y=m|x,z).) If not specified,
a variable will be created.

prub(#) : the upper bound of permissible baseline probabilities.
If not specified, the default value is 1.

prlb(#) : the lower bound of permissible baseline probabilities.
If not specified, the default value is 0.

basevalue(#) : the value at which to set the covariate of interest
z when calculating baseline probability. If not specified, the default value is 0.

refvalue(#) : the value at which to set the covariate of interest
z when calculating the change from z=basevalue, i.e., the first difference.
If not specified, the default value is 1.

round(#) : the units in which to round z for the purpose of
identifying the pair of observations that are closest in baseline probability.
This is useful for continuous z, when there are few or no observations with exactly
the same value of z across groups. Note that the values of basevalue and refvalue
are not rounded when calculating second differences, even if round is specified.
Entering round(.1) rounds 1.234 to 1.2, round(.01) to 1.23. See Stata's f_round.
If not specified, z is not rounded.

expression(exp) : specify if calculating probabilities based on anything
OTHER than the default expression used by margins after the estimated regression.
Rarely needed, except with firthlogit. See the option expression with margins for specifics.
See also the option outcome, which is mutually exclusive, and used after mlogit.

outcome(#) : the value of m for which to calculate Pr(Y=m|x) after a multinomial
logit. I.e., this should be a (non-baseline) value of the dependent variable.
This option must be specified after mlogit and is not allowed otherwise.

level(#) : the confidence level for the confidence intervals on the
first and second differences. If not specified, the level set in Stata
(by default, 95) is used.

seconddifference : calculate second differences.

verbose : show output from margins.

dropprvar : drop the program-created variable storing predicted probabilities.

ivlist(varlist) : a list of covariates in the previously estimated regression,
including groupvar. Since sdcasepick can determine this list automatically,
this option is typically not needed.

oos : not currently documented. do not use.

overgroup : not currently documented. do not use.

Examples

logit dv gv##(z x1 x2)
sdcasepick z, groupvar(gv) prlb(.45) prub(.55) seconddifference

logit dv gv##(z x1 x2)
predict pv
sdcasepick z, groupvar(gv) prlb(.45) prub(.55) prvar(pv) seconddifference

Using option round with continuous treatment:
logit dv gv##(c.z c.x1 c.x2)
sdcasepick z, groupvar(gv) basevalue(1.2) refvalue(1.6) round(.1) seconddifference

Comparing effects across two levels of a categorical group variable:
logit dv i.cgv##(z x1 x2)
gen gv = 0 if cgv == 3
replace gv = 1 if cgv == 6
sdcasepick z, groupvar(gv) prlb(.45) prub(.55) seconddifference

Specification after mlogit:
mlogit dv gv##(z x1 x2)
predict pv, outcome(3)
sdcasepick z, groupvar(gv) outcome(3) prvar(pv) prlb(.10) prub(.20) seconddifference

Reference

Gregory A. Caldeira and Daniel Lempert. (2018).
"Selection of Cases for Discussion: the U.S. Supreme Court, OT 1939, 1968, and 1982."
Paper presented at 2018 APSA Annual Meeting. Forthcoming, Journal of Law & Courts.

Notes

sdcasepick currently requires Stata 15 or newer; possible to change to earlier version
at/near top of .ado file if desired (but output from older versions has not been tested).

In addition to logit and mlogit, sdcasepick can also be used after probit, firthlogit, and
scobit, though these models (esp. scobit) have been less thoroughly tested. Firthlogit requires the
correct expression for Pr(Y=1) to be given in the option expression, since that model's
margins default is specified incorrectly. Support for ologit may be forthcoming at some point,
but the advantages over the LPM are probably minimal.

sdcasepick incorporates a very slightly modified version of Long and Freese's mlincom
command and subroutines thereof. See J. Scott Long and Jeremy Freese. (2014).
Regression Models for Categorical Dependent Variables Using Stata, Third Edition.
College Station, TX: Stata Press.

Author

Daniel Lempert
lemperds@potsdam.edu / dalempert@gmail.com