
Transportability analysis using IOPW
transportIP.Rd
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 frompropensityScoreModel
if provided; otherwise it will remainNULL
. Note that when using custom weights,treatment
should be provided so thatsummary.transportIP
andplot.transportIP
works.- participation
String indicating name of participation variable. If
NULL
, it will be auto-detected fromparticipationModel
if provided; otherwise it will remainNULL
. Note that when using custom weights,participation
should be provided so thatsummary.transportIP
andplot.transportIP
works.- response
String indicating name of response variable. If
NULL
, it will be auto-detected formmsmFormula
.- family
Either a
family
function as used forglm
, or one ofc("polr", "coxph", "survreg")
.- method
Link function used for
polr
, one ofc("logistic", "probit", "loglog", "cloglog", "cauchit")
.- exOpt
A list with components
propensity
,participation
andfinal
. Each component specifies whether weights should be trimmed or truncated. Use the functionstrim
andtrunc
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 classglm
,survreg
andcoxph
, with the correct variance estimators appropriately replaced. If of classglm
, it will have an extravar
component containing the correct variance estimates.propensityScoreModel
: Model of treatment assignment,NULL
if not provided and custom propensity weights are usedparticipationModel
: Model of study participation,NULL
if not provided and custom propensity weights are usedpropensityWeights
: Propensity weights usedparticipationWeights
: Participation weights usedfinalWeights
: Weights used to fit MSMcustomPropensity
: Boolean indicating whether custom propensity weights are usedcustomParticipation
: Boolean indicating whether custom participation weights are usedtreatment
: String indicating variable name of treatmentparticipation
: String indicating variable name of participationresponse
: String indicating variable name of responsedata
: Data provided indata
argument. Either a list containing study data and target data or a data frame containing both.exOpt
: ProvidedexOpt
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.