Create data containing the treatment variable and all other covariates. This data is required to build the design (i.e., x) matrix in either a propensity score model or a covariate adjusted outcomes model. Only variables required by the model are kept.

make_xdata(
  formula,
  data,
  imputation = c("multi", "none"),
  missing_dummy = FALSE,
  id = "patient_id",
  n_impute = 5
)

Arguments

formula

A formula for the propensity score with the treatment variable to the left of the ~ operator and the model terms on the right.

data

The dataset containing the variables specified in formula.

imputation

Imputation strategy to use. Use "multi" to multiply impute data with multi_impute(). No imputation is performed when the "none" is chosen.

missing_dummy

Whether to create dummy variables for variables when observations are missing.

id

The variable uniquely identifying each patient.

n_impute

Number of imnputations to perform. Only used when imputation = "multi".

Value

An object of class model_data inheriting from dplyr::tibble. It contains all variables used in formula and, if multiple imputation is used, an additional column named imp indicating the imputation number.