*! version 1.0
help simqoi

Title

simqoi -- Simulate quantities of interest

Syntax

simqoi
[if] [in]
using filename
[weight]
[,
quantity_of_interest
options]

quantity_of_interest

ev simulate expected values; the default

pv simulate predicted values

diff simulate the difference between two expected values

ratio simulate the ratio of two expected values

Main
depvar(eqno) specify the dependent variable

generate(stubname) save simulated values as variables with prefix stubname

double generate variable type as double; default is float

seed(#) set random-number seed to #

At
at(atspec) simulate
quantity of interest at specified values of covariates

noesample do not restrict calculation of statistics to the
estimation sample

noweights ignore weights specified in estimation

nooffset ignore any offset() or exposure() variable

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

noheader suppress output header

nolabel display numeric codes rather than value labels

noattable suppress table of fixed covariate values

The [if] [in] qualifiers restrict the scope of at() to those observations
for which the value of the expression is true.

See at() under Options for a description
of atspec.

fweights, aweights and pweights are allowed; see weight.

Description

simqoi implements a simulation-based approach for transforming the raw output of
regression models into quantities of substantive interest.
This approach has been discussed, among others, by
Dowd et al. (2014),
Gelman and Hill (2007),
King et al. (2000) and
Krinsky and Robb (1986; 1990; 1991).

Specifically, simqoi simulates predicted and expected values of the outcome variable
using the parameters stored by bootstrap or postsim.
simqoi also includes a wrapper for simulating differences and ratios of two
expected values.

Users can further transform the simulations produced by simqoi into any function of
interest through basic data manipulation.
Point estimates and measures of uncertainty of these functions can be assessed with
simple descriptive statistics (mean, median, standard deviation, centile-based confidence
intervals, etc.).
This technique is very convenient for tackling complex, non-linear functions of predicted
and expected values that are difficult to derive with standard analytical methods.

simqoi currently supports the following estimation commands:

command description

Linear regression models
cnsreg Constrained linear regression

eivreg Errors-in-variables regression

regress Linear regression

skewnreg Skew-normal linear regression

skewtreg Skew-t linear regression

tobit Tobit regression

Binary-response regression models
biprobit Bivariate probit regression

blogit Logistic regression for grouped data

bprobit Probit regression for grouped data

cloglog Complementary log-log regression

hetprob Heteroskedastic probit regression

logistic Logistic regression, reporting odds ratios

logit Logistic regression, reporting coefficients

probit Probit regression

scobit Skewed logistic regression

Discrete-response regression models
mlogit Multinomial (polytomous) logistic regression

ologit Ordered logistic regression

oprobit Ordered probit regression

Poisson regression models
gnbreg Generalized negative binomial model

nbreg Negative binomial regression

poisson Poisson regression

zinb Zero-inflated negative binomial regression

zip Zero-inflated Poisson regression

Instrumental-variables regression models
ivregress Single-equation instrumental-variables regression

Regression models with selection
heckman Heckman selection model

heckprob Probit model with sample selection

simqoi can be used with svy estimation results; see
[SVY] svy estimation.

Options

Main

depvar(## | name) is relevant only when you have previously fit
a model with two dependent variables in e(depvar).
It specifies the equation to which you are referring.
The default is depvar(#1).
depvar() can be specified using

#1, #2, ..., where #1 means the first equation,
#2 means the second equation, etc.; or

the name of the dependent variable.

generate(newvar) specifies that the simulated values be stored as variables
named stubname1, stubname2, ....
Each observation in each new variable contains one simulated value.

double specifies that the new variables be stored as Stata doubles,
meaning 8-byte reals.
If double is not specified, variables are stored as floats,
meaning 4-byte reals.
See [D] data types.

seed(#) sets the random-number seed.
Specifying this option is equivalent to typing the following command prior
to calling simqoi:

. set seed #

At

at(atspec) specifies values for covariates to be treated as fixed.
The default is at((mean) _all).

at(age=20) fixes covariate age to the value specified.
at() may be used to fix continuous or factor covariates.

at(age=20 sex=1) simultaneously fixes covariates age
and sex at the values specified.

at(age=(20 30 40 50)) fixes age first at 20, then at 30, etc.
simqoi produces separate results for each specified value.

at(age=(20(10)50)) does the same as
at(age=(20 30 40 50)); that is, you may specify a
numlist.

at((mean) age (median) distance)
fixes the covariates at the summary statistics specified.
at((p25) _all) fixes all covariates at their 25th percentile
values.
See Syntax of at() for the full list
of summary-statistic modifiers.

at((mean) _all (median) x x2=1.2 z=(1 2 3))
is read from left to right, with latter specifiers overriding former ones.
Thus all covariates are fixed at their means except for
x (fixed at its median), x2 (fixed at 1.2), and
z (fixed first at 1, then at 2, and finally at 3).

at((means) _all (median) x2)
is a convenient way to set all covariates except x2 to the mean.

See Syntax of at() for more information.

noesample
affects at(atlist).
It specifies that the whole dataset be considered instead of only those
observations marked in the e(sample) defined by the previous estimation
command.

noweights
affects at(atlist).
It specifies that any weights specified on the previous estimation command be
ignored.
By default simqoi uses the weights specified on the estimator to compute
summary statistics.
If weights are specified on the simqoi command they override previously
specified weights,
making it unnecessary to specify noweights.

nooffset
specifies that the calculation should be made, ignoring any offset or exposure
variable specified when the model was fit.

Reporting

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

nolabel requests that value labels attached to the dependent variable in
the model be ignored.

noheader prevents the table header from being displayed.

noattable prevents the table of fixed covariate values from being displayed.

Syntax of at()

In option at(atspec),
atspec may contain one or more of the following specifications:

varlist

(stat) varlist

varname = #

varname = (numlist)

where

1. varnames must be covariates in the current estimation results.

2. Variable names (whether in varname or varlist)
may be continuous variables, factor variables, or virtual level
variables, such as age, group, or 3.group.

3. varlist may also be one of three standard lists:

a. _all (all covariates),

b. _factor (all factor-variable covariates), or

c. _continuous (all continuous covariates).

4. Specifications are processed from left to right with latter specifications
overriding previous ones.

5. stat can be any of the following:

variables

stat description allowed

mean means (default) all

median medians continuous

p1 1st percentile continuous

p2 2nd percentile continuous

... 3rd-49th percentiles continuous

p50 50th percentile (same as median)
continuous

... 51st-97th percentiles continuous

p98 98th percentile continuous

p99 99th percentile continuous

min minimums continuous

max maximums continuous

zero fixed at zero continuous

base base level factors

Examples

These examples are intended for quick reference. For more intricate examples with
discussion see the program's website.

Example: Dowd, Greene and Norton (2014)

Setup

. webuse margex

Bootstrap replications

. bootstrap, saving(boots) reps(1000): logit outcome c.age##i.sex

Expected value (predicted probability)

. simqoi using boots, ev at(age=50 sex=1)

Partial effect

. simqoi using boots, diff at(age=(50 51) sex=1)

Post-estimation simulation (Krinsky-Robb method)

. postsim, saving(sims) reps(1000): logit outcome c.age##i.sex

Expected value (predicted probability)

. simqoi using sims, ev at(age=50 sex=1)

Partial effect

. simqoi using sims, diff at(age=(50 51) sex=1)

Saved results

simqoi saves the following in r():

Scalars

r(N_reps) number of simulations

Macros

r(cmd) simqoi

r(qi) ev or pv

r(level) # from level(#) option

r(atstats) list of keywords associated with the at() option;
a keyword is either value or one of stats

r(wtype) weight type

r(wexp) weight expression

r(seed) initial random-number seed

Matrices

r(b) mean of simulated values

r(se) standard errors

r(lb) lower confidence bound

r(ub) upper confidence bound

r(Results) Results

r(at) matrix of values from the at() option

References

Dowd, Bryan E., William H. Greene, and Edward C. Norton. 2013.
Computation of Standard Errors.
Health Services Research 49, no. 2: 731-750.

Gelman, Andrew and Jennifer Hill. 2007.
Data Analysis using Regression and Multilevel/Hierarchical Models.
Cambridge University Press.

King, Gary, Michael Tomz, and Jason Wittenberg. 2000.
Making the Most of Statistical Analyses:
Improving Interpretation and Presentation.
American Journal of Political Science 44, no. 2: 347-61.

Krinsky, Itzhak and A. Leslie Robb. 1986.
On Approximating the Statistical Properties of Elasticities.
The Review of Economics and Statistics 68, no. 4: 715-19.

Krinsky, Itzhak, and A. Leslie Robb. 1990
On Approximating the Statistical Properties of Elasticities: A Correction.
The Review of Economics and Statistics 72, no. 1: 189-90.

Krinsky, Itzhak and A. Leslie Robb. 1991.
Three Methods for Calculating the Statistical Properties of Elasticities: A Comparison.
Empirical Economics 16, no. 2: 199-209.

Author

Javier Márquez Peña,

Buendía & Laredo, Mexico City.

javier.marquez@buendiaylaredo.com

http://javier-marquez.com/software/moreclarify

Also see

Help: postsim, simqi (if installed);

[R] bootstrap, [R] jackknife, [R] permute.