create_params {hesim}R Documentation

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

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

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

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

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

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

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().

Value

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

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

# 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)

[Package hesim version 0.5.4 Index]