help ipwlogithttp://github.com/benjann/ipwlogit/

Title

ipwlogit -- Marginal logistic regression by inverse probability weighting

Syntax

ipwlogit depvar tvar [indepvars] [if] [in] [weight]
[,
options
]

options

Main
psmethod(method) propensity
score estimation method

psopts(options) options
passed through to propensity score model

truncate(#) truncate weights, # in [0,.5]

bins(#) number of bins for continuous treatment

discrete treat continuous treatment as discrete

asbalanced use balanced design (non-stabilized weights)

noisily display output from propensity score estimation

nodots suppress propensity score estimation progress dots

noconstant suppress constant term in outcome model

maximize_options maximization options
for outcome model; seldom used

generate(newvar) store IPWs

tgenerate(newvar) store binned treatment variable

replace allow replacing existing variables

SE/Robust
vce(vcetype) variance estimation
method; vcetype may be robust, cluster clustvar,
svy, bootstrap, or jackknife

novceadjust treat IPWs as fixed

ifgenerate(spec) store influence functions; spec may be
namelist or stub*

rifgerate(spec) store recentered influence functions; spec is
namelist or stub*

ifscaling(spec) scaling of (recentered) IFs; spec if total (default) or mean

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

or report odds ratio

noheader suppress table header

notable suppress table of results

noipw suppress table of IPW statistics

display_options standard display option

coeflegend display legend instead of statistics

indepvars may contain factor variables; see fvvarlist.

pweights, fweights, and iweights are allowed; see help
weight.

Description

ipwlogit fits marginal logistic regression of depvar on
tvar, possibly adjusting for indepvars by inverse probability
weighting (IPW). The resulting estimate can be interpreted as a marginal (log)
odds ratio of a positive outcome. depvar equal to nonzero and nonmissing
(typically depvar equal to one) indicates a positive outcome, whereas
depvar equal to zero indicates a negative outcome.

tvar can be categorical, continuous, or discrete.

o Categorical treatment: Specify tvar as
i.varname, where varname is the name of the treatment
variable. More complicated factor-variable specifications such as, e.g.,
ibn.varname, i(2 3 4).varname , or
0.varname 1.varname are also allowed. In any
case, the computation of inverse probability
weights (IPWs) will be based on the observed levels of the treatment variable,
not the levels specified in tvar.

o Continuous treatment: Specify tvar as varname or
c.varname to model a linear effect, or as
c.varname##c.varname to model a nonlinear
effect. More complicated interaction specifications such as
varname c.varname#c.varname
or c.varname##c.varname##c.varname
are also allowed. The computation of IPWs will be based
based on a coarsened treatment variable that divides the original
treatment into a series of equal probability bins. Use option bins()
to control the number of bins.

o Discrete treatment: Specify tvar as for a continuous
treatment, but additionally apply option discrete. No binning will be
applied, that is, the computation of IPWs will be based on the observed levels
of the treatment variable.

For details on inverse probability weighting and marginal odds ratios see
Jann and Karlson (2023).

Options

psmethod(method) selects the propensity score estimation method. Supported
methods are as follows.

logit for each treatment level, fit
a logistic regression of the level against all other levels
(using command logit)

mlogit fit a multinomial logistic regression across all
levels (using command mlogit)

ologit fit an ordered logistic regression across all
levels (using command ologit)

gologit fit a generalized ordered logistic regression across all
levels; this requires command gologit2 by Williams (2006)
to be installed on the system (type ssc install gologit2)

cologit fit a series of cumulative odds models across
treatment levels (using command logit); this is asymptotically
equivalent to gologit2, but imposes less computational burden

The default method depends on the type of the treatment variable. For a categorical
treatment with two levels (dichotomous treatment), the default is logit; for
a categorical treatment with more than two levels, the default is mlogit; for a
continuous or discrete treatment, cologit is the default. For a dichotomous treatment,
the choice of method does not matter; results will always be the same. For an
ordered categorical treatment, you may want to consider cologit
(or gologit or ologit) instead of mlogit.

psopts(options) specifies options to be passed through to the
propensity score estimation command. This may be useful, for example,
to specify constraints. See the help file of the relevant command
(logit, mlogit, ologit, or gologit2) for
information on available options (option link() is not allowed in case
of gologit2).

truncate(#), # in [0,0.5], applies truncation to the inverse
probability weights. Weights smaller than quantile # of the overall
distribution of weights will be replaced by the value of quantile #
and weights larger than quantile 1-# will be replaced by the value of
quantile 1-#. For example, type truncate(0.01) to truncate the
weights to the 1st and 99th percentile. Truncation will always be applied
on the basis of stabilized weights; truncated non-stabilized weights will be
obtained by rescaling the truncated stabilized weights.

bins(#) sets the (maximum) number of quantile bins used to categorize
a continuous treatment. The resulting number of bins may be less than
# if there is heaping in the distribution of the treatment variable. The
default is to determine the number of bins as ceil(ln(N)/ln(2)) + 1
(Sturges' rule for the number of histogram bins).

discrete declares the treatment variable as discrete. In this case,
the variable will not be categorized based on quantiles. Use this option for
a quantitative treatment with relatively few distinct levels.

asbalanced scales the inverse probability weights in a way such that
they correspond to a balanced design in which each treatment level has the
same marginal probability. By default, ipwlogit uses so-called stabilized
weights that are scaled such that the sum of weights within each treatment
level corresponds to the relative frequency of the level (in expectation). Use
asbalanced to request non-stabilized weights that are scaled such that
the sum of weights within each treatment levels is the same (in expectation).

noisily displays the output from the model(s) used to estimate
propensity scores. By default, such output is suppressed.

nodots suppresses the propensity score estimation progress dots. nodots
has no effect of noisily is specified.

noconstant suppresses the constant term (intercept) in the outcome
model. This may be useful if you want to report odds by levels of a
categorical treatment rather than odds ratios with respect to the base
level (specify tvar as ibn.varname in this case).

maximize_options are maximization options for the outcome model. See
help logit for details.

generate(newvar) stores the inverse probability weights (IPWs) in variable
newvar. The stored IPWs are net of sampling weights. To obtain overall weights,
multiply the IPWs by the sampling weights. Option generate() is not
allowed with vce(bootstrap) or vce(jackknife).

tgenerate(newvar) stores the binned treatment in variable
newvar. Option tgenerate() is not
allowed with vce(bootstrap) or vce(jackknife), or if the
treatment variable is categorical.

replace allows to overwrite existing variables.

vce(vcetype) specifies how standard errors
are computed. vcetype may be:

robust
cluster clustvar
svy [svy_vcetype] [, svy_options ]
bootstrap [, bootstrap_options ]
jackknife [, jackknife_options ]

vce(robust), the default, computes robust standard errors based on
influence functions.

vce(cluster clustvar) computes standard errors based
on influence functions allowing for intragroup correlation, where
clustvar specifies to which group each observation belongs.

vce(svy) computes standard errors taking the survey design as set by
svyset into account. The syntax is equivalent to the syntax of the svy
prefix command; that is, vce(svy) is ipwlogit's way to support
the svy prefix.

vce(bootstrap) and vce(jackknife) compute standard errors using
bootstrap or jackknife, respectively; see help vce_option.

novceadjust assumes the IPWs as fixed (rather than estimated)
when computing standard errors. This typically leads to slightly
conservative results. vce(bootstrap), vce(jackknife), and
vce(svy) with replication-based VCE imply novceadjust
(to save a little bit of computer time).

ifgenerate(spec) stores the influence functions of the parameters of the
outcome model. Either specify a list of new variables names,
or specify stub*, in which case the new variables will be named
stub1, stub2, etc. Option ifgenerate() is not
allowed with vce(bootstrap) or vce(jackknife).

rifgenerate(spec) stores the recentered influence functions; see the description
of ifgenerate(). Only one of ifgenerate() and rifgenerate()
is allowed.

ifscaling(spec) determines the scaling of the stored (recentered) influence
functions. spec can be total (scaling for analysis by
total) or mean (scaling for analysis by mean). Default is
ifscaling(total).

level(#) specifies the confidence level, as a percentage, for
confidence intervals. The default is level(95) or as
set by set level.

or reports the estimated coefficients transformed to odds ratios,
that is, exp(b) rather than b. Standard errors and confidence intervals are
similarly transformed. This option affects how results are displayed, not
how they are estimated. or may be specified at estimation or when
replaying previously estimated results. When applying multiple imputation,
specify or as option to mi estimate, not as option to
ipwlogit.

noheader suppresses the display of the table header.

notable suppresses the display of the table of results.

noipw suppresses the display of the table of IPW statistics.

display_options are usual display options as documented in
[R] Estimation options.

coeflegend specifies that the legend of the coefficients and how to
specify them in an expression be displayed rather
than displaying the statistics for the coefficients.

Example

The following example illustrates how the adjusted marginal odds ratio can be
different from the conditional odds ratio:

unadjusted marginal odds ratio
. webuse lbw
. logit low i.smoke, or vce(robust)
. ipwlogit low i.smoke, or

conditional odds ratio
. logit low i.smoke age lwt i.race ptl ht ui, or vce(robust)

adjusted marginal odds ratio
. ipwlogit low i.smoke age lwt i.race ptl ht ui, or

Stored results

ipwlogit stores the following in e():

Scalars

e(N) number of observations

e(sum_w) sum of base weights

e(tk) number of treatment levels/bins

e(truncate) value of truncate()

e(bins) requested number of bins; continuous treatment only

e(k) number of parameters in outcome model

e(k_eq) number of equations in outcome model

e(df_m) degrees of freedom of outcome model

e(r2_p) pseudo-R-squared of outcome model

e(ll) log likelihood of outcome model

e(ll_0) log likelihood of constant-only outcome model

e(N_cds) number of completely determined successes in outcome model

e(N_cdf) number of completely determined failures in outcome model

e(ic) number of iterations of outcome model

e(rc) return code of outcome model

e(converged) 1 if outcome model converged, 0 otherwise

e(N_clust) number of clusters

e(chi2) outcome model chi-squared

e(p) p-value for model test

e(rank) rank of e(V)

Macros

e(cmd) ipwlogit

e(cmdline) command as typed

e(title) title in estimation output

e(depvar) name of dependent variable

e(tvar) treatment variable specification

e(tname) name of treatment variable

e(ttype) factor, discrete, or continuous; type of treatment variable

e(tlevels) list of treatment levels

e(indepvars) adjustment variables

e(psmethod) propensity score estimation method

e(psopts) options passed through to propensity score estimation

e(asbalanced) asbalanced or empty

e(mlopts) maximization options passed through to outcome model

e(wtype) weight type

e(wexp) weight expression

e(clustvar) name of cluster variable

e(chi2type) Wald; type of model chi-squared test

e(vce) vcetype specified in vce()

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

e(vceadjust) novceadjust or empty

e(properties) b V

e(generate) name of variable containing IPWs

e(tgenerate) name of variable containing binned treatment

e(ifgenerate) names of variables containing IFs

e(iftype) IF or RIF (or empty)

e(ifscaling) total or mean (or empty)

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix of the estimators

e(V_modelbased) model-based variance

e(at) breaks of continuous treatment or values of discrete treatment

e(prop) marginal treatment probabilities

e(ipw) information on the distribution of the IPWs

Functions

e(sample) marks estimation sample

References

Jann, Ben, Kristian Bernt Karlson. 2023. Estimation of marginal odds ratios. University
of Bern Social Sciences Working Papers 44. Available from
https://ideas.repec.org/p/bss/wpaper/44.html.

Williams, Richard. 2006. Generalized ordered logit/partial proportional odds
models for ordinal dependent variables. The Stata Journal
6(1):58-82. DOI: 10.1177/1536867X0600600104

Author

Ben Jann, University of Bern, ben.jann@unibe.ch

Thanks for citing this software as follows:

Jann, B. (2022). ipwlogit: Stata module to fit marginal logistic regression
by inverse probability weighting. Available from
http://github.com/benjann/ipwlogit/.

Also see

Online: help for
logit, mlogit, ologit,
gologit2 (if installed), riflogit (if installed),
lnmor (if installed)