Learn R Programming

hesim (version 0.2.3)

StateVals: Model for state values

Description

Simulate values (i.e., utility or costs) associated with health states in a partitioned survival or state transition model.

Usage

StateVals

Arguments

Format

R6Class object.

Fields

input_mats

Input matrices used to simulate state values by strategy, patient, and health state. Must be an object of class input_mats where each row in the matrix "X" is a unique strategy, patient, and health state. "X" must be sorted by strategy, patient, and health state.

params

An object of class params_lm, which contains the parameters for simulating state values.

Methods

new(input_mats, params)

Constructor for the class.

sim(t, type = c("predict", "random"))

Simulate state values with either predicted means or random samples by treatment strategy, patient, and health state.

  • t: A numeric vector of times. The first element must be 0.

  • type: "predict" for mean values or "random" for random samples.

check()

Input validation for class. Checks that fields are the correct type.

Examples

Run this code
# NOT RUN {
# Simulation data
dt_strategies <- data.frame(strategy_id = c(1, 2, 3))
dt_patients <- data.frame(patient_id = seq(1, 3),
                          age = c(45, 50, 60),
                          female = c(0, 0, 1))
dt_states <- data.frame(state_id =  seq(1, 3),
                           state_name = paste0("state", seq(1, 3)))
hesim_dat <- hesim_data(strategies = dt_strategies,
                              patients = dt_patients,
                              states = dt_states)

# Create StateVals object
fit_costs_medical <- stats::lm(costs ~ female + state_name, data = psm4_exdata$costs$medical)
dat <- expand(hesim_dat, by = c("strategies", "patients", "states"))
costs_medical <- create_StateVals(fit_costs_medical, input_data = dat, n = 5)

# Predict
head(costs_medical$sim(t = 5, type = "predict"))
# }

Run the code above in your browser using DataLab