Learn R Programming

SemiCompRisks (version 3.4)

simID: The function that simulates independent/cluster-correlated semi-competing risks data under semi-Markov Weibull/Weibull-MVN models.

Description

The function to simulate independent/cluster-correlated semi-competing risks data under semi-Markov Weibull/Weibull-MVN models.

Usage

simID(id=NULL, x1, x2, x3, beta1.true, beta2.true, beta3.true,
			alpha1.true, alpha2.true, alpha3.true, 
			kappa1.true, kappa2.true, kappa3.true, 
			theta.true, SigmaV.true=NULL, cens)

Arguments

id

a vector of cluster information for n subjects. The cluster membership must be set to consecutive positive integers, \(1:J\). Required only when generating clustered data.

x1

covariate matrix, n observations by p1 variables.

x2

covariate matrix, n observations by p2 variables.

x3

covariate matrix, n observations by p3 variables.

beta1.true

true value for \(\beta_1\).

beta2.true

true value for \(\beta_2\).

beta3.true

true value for \(\beta_3\).

alpha1.true

true value for \(\alpha_1\).

alpha2.true

true value for \(\alpha_2\).

alpha3.true

true value for \(\alpha_3\).

kappa1.true

true value for \(\kappa_1\).

kappa2.true

true value for \(\kappa_2\).

kappa3.true

true value for \(\kappa_3\).

theta.true

true value for \(\theta\).

SigmaV.true

true value for \(\Sigma_V\). Required only when generating clustered data.

cens

a vector with two numeric elements. The right censoring times are generated from Uniform(\(cens[1]\), \(cens[2]\)).

Value

simIDcor returns a data.frame containing semi-competing risks outcomes from n subjects. It is of dimension \(n\times 4\): the columns correspond to \(y_1\), \(\delta_1\), \(y_2\), \(\delta_2\).

y1

a vector of n times to the non-terminal event

y2

a vector of n times to the terminal event

delta1

a vector of n censoring indicators for the non-terminal event time (1=event occurred, 0=censored)

delta2

a vector of n censoring indicators for the terminal event time (1=event occurred, 0=censored)

Examples

Run this code
# NOT RUN {
	library(MASS)
	set.seed(123456)
	
	J = 110
	nj = 50
	n = J * nj

	id <- rep(1:J, each = nj)

	kappa1.true <- 0.05
	kappa2.true <- 0.01
	kappa3.true <- 0.01
	alpha1.true <- 0.8
	alpha2.true <- 1.1
	alpha3.true <- 0.9
	beta1.true <- c(0.5, 0.8, -0.5)
	beta2.true <- c(0.5, 0.8, -0.5)
	beta3.true <- c(1, 1, -1)
	SigmaV.true <- matrix(0.25,3,3)
	theta.true <- 0.5
	cens <- c(90, 90)

	cov1 <- matrix(rnorm((length(beta1.true)-1)*n, 0, 1), n, length(beta1.true)-1)
	cov2 <- sample(c(0, 1), n, replace = TRUE)
	x1 <- as.data.frame(cbind(cov1, cov2))
	x2 <- as.data.frame(cbind(cov1, cov2))
	x3 <- as.data.frame(cbind(cov1, cov2))
	
	simData <- simID(id, x1, x2, x3, beta1.true, beta2.true, beta3.true, 
				alpha1.true, alpha2.true, alpha3.true, 
				kappa1.true, kappa2.true, kappa3.true, 
				theta.true, SigmaV.true, cens)	
   				    				
# }

Run the code above in your browser using DataLab