Learn R Programming

flexsurv (version 2.2)

simulate.flexsurvreg: Simulate datasets from a fitted flexsurvreg model

Description

Simulate datasets from a fitted flexsurvreg model

Usage

# S3 method for flexsurvreg
simulate(
  object,
  nsim = 1,
  seed = NULL,
  censtime = NULL,
  vectorised = TRUE,
  ...
)

Value

A data frame with nsim pairs of columns named

"sim_1","event_1" and so on, containing the simulated event or censoring times, and an indicator for whether the event was observed.

Arguments

object

Object returned by flexsurvreg

nsim

Number of datasets to simulate

seed

Random number seed. This is returned with the result of this function as described in simulate.

censtime

Right-censoring time, or vector of right-censoring times of the same size as the data used to fit the model.

vectorised

Set to FALSE if the fitted model uses distribution functions from a package other than flexsurv and those functions are not vectorised. By default, this function assumes that they are vectorised. Incomprehensible warnings may be printed and the simulation is not guaranteed to work if this assumption is wrong. Vectorising will generally make the simulation much faster.

...

Currently unused.