Learn R Programming

hesim (version 0.5.0)

input_mats: Input matrices for a statistical model

Description

Create an object of class input_mats, which contains inputs matrices for simulating a statistical model. Consists of (i) input matrices, X, and (ii) metadata used to index each matrix in X. More details are provided under "Details" below.

Usage

input_mats(X, ...)

Arguments

X

A list of input matrices for predicting the values of each parameter in a statistical model. May also be a list of lists of input matrices when a list of separate models is fit (e.g., with flexsurvreg_list()).

...

Arguments to pass to id_attributes().

Details

Each row of each matrix X is an input vector, \(x_{hik}\), where \(h\) denotes a health-related index, \(i\) indexes a patient, and \(k\) is a treatment strategy. A health-related index is either a health state (e.g., state_id or a transition between health states (e.g., transition_id). In some cases, the health-related index \(h\) can be suppressed and separate models can be fit for each health index. This is, for instance, the case in a partitioned survival model where separate models are fit for each survival endpoint.

The rows of the matrices in X must be sorted in a manner consistent with the ID variables as described in id_attributes().

See Also

create_input_mats()

Examples

Run this code
# NOT RUN {
strategies <- data.frame(strategy_id = c(1, 2))
patients <- data.frame(patient_id = seq(1, 3), 
                          age = c(45, 47, 60),
                          female = c(1, 0, 0),
                          group = factor(c("Good", "Medium", "Poor")))
hesim_dat <- hesim_data(strategies = strategies,
                        patients = patients)

dat <- expand(hesim_dat, by = c("strategies", "patients"))
input_mats <- input_mats(X = list(mu = model.matrix(~ age, dat)),
                         strategy_id = dat$strategy_id,
                         n_strategies = length(unique(dat$strategy_id)),
                         patient_id = dat$patient_id,
                        n_patients = length(unique(dat$patient_id)))
print(input_mats)
# }

Run the code above in your browser using DataLab