help for srslogit(Roger Newson)

Logit regression with secondary ridit splines

srslogit depvar
[indepvars]
[weight]
[if] [in]
[,
pprobability(newvar)
pxb(newvar)
pipweight(newvar)

nosrspline

power(#)
refpts(numlist)
ridit(newvar)

sprob(newvar)
sxb(newvar)
sipweight(newvar)
rrspline(prefix)

noconstant
glm_options
]

where prefix is a prefix for generated variables containing the ridit reference splimes,
and glm_options are options for glm,
other than the noconstant, asis, family(), and link() options.

fweights, iweights, and pweights are allowed; see
weight.
They are interpreted as weights of the same kinds with glm.

Description

srslogit fits a primary logit model for a binary dependent variable
in a list of independent variables,
followed optionally by a secondary ridit spline model for the same binary dependent variable
in the ridit of the predicted dependent variable
from the primary logit model.
It optionally outputs variables created in this process,
including the predicted values (also known as propensity scores)
and inverse probability weights (also known as inverse propensity weights)
from the primary and secondary logit models.
These propensity weights may be used as treatment propensity weights
(if the dependent variable is a treatment indicator)
or as completeness-propensity weights
(if the dependent variable is a completeness indicator).
srslogit uses the SSC packages wridit and bspline,
which have to be installed in order for srslogit to run.

Options

pprobability(newvar), pxb(newvar), and pipweight(newvar)
specify the names of optional generated output variables,
to contain the predicted probabilities, predicted odds, and inverse probability weights,
respectively,
of an outcome of 1 from the primary logit model.
The inverse probability weight corresponding to a perdicted probability pprobability
and an outcome value of 0 or 1
is a_1/pprobability if the outcome is 1,
and a_0/(1-pprobability) if the outcome is 0,
where a_0 and a_1 are stabilization factors,
equal to the overall probabilities that the outcome variable is 0 or 1,
respectively.
Inverse probability weights can be used as inverse treatment probability weights
for estimation of the average treatment effects for the whole sample,
if the outcome is a treatment indicator,
or as inverse completeness probability weights for the subsample with outcome 1,
if the outcome is a completeness indicator.

nosrspline specifies that the secondary ridit spline will not be fitted.
If nosrspline is specified,
then the options power(), refpts(),
ridit(), sprobability(), sxb(), sipweight(),
and rrspline()
will be ignored.

power(#) specifies the power (or degree) of the fitted secondary ridit spline.
The default is power(3), specifying a cubic secondary ridit spline.

refpts(numlist) specifies an ascending list of percentage ridits (between 0 and 100 inclusively)
to be used as reference points for the secondary ridit spline
in the ridit of the primary predictor.
The default is refpts(0 25 50 75 100),
specifying a spline with reference points at percents 0, 25, 50 75, and 100,
corresponding to percentiles 0 (the minimum), 25, 50, 75, and 100 (the maximum)
of the predicted proportion of individuals with outcome 1
from the primary logit model.

ridit(newvar) specifies an optional generated output variable,
containing the ridits of the predicted probabilities from the primary logit model,
used for generating the ridit spline used to define the secondary ridit spline logit model.

sprobability(newvar), sxb(newvar), and sipweight(newvar)
specify the names of optional generated output variables,
to contain the predicted probabilities, predicted odds, and inverse probability weights,
respectively,
of an outcome of 1 from the secondary ridit spline logit model.

rrspline(prefix) specifies a prefix for the names Of optional generated outpu/t variables,
to contain the reference ridit spline basis used to fit the secondary ridit spline logit model.
If the user specifies rrspline(prefix),
then the generated reference ridit spline basis variables have names numbered prefix_i,
for i from 1 to the number of reference points specified by the refpts() option.

Methods and formulas

srslogit works by first fitting a primary logit regression model,
fitted using glm,
with the outcome specified by the input depvar
and covariates specified by the input indepvars,
and then computes the predicted probabilities, predicted odds, and inverse probability weights
for that primary model.
If nosrspline is not specified,
it then proceeds to the secondary ridit spline model.
To do this,
it first computes the percentage ridits of the predicted odds from the primary model
using the SSC package wridit,
and then using the flexcurv module of the SSC package bspline
to compute a reference spline basis in the percentage ridits,
with reference points on a percentage scale specified by the refpts() option.
This reference spline basis is then used as the covariates for a second glm command,
with the noconstant option,
so that the parameters are the log odds of the outcome variable
at the reference percentage ridits specified by refpts().
This second model is known as the secondary ridit spline model,
and is formulated to have the discriminating power of the primary logit model,
but to have better calibration when predicting the outcome from the ridit of the predicted odds.
srslogit then computes the predicted probabilities, predicted odds, and inverse probability weights
for the secondary model.
The computed variables are returned in new variables,
if the appropriate options are specified,
but otherwise live in temporary variables,
which are discarded when srslogit completes execution.

The primary model is fitted using a glm command of the form

glm depvar [indepvars] [if] [in] [weight] , family(bernoulli) link(logit) asis [ noconstant ] glm_options

where glm_options are options for glm,
other than the noconstant, asis, family(), and link() options.

If nosrspline is not specified,
then the percentage ridits are calculated using a wridit command of the form

wridit pxb [if] [in] [weight], percent gene(ridit)

where pxb is an input variable containing the predicted log odds from the primary logistic model,
and ridit is an output variable to contain the percentage ridits of the primary predicted log odds.
The secondary ridit spline basis is then computed using a flexcurv command of the form

flexcurv rrsbasis [if] [in] , xvar(ridit) refpts(refpts) power(power)
krule(interpolate)
include(0 100)
generate(rrspline) type(double) labprefix("Percent@")

where rrsbasis is the newvarlist specifying the names of the variables to be created as the ridit reference spline basis,
ridit is the variable containing the percentage ridits,
refpts is the numlist specified by the refpts() option,
power is the integer power specified by the power() option,
and rrspline is the prefix specified by the rrspline() option.
We can then fit the secondary ridit spline logit model using a glm command of the form

glm depvar rrsbasis [if] [in] [weight] , family(bernoulli) link(logit) asis noconstant
glm_options

which fits a logit model for the outcome with respect to the ridit reference spline basis,
whose parameters are the values of the secondary ridit spline at the reference percents
specified by refpts().

More about reference splines and the bspline package can be found in
Newson (2012)
and Newson (2011).
More about ridit splines, and their use in propensity weighting,
can be found in
Newson (2017).

Technical note

The logit function is the canonical link function for the Bernoulli distributional family.
This implies that the log pseudolikelihood being maximized
is mathematically guaranteed to be concave,
implying that the maximization is guaranteed to converge,
if converging is defined to include converging to a parameter vector of log odds or odds ratios
including values of plus or minus infinity.
(That is to say, multiple local maxima are mathematically disallowed from existing.)
This in turn implies that, if the model seems not to be converging,
then we should be able to assume that it is really converging to a vector with at least one infinite value,
and that the predicted probabilities from the model will therefore be not vastly in error,
although some predicted values will be close to 0 or 1.
Therefore, we do not expect any major errors to be generated by using the current estimated parameter vector,
even though glm reports that the model has not converged,
although the corresponding inverse probability weights
(also known as inverse propensity weights)
may occasionally be very large.
srslogit therefore does not fail when either the primary model or the secondary model
is reported as failing to converge (return code 430).
The use of a secondary ridit spline will probably minimize extreme inverse probability weights,
except when the inverse probability weights are failing to balance the covariates
included in the primary logit model.
This lack of balance will cause the inverse probability weighted Somers' D
of predicted probability or odds with respect to the Bernoulli outcome
to be clearly positive,
when measured using the somersd package.
See Newson (2017)
for more about the use of somersd to detect imbalance.

Examples

These examples use the lbw dataset,
downloadable using the command webuse.
We create propensity scores for smoking,
indicated by the variable smoke,
based on a list of variables that might predict smoking in a pregnant mother.

Set-up

. webuse lbw, clear

. describe, full

. label list smoke

. tab smoke, m

Compute propensity scores and inverse probability weights from the primary and secondary logit models:

. srslogit smoke age lwt ib1.race ptl ib0.ht, pprob(priprop) pipw(priipw) sprob(secprop) sipw(secipw) eform

. describe, full

. summ priprop, de

. summ priipw, de

. summ secprop, de

. summ secipw, de

Use the SSC packages somersd and haif to do the balance checks and variance inflation checks, respectively,
for the primary propensity score and inverse probability weights:

. somersd smoke priprop, transf(z) tdist

. somersd smoke priprop [pwei=priipw], transf(z) tdist

. haif ib0.smoke, pweight(priipw)

Use the same SSC packages
to do the balance checks and variance inflation checks, respectively,
for the secondary ridit spline propensity score and inverse probability weights:

. somersd smoke secprop, transf(z) tdist

. somersd smoke secprop [pwei=secipw], transf(z) tdist

. haif ib0.smoke, pweight(secipw)

We see from the unweighted somersd commands
that the primary and secondary propensity scores
predict smoking equally well.
We see from the inverse propensity weighted somersd commands
that the secondary propensity weights balance the association
slightly better than the primary propensity weights.
We see from the haif commands
that the secondary propensity weights inflate the variance of a smoking effect on an outcome variable
less than the primary inverse propensity weights.
The secondary propensity weights might therefore be better ones to use
when estimating an effect of smoking on an outcome
(such as child birth weight).

The packages somersd and haif are downloadable from SSC.
Their use in evaluating the costs and benefits of propensity weights is described in
Newson (2017).
More about reference splines and the bspline package can be found in
Newson (2012).

Estimate the maternal smoking effect on birth weight using secondary inverse propensity weights:

. regress bwt smoke [pwei=secipw]

This effect is adjusted for the covariates in the propensity model.
It compares mean birthweight if all mothers smoked
with mean birthweight if no mothers smoked.

Saved results

If the nosrspline option is not specified,
stpp_est saves in e() the estimation results from the glm command
used to fit the secondary ridit spline logit regression model.
If the nosrspline option is specified,
stpp_est saves in e() the estimation results from the glm command
used to fit the primary logit regression model.

Author

Roger Newson, King's College London, UK.

Email: roger.newson@kcl.ac.uk

References

Newson, R. B. 2017. Ridit splines with applications to propensity weighting.
Presented at the 23rd UK User Meeting, 7–8 September, 2017.

Newson, R. B. 2012.
Sensible parameters for univariate and multivariate splines.
The Stata Journal 12(3): 479-504.
Download from the Stata Journal website.

Newson, R. B. 2011. Sensible parameters for polynomials and other splines.
Presented at the 17th UK Stata User Meeting, 15-16 September, 2011.

Also see

Manual: [R] glm

On-line: help for glm

help for wridit, bspline if installed