Learn R Programming

hesim (version 0.5.0)

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 flexsurvreg 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_list create_params(object, n = 1000, uncertainty = c("normal", "none"), ...)

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

Arguments

object

A statistical model to randomly sample parameters from.

...

Further arguments passed to or from other methods. Only used when object is of class partsurvfit, in which case the arguments are passed to bootstrap.partsurvfit().

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.

Value

An object prefixed by params_. Mapping between create_params and the classes of the returned objects are:

Examples

Run this code
# NOT RUN {
# create_params.lm
fit <- stats::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 <- flexsurv::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