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.

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

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.

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.

References

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

See also

Author

C. H. Jackson chris.jackson@mrc-bsu.cam.ac.uk

Examples

fite <- flexsurvreg(Surv(futime, fustat) ~ age, data = ovarian, dist="exp") normboot.flexsurvreg(fite, B=10, newdata=list(age=50))
#> rate #> [1,] 0.0001332482 #> [2,] 0.0002711888 #> [3,] 0.0003699895 #> [4,] 0.0002547905 #> [5,] 0.0005460259 #> [6,] 0.0002298601 #> [7,] 0.0004888441 #> [8,] 0.0001546735 #> [9,] 0.0005137610 #> [10,] 0.0004137849 #> attr(,"X") #> age #> 1 50 #> attr(,"X")attr(,"newdata") #> age #> 1 50
normboot.flexsurvreg(fite, B=10, X=matrix(50,nrow=1))
#> rate #> [1,] 0.0003828207 #> [2,] 0.0007732248 #> [3,] 0.0002974008 #> [4,] 0.0004209704 #> [5,] 0.0003696917 #> [6,] 0.0003892503 #> [7,] 0.0002301911 #> [8,] 0.0004544350 #> [9,] 0.0002247175 #> [10,] 0.0002689401 #> attr(,"X") #> [,1] #> [1,] 50
normboot.flexsurvreg(fite, B=10, newdata=list(age=0)) ## closer to...
#> rate #> [1,] 9.166549e-06 #> [2,] 7.990797e-06 #> [3,] 3.310913e-06 #> [4,] 5.787134e-08 #> [5,] 2.842888e-06 #> [6,] 6.955214e-07 #> [7,] 6.405365e-07 #> [8,] 6.179835e-06 #> [9,] 2.165180e-06 #> [10,] 2.561075e-07 #> attr(,"X") #> age #> 1 0 #> attr(,"X")attr(,"newdata") #> age #> 1 0
fite$res
#> est L95% U95% se #> rate 8.883706e-07 1.444100e-08 5.465012e-05 1.867116e-06 #> age 1.185227e-01 5.216657e-02 1.848788e-01 3.385579e-02