Skip to contents

Estimates the coefficients of a marginal structural model (MSM) using IP weighting in a generalizability or transportability analysis. In particular, the estimators should be unbiased for the coefficients in the superpopulation or the target population, respectively. Currently, this function only supports the case when there are exactly two treatment levels.

Usage

transportIP(
  msmFormula,
  propensityScoreModel = NULL,
  participationModel = NULL,
  propensityWeights = NULL,
  participationWeights = NULL,
  treatment = NULL,
  participation = NULL,
  response = NULL,
  family = stats::gaussian,
  method = c("logistic", "probit", "loglog", "cloglog", "cauchit"),
  exOpt = list(propensity = NULL, participation = NULL, final = NULL),
  data,
  transport = T,
  bootstrapNum = 500
)

Arguments

msmFormula

A formula for the MSM to be fitted, which usually includes the outcome, the treatment and any effect modifiers.

propensityScoreModel

Either a formula or a glm object representing the model for treatment assignment given covariates.

participationModel

Either a formula or a glm object representing the model for study participation given effect modifiers. If a formula and the "data" argument is a list, then add participation as the left-hand side of the formula.

propensityWeights

Vector of custom weights balancing covariates between treatments. Providing them will override the formula or model provided by propensityScoreModel. This vector should have as any entries as the sample size of the study data.

participationWeights

Vector of custom weights balancing effect modifiers between study and target populations. Providing them will override the formula or model provided by participationModel. This vector should have as any entries as the sample size of the study data.

treatment

String indicating name of treatment variable. If NULL, it will be auto-detected from propensityScoreModel if provided; otherwise it will remain NULL. Note that when using custom weights, treatment should be provided so that summary.transportIP and plot.transportIP works.

participation

String indicating name of participation variable. If NULL, it will be auto-detected from participationModel if provided; otherwise it will remain NULL. Note that when using custom weights, participation should be provided so that summary.transportIP and plot.transportIP works.

response

String indicating name of response variable. If NULL, it will be auto-detected form msmFormula.

family

Either a family function as used for glm, or one of c("polr", "coxph", "survreg").

method

Link function used for polr, one of c("logistic", "probit", "loglog", "cloglog", "cauchit").

exOpt

A list with components propensity, participation and final. Each component specifies whether weights should be trimmed or truncated. Use the functions trim and trunc to specify trimming/truncation. Note that only truncation is supported for final weights.

data

Either a single data frame containing merged study and target datasets, or a list containing the study dataset and the target dataset. Note that if participationModel is a glm object, the datasets would have been merged, so provide the merged dataset containing response, treatment, covariates controlled for in the original study, study participation and effect modifiers if this is the case. Make sure to code treatment and participation as 0-1 or TRUE-FALSE, with 1 and TRUE representing treatment group and study data, respectively.

transport

A boolean indicating whether a generalizability analysis (false) or a transportability analysis (true) is done.

bootstrapNum

Number of bootstrap datasets to simulate to obtain robust variance estimate.

Value

A transportIP object containing the following components:

  • msm: Raw model fit object for MSM of class glm, survreg and coxph, with the correct variance estimators appropriately replaced. If of class glm, it will have an extra var component containing the correct variance estimates.

  • propensityScoreModel: Model of treatment assignment, NULL if not provided and custom propensity weights are used

  • participationModel: Model of study participation, NULL if not provided and custom propensity weights are used

  • propensityWeights: Propensity weights used

  • participationWeights: Participation weights used

  • finalWeights: Weights used to fit MSM

  • customPropensity: Boolean indicating whether custom propensity weights are used

  • customParticipation: Boolean indicating whether custom participation weights are used

  • treatment: String indicating variable name of treatment

  • participation: String indicating variable name of participation

  • response: String indicating variable name of response

  • data: Data provided in data argument. Either a list containing study data and target data or a data frame containing both.

  • exOpt: Provided exOpt argument.

Details

The function fits models of treatment assignment and study participation in order to calculate the weights used to fit the MSM. For each of these models, if a formula is provided, logistic regression is used by default. If a glm object is provided, the function extracts the necessary weights from the object. The function does not support other weighting methods, so if they are required, provide custom weights.

The MSM-fitting functions do not provide correct standard errors as-is. Bootstrap is used to calculate robust bootstrap variance estimators of the parameter estimators. The function replaces the variance component in summary.glm, coxph and survreg with the robust variance estimators directly. This does not seem to behave well with predict.glm yet, but prediction is not of primary interest in a generalizability or transportability analysis.