Skip to contents

Bundles data, column mappings, and a method object into an analysis object ready to be passed to run_analysis.

Usage

setup_analysis_primary(
  data,
  trial_status_col_name,
  treatment_col_name,
  outcome_col_name,
  covariates_col_name,
  method_weighting_obj,
  alpha = 0.05
)

Arguments

data

A data frame containing all subject-level data. It must have trial treated patients and trial controls. It must also have external controls, unless the method is ec_ipw(weight = 0).

trial_status_col_name

Name of the trial status column: 1 for trial patients, 0 for external controls. Must be numeric or logical.

treatment_col_name

Name of the treatment column: 1 for treated, 0 for control. Must be numeric or logical, not a factor. External controls must have 0.

outcome_col_name

Character vector of outcome column names. The columns must have no missing values.

covariates_col_name

Character vector of covariate column names. The columns must have no missing values. Outcome and covariate columns cannot be named S or A, or be the trial-status or treatment column.

method_weighting_obj

A method object created by ec_ipw or ec_aipw.

alpha

Significance level, more than 0 and less than 1 (default 0.05).

Value

An object of class analysis_primary_obj, to be passed to run_analysis.

Details

Available primary methods:

ec_ipw

Inverse probability weighting.

ec_aipw

Augmented inverse probability weighting (doubly robust).

Examples

method <- ec_ipw(ps_formula = "S ~ x1 + x2 + x3 + x4 + x5")
setup_analysis_primary(
  data = SyntheticData,
  trial_status_col_name = "S",
  treatment_col_name = "A",
  outcome_col_name = c("y1", "y2"),
  covariates_col_name = c("x1", "x2", "x3", "x4", "x5"),
  method_weighting_obj = method
)
#> <analysis_primary_obj>
#>   Observations: 300 
#>   Trial status: S 
#>   Treatment: A 
#>   Outcomes: y1, y2 
#>   Covariates: x1, x2, x3, x4, x5 
#>   Method: EC-IPW 
#>   Alpha: 0.05