Learn R Programming

hesim (version 0.2.3)

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 point_estimate = FALSE, then random samples from the posterior distribution are returned.

Usage

create_params(object, ...)

# S3 method for lm create_params(object, n = 1000, point_estimate = FALSE, ...)

# S3 method for flexsurvreg create_params(object, n = 1000, point_estimate = FALSE, ...)

# S3 method for flexsurvreg_list create_params(object, n = 1000, point_estimate = FALSE, ...)

# S3 method for partsurvfit create_params( object, n = 1000, point_estimate = FALSE, bootstrap = TRUE, max_errors = 0, ... )

Arguments

object

A statistical model to randomly sample parameters from.

...

Further arguments passed to or from other methods. Currently unused.

n

Number of random observations to draw.

point_estimate

If TRUE, then the point estimates are returned and and no samples are drawn.

bootstrap

If bootstrap is FALSE or not specified, then n parameter sets are drawn by sampling from a multivariate normal distribution. If bootstrap is TRUE, then parameters are bootstrapped using bootstrap.

max_errors

Equivalent to the max_errors argument in bootstrap.

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.flexsurvreg -> params_surv

  • create_params.flexsurvreg_list -> params_surv_list

  • create_params.partsurvfit -> params_surv_list

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