simdat: Simulate component-wise censored data from an illness-death...

Description Usage Arguments Value Examples

View source: R/simdat.R

Description

This function simulates component-wise censored data from an irreversible or reversible illness-death model. The data is component-wise censored because illness status is intermittently observed at visits, while vital status (alive/dead) is fully observed until right censoring time. All individuals start alive and illness-free. Time from state entry to transition is simulated from a Weibull distribution with user-specified parameters, and the user specifies the visit process.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
simdat(
  n,
  scale12 = 1/8e-04,
  scale13 = 1/2e-04,
  scale23 = 1/0.0016,
  shape12 = 1,
  shape13 = 1,
  shape23 = 1,
  scale21 = NULL,
  shape21 = 1,
  vital.lfu = c(30.4 * 36, 30.4 * 48),
  dropout.rate = NULL,
  visit.schedule = 30.4 * c(6, 12, 18, 24, 30, 36, 42, 48),
  scatter.sd = 10,
  missing.rate = 0,
  visit.rate = NULL,
  renew.param = NULL,
  visit.postprog = 1,
  dependent.visit = NULL,
  seed = NULL
)

Arguments

n

sample size

scale12

The model has states 1, 2 and 3 representing illness free, alive with illness, and death. scale12 is the scale parameter for the Weibull distribution used to generate the time from entry in state 1 until transition to state 2. Default is 1/0.0008.

scale13

the scale parameter for the Weibull distribution used to generate the time from entry in state 1 until transition to state 3. Default is 1/0.0002.

scale23

the scale parameter for the Weibull distribution used to generate the time from entry in state 2 until transition to state 3. Default is 1/0.0016.

shape12

the shape parameter for the Weibull distribution used to generate the time from entry in state 1 until transition to state 2. Default is 1.

shape13

the shape parameter for the Weibull distribution used to generate the time from entry in state 1 until transition to state 3. Default is 1.

shape23

the shape parameter for the Weibull distribution used to generate the time from entry in state 2 until transition to state 3. Default is 1.

scale21

the scale parameter for the Weibull distribution used to generate the time from entry in state 2 until transition to state 1. Default is NULL, which implies an irreversible illness-death model. If scale21 is a positive number, the model is reversible, i.e. transitions from state 2 back to state 1 are allowed. This version of simdat can only handle reversible models where all scale parameters are equal to 1.

shape21

the shape parameter for the Weibull distribution used to generate the time from entry in state 2 until transition to state 1. Default is 1.

vital.lfu

defines the right censoring time or distribution. If vital.lfu is a vector, right censoring will occur according to a uniform distribution on the interval defined by the vector. If vital.lfu is a scalar, all observations will be right-censored at vital.lfu.

dropout.rate

controls dropout. Default is NULL, meaning no dropout; all right censoring arises via the vital.lfu parameter. If dropout.rate is non-null, individuals are subject to dropout according to an exponential distribution with rate dropout.rate.

visit.schedule

exactly one of visit.schedule, visit.rate and renew.param should be non-null If visit.schedule is non-null, visits will be generated according to a truncated normal distribution around each time in visit.schedule, truncated at 3 standard deviations.

scatter.sd

the standard deviation of the truncated normal distribution used to generate visit times

missing.rate

a vector of the same length as visit.schedule, which specifies the proportion of individuals with missing data at each time in visit.schedule. If missing.rate=0 (the default), no visits are missed.

visit.rate

exactly one of visit.schedule, visit.rate and renew.param should be non-null If visit.rate is non-null, visits will be generated according to a Poisson process with rate function visit.rate as a function of time, for example, visit.rate = function(t) .0001*t. For a constant visit rate, use visit.rate = function(x) sapply(x, function(t) C) where C is the constant rate.

renew.param

exactly one of visit.schedule, visit.rate and renew.param should be non-null If renew.param is non-null, visits will be generated according to a Weibull renewal visit process with shape and scale parameters equal to the first and second entries of renew.param.

visit.postprog

if equal to 0, visits stop once illness is observed at a visit. If equal to 1, visits continue as normal. The default is 1.

dependent.visit

If dependent.visit is non-null, an extra visit is added following an individual's first transition to state 2. If dependent.visit is a vector, the time from the transition to state 2 until the visit is generated from a truncated normal distribution with mean, standard deviation given by the first and second elements of the vector, respectively. If dependent.visit is a function, the time from the transition to state 2 until the visit will be generated according to a Poisson process with rate function visit.rate as a function of time.

seed

If seed is specified, set.seed(seed) will be run before generating the data, so the data can be reproduced.

Value

A dataframe with one row per individual with the variables dtime, dstatus, state2obs, laststate1, t1-tm, x1- xm, and nvisits. nvisits and m are the largest number of visits observed in the dataset. dstatus=1 represents death and dstatus=0 represents right censoring. ti and xi are the time and observed status at the i-th visit. xi=1 means alive and event free (state 1 in a multistate illness-death model), and xi=2 means alive with event. state2obs is the time of the first visit in state 2 (Inf if state 2 was never observed) and laststate1 is the time of the last observation in state 1 before state 2 was observed (0 if an individual was already in state 2 at the first visit). Visits are numbered by ascending time and missing visits do not get a placeholder. That is, if visit.schedule was 30, 60, 90 and 120 days, but the actual visit times for an individual were 45,40, NA, 125 because of normal scatter and missing visits, the entries t1-t4 will be 40, 45, 125, NA.

Examples

1
2
3
4
simdat(50, scale12=1/.0008, scale13=1/.0002, scale23=1/.0016,
vital.lfu=c(30.4*36, 30.4*48),
visit.schedule = 30.4*c(6, 12, 18, 24, 30, 36, 42, 48),
scatter.sd=10)

anneae/cwcens documentation built on Aug. 14, 2021, 7:20 p.m.