R/params.R
, R/params_lm.R
, R/params_mlogit.R
, and 3 more
create_params.Rd
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.
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,
...
)
A statistical model to randomly sample parameters from.
Currently unused.
Number of random observations to draw. Not used if uncertainty = "none"
.
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.
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.
Logical indicating whether error messages should be suppressed. Passed to
the silent
argument of try()
.
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
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.
# 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)
#> (Intercept) female
#> [1,] 31262.29 882.5941
#> [2,] 32447.73 1905.9169
#> [3,] 28861.79 4782.5384
#> [4,] 28628.35 7038.5227
#> [5,] 30309.50 3072.4469
head(params_lm$sigma)
#> [1] 10311.3 10311.3 10311.3 10311.3 10311.3
# 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)
#> [1] "weibull.quiet"
head(params_surv_wei$coefs)
#> $shape
#> (Intercept)
#> [1,] -0.1721055
#> [2,] -0.1228815
#> [3,] 0.2868667
#> [4,] 0.3138654
#> [5,] 0.3201734
#>
#> $scale
#> (Intercept)
#> [1,] 7.059577
#> [2,] 7.261128
#> [3,] 7.390533
#> [4,] 6.926668
#> [5,] 6.719093
#>