Learn R Programming

microsimulation (version 1.4.4)

simulate.survreg: Simulate event times from a survreg object

Description

Simulate event times from a survreg object

Usage

# S3 method for survreg
simulate(object, nsim = 1, seed = NULL, newdata, t0 = NULL, ...)

Value

vector of event times with nsim repeats per row in newdata

Arguments

object

survreg object

nsim

number of simulations per row in newdata

seed

random number seed

newdata

data-frame for defining the covariates for the simulations. Required.

t0

delayed entry time. Defaults to NULL (which assumes that t0=0)

...

other arguments (not currently used)

Examples

Run this code
library(survival)
fit <- survreg(Surv(time, status) ~ ph.ecog + age + sex + strata(sex),
               data = lung)
nd = transform(expand.grid(ph.ecog=0:1, sex=1:2), age=60)
simulate(fit, seed=1002, newdata=nd)
simulate(fit, seed=1002, newdata=nd, t0=500)

Run the code above in your browser using DataLab