Skip to contents

An outcome model needs to be fitted using the study data to perform transportability analysis using g-computation. However, glm and functions in survival typically contain the data used to fit the model in their respective result objects. This function provides the option to remove most components containing the data from these result objects to comply with data sharing regulations. The party with sole access to the study data may use only this function and provide the results object (possibly in a .rds file) to others who request it.

Note that for time-to-event outcomes, survreg should used for the outcome model over coxph because the latter is not meant to produce predicted survival times. The coxph option is provided, but we warn that the computation time might be prohibitive.

Usage

transportGCPreparedModel(
  outcomeModel,
  response = NULL,
  responseLevels = NULL,
  treatment,
  treatmentLevels = NULL,
  family = stats::gaussian,
  method = c("logistic", "probit", "loglog", "cloglog", "cauchit"),
  studyData = NULL,
  wipe = T,
  formula = NULL
)

Arguments

outcomeModel

Either a formula or a glm, survreg, coxph, or polr object representing the outcome model. Please set model = T if providing a fitted model object.

response

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

responseLevels

For ordinal responses, vector of strings indicating levels of response variable in the study data. If NULL and polr is used, it will be auto-detected using response and studyData.

treatment

String indicating name of treatment variable. This argument is required.

treatmentLevels

Vector of strings indicating levels of treatment variable in the study data. If NULL, it will be auto-detected using treatment and studyData.

family

Either a family function as used for glm, or one of c("coxph", "survreg"). Only required if outcomeModel is a formula.

method

Link function used for polr, one of c("logistic", "probit", "loglog", "cloglog", "cauchit"). Only required if outcomeModel is a formula and polr is used.

studyData

Data frame of the study data.

wipe

Logical indicating whether original study data should be wiped from outcome model-fitting object.

formula

The formula used to fit outcomeModel, if outcomeModel is provided as a fitted model object. This is necessary to provide only when using coxph, survreg and polr because these objects do not have the formula components.

Value

A transportGCPreparedModel object containing the following components:

  • outcomeModel: The fitted outcome model with all components containing the data used to fit the model removed

  • response: String indicating name of response variable

  • treatment: String indicating name of treatment variable

  • treatmentLevels: Vector of strings indicating levels of treatment variable

  • family: The family argument provided

  • wipe: The wipe argument provided

  • formula: The formula used to fit the outcome model