*! version 1.0.0

Title

survsim -- Simulate survival data from a parametric distribution,
a user-defined distribution, from a fitted merlin model, from a cause-specific
hazards competing risks model, or from a general multi-state model

Syntax

Syntax for simulating survival times from a fitted merlin survival model:

survsim newvarname1 newvarname2 , model(name) maxtime(#|varname)

Options

model(name) the estimates store name of the fitted merlin model; see details

maxtime(#|varname) right censoring time(s); either a common number or a varname

Description

survsim simulates survival data from a parametric distribution, a user-defined distribution, from a fitted
merlin model, from a cause-specific hazards competing risks model, or from a Markov multi-state model.
This help file centres on simulating from a fitted merlin model.

Survival times can be simulated from the estimated model, using the variables in your current dataset. The variables can simply
be altered, to provide a flexible framework to simulate using the estimated parameter vector.

newvarname1 specifies the new variable name to contain the generated survival times. newvarname2 specifies the
new variable name to contain the generated event indicator.

Options

model(name) specifies the name of the estimates store object containing the estimates of the model
fitted. The survival must be estimated using the merlin command. For example,

. merlin (_t trt , family(weibull, failure(_d)))

. estimates store m1

. survsim stime died, model(m1) maxtime(10)

survsim will simulate from the fitted model, using covariate values that are in your current dataset.

maxtime(#|varname) specifies the right censoring time(s). Either a common maximum follow-up time # can be
specified for all observations, or observation specific censoring times can be specified by using a varname.

Remarks

Always set seed, to ensure reproducibility.

Examples

Simulate from a fitted Weibull survival model:

. webuse brcancer

. stset rectime, failure(censrec) scale(365)

. merlin (_t hormon , family(weibull, failure(_d)))

. estimates store m1

. survsim stime died, model(m1) maxtime(10)

Simulate from a fitted Royston-Parmar spline-based survival model:

. webuse brcancer

. stset rectime, failure(censrec) scale(365)

. merlin (_t hormon , family(rp, failure(_d) df(3)))

. estimates store m2

. survsim stime died, model(m2) maxtime(10)

Author

Michael J. Crowther

Red Door Analytics

E-mail: michael@reddooranalytics.se

Please report any errors you may find.

References

Bender R, Augustin T and Blettner M. Generating survival times to simulate Cox proportional hazards models. Statistics in Medicine 2005;24:1713-1723.

Crowther MJ and Lambert PC. Simulating complex survival data. The Stata Journal 2012;12(4):674-687.

Crowther MJ and Lambert PC. Simulating biologically plausible complex survival data. Statistics in Medicine 2013;32(23):4118-4134.

Jann, B. 2005. moremata: Stata module (Mata) to provide various functions. Available from http://ideas.repec.org/c/boc/bocode/s455001.html.