Learn R Programming

hesim (version 0.5.5)

create_input_mats: Create input matrices

Description

create_input_mats() is a generic function for creating an object of class input_mats. Model matrices are constructed based on the variables specified in the model object and the data specified in input_data. create_input_mats() is not typically called by users directly, but is instead used by functions that create model objects (e.g., create_IndivCtstmTrans(), create_CohortDtstmTrans(), create_PsmCurves()).

Usage

create_input_mats(object, ...)

# S3 method for lm create_input_mats(object, input_data, ...)

# S3 method for flexsurvreg create_input_mats(object, input_data, ...)

# S3 method for flexsurvreg_list create_input_mats(object, input_data, ...)

# S3 method for partsurvfit create_input_mats(object, input_data, ...)

# S3 method for params_lm create_input_mats(object, input_data, ...)

# S3 method for params_surv create_input_mats(object, input_data, ...)

# S3 method for params_surv_list create_input_mats(object, input_data, ...)

# S3 method for multinom create_input_mats(object, input_data, ...)

# S3 method for multinom_list create_input_mats(object, input_data, ...)

# S3 method for params_mlogit_list create_input_mats(object, input_data, ...)

Value

An object of class input_mats.

Arguments

object

An object of the appropriate class.

...

Further arguments passed to model.matrix().

input_data

An object of class expanded_hesim_data returned by expand.hesim_data(). It is used to look for the variables needed to create an input matrix for use in a statistical models and the ID variables for indexing rows in the input matrix.

See Also

input_mats()

Examples

Run this code
library("flexsurv")

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")))
states <- data.frame(state_id =  seq(1, 3),
                     state_name = factor(paste0("state", seq(1, 3))))
hesim_dat <- hesim_data(strategies = strategies,
                        patients = patients,
                        states = states)

# Class "lm"
input_data <- expand(hesim_dat, by = c("strategies", "patients", "states"))
medcost_fit <- lm(costs ~ female + state_name, psm4_exdata$costs$medical)
input_mats <- create_input_mats(medcost_fit, input_data)
input_mats

# Class "flexsurvreg"
input_data <- expand(hesim_dat, by = c("strategies", "patients"))
fit_wei <- flexsurvreg(formula = Surv(futime, fustat) ~ 1,
                       data = ovarian, dist = "weibull")
input_mats <- create_input_mats(fit_wei, input_data)
input_mats

Run the code above in your browser using DataLab