simcoxph: Simulate survival data and fit models

View source: R/simfrail.R

simcoxphR Documentation

Simulate survival data and fit models

Description

Generates simulated clustered survival data by repeatedly generating data, using a shared frailty model, and fitting the models. Respective arguments are passed to genfrail and coxph, and the resulting parameter estimates are aggregated and summarized.

This function is similar to simfrail, except models are fitted using the coxph.

Usage

simcoxph(reps, genfrail.args, coxph.args, Lambda.times, cores = 0)

Arguments

reps

number of times to repeat the simulation

genfrail.args

list of arguments to pass to genfrail

coxph.args

list of arguments to pass to coxph

Lambda.times

vector of time points to obtain baseline hazard estimates at

cores

integer; if > 0, the number of cores to use; if < 0, the number of cores not to use; if 0, use all available cores

Value

A simcoxph object that is essentially a data.frame of the resulting parameter estimates. Each row is a single run, and columns are as follows.

seed

the seed used for the run

runtime

the time it took to fit the model

N

number of clusters

mean.K

average cluster size

cens

empirical censorship

beta

true regression coefficients

hat.beta

estimated regression coefficients

se.beta

standard error of each regression coefficient

theta

true frailty distribution parameters

hat.theta

estimated frailty distribution parameters

se.theta

standard error of each frailty distribution parameter (NA since coxph does not currently provide this.)

Lambda

true cumulative baseline hazard at each Lambda.times point

hat.Lambda

estimated cumulative baseline hazard at each Lambda.times point

se.Lambda

standard error at each Lambda.times point (NA since coxph does not currently provide this)

Author(s)

John. V Monaco, Malka Gorfine, Li Hsu

See Also

coxph, genfrail, simfrail

Examples

## Not run: 
sim <- simcoxph(reps=100,
                genfrail.args=alist(
                  N=50, K=2,
                  beta=c(log(2),log(3)), 
                  frailty="gamma", theta=2,
                  Lambda_0 = function(t, tau=4.6, C=0.01) (C*t)^tau), 
                coxph.args=alist(
                  formula=Surv(time, status) ~ Z1 + Z2 + cluster(family), 
                  frailty="gamma"),
                Lambda.times=1:120, cores = 0)

# Summarize the results
summary(sim)

# Plot the residuals
plot(sim, "residuals")

## End(Not run)

frailtySurv documentation built on Aug. 14, 2023, 1:06 a.m.