Learn R Programming

hesim (version 0.5.5)

create_params: Create a parameter object from a fitted model

Description

create_params is a generic function for creating an object containing parameters from a fitted statistical model. If uncertainty != "none", then random samples from suitable probability distributions are returned.

Usage

create_params(object, ...)

# S3 method for lm create_params(object, n = 1000, uncertainty = c("normal", "none"), ...)

# S3 method for multinom create_params(object, n = 1000, uncertainty = c("normal", "none"), ...)

# S3 method for multinom_list create_params(object, n = 1000, uncertainty = c("normal", "none"), ...)

# S3 method for flexsurvreg create_params(object, n = 1000, uncertainty = c("normal", "none"), ...)

# S3 method for flexsurvreg_list create_params(object, n = 1000, uncertainty = c("normal", "none"), ...)

# S3 method for partsurvfit create_params( object, n = 1000, uncertainty = c("normal", "bootstrap", "none"), max_errors = 0, silent = FALSE, ... )

Value

An object prefixed by params_. Mapping between create_params

and the classes of the returned objects are:

  • create_params.lm -> params_lm

  • create_params.multinom -> params_mlogit

  • create_params.multinom_list -> params_mlogit_list

  • create_params.flexsurvreg -> params_surv

  • create_params.flexsurvreg_list -> params_surv_list

  • create_params.partsurvfit -> params_surv_list

Arguments

object

A statistical model to randomly sample parameters from.

...

Currently unused.

n

Number of random observations to draw. Not used if uncertainty = "none".

uncertainty

Method determining how parameter uncertainty should be handled. If "normal", then parameters are randomly drawn from their multivariate normal distribution. If "bootstrap", then parameters are bootstrapped using bootstrap. If "none", then only point estimates are returned.

max_errors

Maximum number of errors that are allowed when fitting statistical models during the bootstrap procedure. This argument may be useful if, for instance, the model fails to converge during some bootstrap replications. Default is 0.

silent

Logical indicating whether error messages should be suppressed. Passed to the silent argument of try().

See Also

These methods are typically used alongside create_input_mats() to create model objects as a function of input data and a fitted statistical model. For instance, create_PsmCurves() creates the survival model for a partitioned survival model, create_IndivCtstmTrans() creates the transition model for an individual continuous time state transition model, create_CohortDtstmTrans() creates the transition model for a cohort discrete time state transition model, and create_StateVals() creates a health state values model.

Examples

Run this code
# create_params.lm
fit <- lm(costs ~ female, data = psm4_exdata$costs$medical)
n <- 5
params_lm <- create_params(fit, n = n)
head(params_lm$coefs)
head(params_lm$sigma)

# create_params.flexsurvreg
library("flexsurv")
fit <- flexsurvreg(formula = Surv(futime, fustat) ~ 1, 
                   data = ovarian, dist = "weibull")
n <- 5
params_surv_wei <- create_params(fit, n = n)
print(params_surv_wei$dist)
head(params_surv_wei$coefs)

Run the code above in your browser using DataLab