Simulate outcomes from an N-state partitioned survival model.
An R6::R6Class object.
survival_models
The survival models used to predict survival curves. Must be an object of class PsmCurves.
utility_model
The model for health state utility. Must be an object of class StateVals.
cost_models
The models used to predict costs by health state. Must be a list of objects of class StateVals, where each element of the list represents a different cost category.
n_states
Number of states in the partitioned survival model.
t_
A numeric vector of times at which survival curves were predicted. Determined
by the argument t
in $sim_curves()
.
survival_
Survival curves simulated using sim_curves()
.
stateprobs_
An object of class stateprobs simulated using $sim_stateprobs()
.
qalys_
An object of class qalys simulated using $sim_qalys()
.
costs_
An object of class costs simulated using $sim_costs()
.
new()
Create a new Psm
object.
Psm$new(survival_models, utility_model = NULL, cost_models = NULL)
survival_models
The survival_models
field.
utility_model
The utility_model
field.
cost_models
The cost_models
field.
n_states
is set equal to the number of survival models plus one.
A new Psm
object.
sim_survival()
Simulate survival curves as a function of time using PsmCurves$sim_survival()
.
Psm$sim_survival(t)
t
A numeric vector of times. The first element must be 0
.
An instance of self
with simulated output from PsmCurves$sim_survival()
stored in stateprobs_
.
sim_stateprobs()
Simulate health state probabilities from survival_
using a partitioned
survival analysis.
Psm$sim_stateprobs()
An instance of self
with simulated output of class stateprobs
stored in stateprobs_
.
sim_qalys()
Simulate quality-adjusted life-years (QALYs) as a function of stateprobs_
and
utility_model
. See vignette("expected-values")
for details.
Psm$sim_qalys( dr = 0.03, integrate_method = c("trapz", "riemann_left", "riemann_right"), lys = FALSE )
dr
Discount rate.
integrate_method
Method used to integrate state values when computing (QALYs).
lys
If TRUE
, then life-years are simulated in addition to QALYs.
An instance of self
with simulated output of class qalys stored
in qalys_
.
sim_costs()
Simulate costs as a function of stateprobs_
and cost_models
.
See vignette("expected-values")
for details.
Psm$sim_costs( dr = 0.03, integrate_method = c("trapz", "riemann_left", "riemann_right") )
dr
Discount rate.
integrate_method
Method used to integrate state values when computing costs.
An instance of self
with simulated output of class costs stored
in costs_
.
summarize()
Summarize costs and QALYs so that cost-effectiveness analysis can be performed.
See summarize_ce()
.
Psm$summarize()
clone()
The objects of this class are cloneable with this method.
Psm$clone(deep = FALSE)
deep
Whether to make a deep clone.
# NOT RUN {
library("flexsurv")
# Simulation data
strategies <- data.frame(strategy_id = c(1, 2, 3))
patients <- data.frame(patient_id = seq(1, 3),
age = c(45, 50, 60),
female = c(0, 0, 1))
states <- data.frame(state_id = seq(1, 3),
state_name = paste0("state", seq(1, 3)))
hesim_dat <- hesim_data(strategies = strategies,
patients = patients,
states = states)
n_samples <- 3
# Survival models
surv_est_data <- psm4_exdata$survival
fit1 <- flexsurv::flexsurvreg(Surv(endpoint1_time, endpoint1_status) ~ age,
data = surv_est_data, dist = "exp")
fit2 <- flexsurv::flexsurvreg(Surv(endpoint2_time, endpoint2_status) ~ age,
data = surv_est_data, dist = "exp")
fit3 <- flexsurv::flexsurvreg(Surv(endpoint3_time, endpoint3_status) ~ age,
data = surv_est_data, dist = "exp")
fits <- flexsurvreg_list(fit1, fit2, fit3)
surv_input_data <- expand(hesim_dat, by = c("strategies", "patients"))
psm_curves <- create_PsmCurves(fits, input_data = surv_input_data,
bootstrap = TRUE, est_data = surv_est_data,
n = n_samples)
# Cost model(s)
cost_input_data <- expand(hesim_dat, by = c("strategies", "patients", "states"))
fit_costs_medical <- stats::lm(costs ~ female + state_name,
data = psm4_exdata$costs$medical)
psm_costs_medical <- create_StateVals(fit_costs_medical,
input_data = cost_input_data,
n = n_samples)
# Utility model
utility_tbl <- stateval_tbl(tbl = data.frame(state_id = states$state_id,
min = psm4_exdata$utility$lower,
max = psm4_exdata$utility$upper),
dist = "unif",
hesim_data = hesim_dat)
psm_utility <- create_StateVals(utility_tbl, n = n_samples)
# Partitioned survival decision model
psm <- Psm$new(survival_models = psm_curves,
utility_model = psm_utility,
cost_models = list(medical = psm_costs_medical))
psm$sim_survival(t = seq(0, 5, .05))
psm$sim_stateprobs()
psm$sim_costs(dr = .03)
head(psm$costs_)
head(psm$sim_qalys(dr = .03)$qalys_)
# }
Run the code above in your browser using DataLab