View source: R/simulate_flexsurvreg.R
simulate.flexsurvreg | R Documentation |
Simulate censored time-to-event data from a fitted flexsurvreg model
## S3 method for class 'flexsurvreg'
simulate(
object,
nsim = 1,
seed = NULL,
newdata = NULL,
start = NULL,
censtime = NULL,
tidy = FALSE,
...
)
object |
Object returned by |
nsim |
Number of simulations per row in |
seed |
Random number seed. This is returned with the result of this
function, as described in |
newdata |
Data frame defining alternative sets of covariate values to simulate with. If omitted, this defaults to the data originally used to fit the model. |
start |
Optional left-truncation time or times. The returned
survival, hazard or cumulative hazard will be conditioned on survival up to
this time. Predicted times returned with A vector of the same length as |
censtime |
A right-censoring time, or vector of times matching the rows
of |
tidy |
If If In either case, the simulated time and indicator for whether the time is an event time (rather than a time of right-censoring) are returned in different columns. |
... |
Other arguments (not currently used). |
A data frame, with format determined by whether tidy
was specified.
fit <- flexsurvreg(formula = Surv(futime, fustat) ~ rx, data = ovarian, dist="weibull")
fit2 <- flexsurvspline(formula = Surv(futime, fustat) ~ rx, data = ovarian, k=3)
nd = data.frame(rx=1:2)
simulate(fit, seed=1002, newdata=nd)
simulate(fit, seed=1002, newdata=nd, start=500)
simulate(fit2, nsim=3, seed=1002, newdata=nd)
simulate(fit2, nsim=3, seed=1002, newdata=nd, start=c(500,1000))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.