Learn R Programming

ipw (version 1.0-2)

ipwpoint: Estimate Inverse Probability Weights (Point Treatment)

Description

Estimate inverse probability weights to fit marginal structural models in a point treatment situation. The exposure for which we want to estimate the causal effect can be binomial, multinomial, ordinal or continuous. Both stabilized and unstabilized weights can be estimated.

Usage

ipwpoint(exposure, family, link, numerator = NULL, denominator,
         data, trim = NULL, ...)

Arguments

exposure
a vector, representing the exposure variable of interest. Both numerical and factor variables can be used. A binomial exposure variable should be coded using values 0/1.
family
is used to specify a family of link functions, used to model the relationship between the variables in numerator or denominator and exposure, respectively. Alternatives are "binomial","multinomial"
link
specifies the link function between the variables in numerator or denominator and exposure, respectively. For family="binomial" (fitted using glm) alternative
numerator
specifies the right-hand side of the model used to estimate the elements in the numerator of the inverse probability weights. When left unspecified, unstabilized weights, with a numerator of 1, are estimated.
denominator
specifies the right-hand side of the model used to estimate the elements in the denominator of the inverse probability weights. Typically includes the variables specified in the numerator model, as well as confounders for which to correct.
data
is a dataframe containing exposure and the variables used in numerator and denominator.
trim
is an optional trim percentile (0-0.5). When specified, both untrimmed and trimmed weights are returned.
...
are further arguments passed to the functions used to estimate the numerator and denominator models (see family and link).

Value

  • A list containing the following elements:
  • ipw.weightsis a vector containing inverse probability weights for each unit under observation. This vector is returned in the same order as the measurements contained in data, to facilitate merging.
  • weights.trimmedis a vector containing trimmed inverse probability weights for each unit under observation. This vector is only returned when trim is specified.
  • callis the original function call to ipwpoint.
  • num.modis the numerator model, only returned when numerator is specified.
  • den.modis the denominator model.

Missing values

The exposure variable and the variables used in numerator and denominator should not contain missing values.

Details

For each unit under observation, this function computes an inverse probability weight, which is the ratio of two probabilities:
  • the numerator contains the probability of the observed exposure level given observed values of stabilization factors (usually a set of baseline covariates). These probabilities are estimated using the model regressingexposureon the terms innumerator, using the link function indicated byfamilyandlink.
  • the denominator contains the probability of the observed exposure level given the observed values of a set of confounders, as well as the stabilization factors in the numerator. These probabilities are estimated using the model regressingexposureon the terms indenominator, using the link function indicated byfamilyandlink.
When the models from which the elements in the numerator and denominator are predicted are correctly specified, and there is no unmeasured confounding, weighting the observations by the inverse probability weights adjusts for confounding of the effect of the exposure of interest. On the weighted dataset a marginal structural model can then be fitted, quantifying the causal effect of the exposure on the outcome of interest. With numerator specified, stabilized weights are computed, otherwise unstabilized weighs with a numerator of 1 are computed. With a continuous exposure, using family="gaussian", weights are computed using the ratio of predicted densities. Therefore, for family="gaussian" only stabilized weights can be used, since unstabilized weights would have infinity variance.

References

Cole, S. R. & Hern�n, M. A. (2008). Constructing inverse probability weights for marginal structural models. American Journal of Epidemiology, 168(6), 656-664. Robins, J. M., Hern�n, M. A. & Brumback, B. A. (2000). Marginal structural models and causal inference in epidemiology. Epidemiology, 11, 550-560.

See Also

basdat, haartdat, healthdat, ipwplot, ipwpoint, ipwtm, timedat, tstartfun.

Examples

Run this code
#load IQ, income and health data.
data(healthdat)

#IQ is confounder for the effect of income on health score.
#Estimate inverse probability weights to correct for confounding.
#Exposure allocation model is linear regression model.
temp <- ipwpoint(
   exposure = income,
   family = "gaussian",
   numerator = ~ 1,
   denominator = ~ iq,
   data = healthdat)

#plot inverse probability weights
graphics.off()
ipwplot(weights = temp$ipw.weights, logscale = FALSE,
   main = "Stabilized weights", xlim = c(0, 8))

#Marginal structural model for the causal effect of income on health score
#corrected for confounding by IQ using inverse probability weighting.
summary(glm(health ~ income, data = healthdat, weights = temp$ipw.weights))

#Compute basic bootstrap confidence interval for income parameter.
boot.fun <- function(dat, index){
   coef(glm(
      formula = health ~ income,
      data = dat[index,],
      weights = ipwpoint(
            exposure = income,
            family = "gaussian",
            numerator = ~ 1,
            denominator = ~ iq,
            data = dat[index,])$ipw.weights))[2]
   }
bootres <- boot(healthdat, boot.fun, 499);bootres
boot.ci(bootres, type = "basic")

Run the code above in your browser using DataLab