This version of the permutational algorithm generates a dataset in which event and censoring times are conditional on an user-specified list of covariates, some or all of which are time-dependent. Event times and censoring times also follow user-specified distributions.

Package: | PermAlgo |

Type: | Package |

Version: | 1.0 |

Date: | 2010-08-24 |

License: | GPL-2 |

LazyLoad: | yes |

The package contains one function avialable to the user, `permalgorithm`

. The gist of the algorithm is to perform a one-to-one matching of `n`

observed times with `n`

independently generated vectors of covariates values. The matching is performed based on a permutation probability law derived from the partial likelihood of Cox's Proportional Hazards (PH) model.

Marie-Pierre Sylvestre, Thad Evans, Todd MacKenzie, Michal Abrahamowicz

Maintainer: Marie-Pierre Sylvestre <marie-pierre.sylvestre.chum@ssss.gouv.qc.ca>

This algorithm is an extension of the permutational algorithm first introduced by Abrahamowicz, MacKenzie and Esdaile, and described in details by MacKenzie and Abrahamowicz. The current version of the permutational algorithm is a flexible tool to generate event and censoring times that follow user-specified distributions and that are conditional on user-specified covariates. It has been validated through simulations in Sylvestre and Abrahamowicz. Please reference the manuscript by Sylvestre and Abrahamowicz cited below if the results of this program are used in any published material.

Sylvestre M.-P., Abrahamowicz M. (2008) Comparison of algorithms to generate
event times conditional on time-dependent covariates. *Statistics in
Medicine* **27(14)**:2618–34.

Abrahamowicz M., MacKenzie T., Esdaile J.M. (1996) Time-dependent hazard ratio:
modelling and hypothesis testing with application in lupus nephritis. *JASA*
**91**:1432–9.

MacKenzie T., Abrahamowicz M. (2002) Marginal and hazard ratio specific random
data
generation: Applications to semi-parametric bootstrapping. *Statistics
and Computing* **12(3)**:245–252.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | ```
# Example - Generating adverse event conditional on use
# of prescription drugs
# Prepare the matrice of covariate (Xmat)
# Here we simulate daily exposures to 2 prescription drugs over a
# year. Drug prescriptions can start any day of follow-up, and their
# duration is a multiple of 7 days. There can be multiple prescriptions
# for each individuals over the year and interuptions of drug use in
# between.
# Additionaly, there is a time-independant binary covarite (sex).
n=500 # subjects
m=365 # days
# Generate the matrix of three covariate, in a 'long' format.
Xmat=matrix(ncol=3, nrow=n*m)
# time-independant binary covariate
Xmat[,1] <- rep(rbinom(n, 1, 0.3), each=m)
# Function to generate an individual time-dependent exposure history
# e.g. generate prescriptions of different durations and doses.
TDhist <- function(m){
start <- round(runif(1,1,m),0) # individual start date
duration <- 7 + 7*rpois(1,3) # in weeks
dose <- round(runif(1,0,10),1)
vec <- c(rep(0, start-1), rep(dose, duration))
while (length(vec)<=m){
intermission <- 21 + 7*rpois(1,3) # in weeks
duration <- 7 + 7*rpois(1,3) # in weeks
dose <- round(runif(1,0,10),1)
vec <- append(vec, c(rep(0, intermission), rep(dose, duration)))}
return(vec[1:m])}
# create TD var
Xmat[,2] <- do.call("c", lapply(1:n, function(i) TDhist(m)))
Xmat[,3] <- do.call("c", lapply(1:n, function(i) TDhist(m)))
# genereate vectors of event and censoring times prior to calling the
# function for the algorithm
eventRandom <- round(rexp(n, 0.012)+1,0)
censorRandom <- round(runif(n, 1,870),0)
# Generate the survival data conditional on the three covariates
data <- permalgorithm(n, m, Xmat, XmatNames=c("sex", "Drug1", "Drug2"),
eventRandom = eventRandom, censorRandom=censorRandom, betas=c(log(2),
log(1.04), log(0.99)), groupByD=FALSE )
# could use survival library and check whether the data was generated
# properly using coxph(Surv(Start, Stop, Event) ~ sex + Drug1 + Drug2,
# data)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.