Learn R Programming

flexsurv (version 2.3.2)

normboot.flexsurvreg: Simulate from the asymptotic normal distribution of parameter estimates.

Description

Produce a matrix of alternative parameter estimates under sampling uncertainty, at covariate values supplied by the user. Used by summary.flexsurvreg for obtaining confidence intervals around functions of parameters.

Usage

normboot.flexsurvreg(
  x,
  B,
  newdata = NULL,
  X = NULL,
  transform = FALSE,
  raw = FALSE,
  tidy = FALSE,
  rawsim = NULL
)

Value

If newdata includes only one covariate combination, a matrix will be returned with B rows, and one column for each named parameter of the survival distribution.

If more than one covariate combination is requested (e.g. newdata is a data frame with more than one row), then a list of matrices will be returned, one for each covariate combination.

Arguments

x

A fitted model from flexsurvreg (or flexsurvspline).

B

Number of samples.

newdata

Data frame or list containing the covariate values to evaluate the parameters at. If there are covariates in the model, at least one of newdata or X must be supplied, unless raw=TRUE.

X

Alternative (less convenient) format for covariate values: a matrix with one row, with one column for each covariate or factor contrast. Formed from all the "model matrices", one for each named parameter of the distribution, with intercepts excluded, cbinded together.

transform

TRUE if the results should be transformed to the real-line scale, typically by log if the parameter is defined as positive. The default FALSE returns parameters on the natural scale.

raw

Return samples of the baseline parameters and the covariate effects, rather than the default of adjusting the baseline parameters for covariates.

tidy

If FALSE (the default) then a list is returned. If TRUE a data frame is returned, consisting of the list elements rbinded together, with integer variables labelling the covariate number and simulation replicate number.

rawsim

allows input of raw samples from a previous run of normboot.flexsurvreg. This is useful if running normboot.flexsurvreg multiple time on the same dataset but with counterfactual contrasts, e.g. treat =0 vs. treat =1. Used in standsurv.flexsurvreg.

References

Mandel, M. (2013). "Simulation based confidence intervals for functions with complicated derivatives." The American Statistician (in press).

See Also

summary.flexsurvreg

Examples

Run this code

    fite <- flexsurvreg(Surv(futime, fustat) ~ age, data = ovarian, dist="exp")
    normboot.flexsurvreg(fite, B=10, newdata=list(age=50))
    normboot.flexsurvreg(fite, B=10, X=matrix(50,nrow=1))
    normboot.flexsurvreg(fite, B=10, newdata=list(age=0))  ## closer to...
    fite$res

Run the code above in your browser using DataLab