Learn R Programming

rstpm2 (version 1.6.5)

simulate-methods: Simulate values from an stpm2 or pstpm2 fit

Description

Given an stpm2 fit and a data-frame of new data, return simulated values

Usage

# S4 method for stpm2
simulate(object, nsim=1,
        seed=NULL, newdata=NULL,
        lower=1e-06, upper=1e+05, start=NULL, ...)
    # S4 method for pstpm2
simulate(object, nsim=1,
        seed=NULL, newdata=NULL,
        lower=1e-06, upper=1e+05, start=NULL, ...)

Methods

object = "stpm2"

an stpm2 fit

Arguments

object

an stpm2 or pstpm2 object

nsim

number of simulations per row in newdata

seed

optional random number seed

newdata

list of new data. If not specified, then defaults to object@data

lower

smallest possible time

upper

largest possible time

start

left truncated entry time (assumed to be zero if NULL)

...

additional arguments (for generic compatibility)

Examples

Run this code
set.seed(1002)
fit1 <- gsm(Surv(rectime,censrec==1)~hormon,data=brcancer,df=3)
simulate(fit1, nsim=10, newdata=data.frame(hormon=1))
simulate(fit1, newdata=data.frame(hormon=0:1))

Run the code above in your browser using DataLab