simbcfraildv: Simulate data from bivariate correlated frailty models.

View source: R/simbcfraildv.R

simbcfraildvR Documentation

Simulate data from bivariate correlated frailty models.

Description

Simulate data from bivariate correlated gamma or lognormal frailty models with one covariate.

Usage

simbcfraildv(
  psize,
  cenr = c(0),
  beta = c(0.5),
  frailty,
  frailpar = c(0.5, 0.5, 0.25),
  bhaz = c("weibull"),
  bhazpar = list(shape = c(0.5), scale = c(0.01)),
  covartype = c("B"),
  covarpar = list(fargs = c(1), sargs = c(0.5)),
  inpcovar = NULL,
  inpcen = NULL,
  comncovar = NULL
)

Arguments

psize

pair size.

cenr

censored rate. The default is zero..

beta

Covariate coefficient.

frailty

A type of frailty distribution to be used. Either gamma or lognormal.

frailpar

vector of frailty parameters, variance and correlation respectively. The default is c(0.5,0.5,0.25) meaning both variances are 0.5 and correlation 0.25.

bhaz

A type of baseline hazard distribution to be used. it can be weibull, gompertz or exponential.

bhazpar

is a list containing scale andshape of the specified baseline hazard distribution.

covartype

specified the distribution from which covariate(s) are goining to be sampled. covartype can be c("B","N","U")denoting binomial, normal or uniform, respectively. For example, covartype=c("B","B") to generate two covariates both from a binomial distribution.

covarpar

is a list containing parmeters of the specified covariate distribution with first and second arguments denoted by fargs and sargs, respectively. For example, if covartype=c("B","U") and covarpar=list(fargs=c(1,0.3),sargs=c(0.5,1.3)), generates two independent covariates from a binomial distribution (with parameters size=1 and probs=0.5) and from uniform distributions (with parameters min=0.3 and max=1.3).

inpcovar

is a list i.e,list(covar1=x1,covar2=x2) to input covariates with both x1 and x2 is in matrix form.

inpcen

is a list containing cent1 and cent2 denoting censoring time for the first and the second subjects in pairs respectively.

comncovar

if common covariates are needed.

Value

An object of class simbcfraildv that contain the following:

  • data A data frame i.e, the simulated data set. IID is individual Id, PID is pair ID, time is the simulated survival time, censor is censoring indicator and X1 denote the simulated covariate.

  • numberofpair The specified number of pairs.

  • censoredrate The specified censored rate.

  • fraildist The specified frailty distribution.

  • frailpar The specified frailty parameters.

See Also

bcfraildv

Examples

set.seed(4)
simdata<-simbcfraildv(psize=300, cenr= c(0.3),beta=c(2),frailty=c("gamma"),
frailpar=c(0.5,0.5,0.5),bhaz=c("weibull"),
bhazpar=list(shape =c(5), scale = c(0.1)),
covartype= c("B"),covarpar=list(fargs=c(1),sargs=c(0.5)))
dataa<-simdata$data
head(dataa)


# If data generation is from bivariate correlated lognormal frailty model,
set.seed(18)
simdata<-simbcfraildv(psize=100, cenr= c(0.2),beta=c(1,-0.7,0.5),frailty=c("lognormal"),
frailpar=c(0.5,0.8,-0.25),bhaz=c("exponential"),
bhazpar=list(scale = c(0.1)),covartype= c("N","N","B"),
covarpar=list(fargs=c(0,0,1),sargs=c(1,1,0.5)))
dataa<-simdata$data
head(dataa)

# If common covariate is desired, i.e., here out of the three covariates 
#covariate 2 is common for the pair.
set.seed(18)
simdata<-simbcfraildv(psize=100, cenr= c(0.2),beta=c(1,-0.7,0.5),frailty=c("lognormal"),
frailpar=c(0.5,0.8,-0.25),bhaz=c("exponential"),
bhazpar=list(scale = c(0.1)),covartype= c("N","N","B"),
covarpar=list(fargs=c(0,0,1),sargs=c(1,1,0.5)),comncovar=2)
dataa<-simdata$data
head(dataa)

# If the data generation is from bivariate correlated gamma frailty model,
#weibull baseline and without covariate,
set.seed(4)
simdata<-simbcfraildv(psize=300, cenr= c(0.3),beta=NULL,frailty=c("gamma"),
frailpar=c(0.5,0.6,0.5),bhaz=c("weibull"),bhazpar=list(shape =c(5), scale = c(0.1)))
dataa<-simdata$data
head(dataa)



bcfrailphdv documentation built on Dec. 28, 2022, 2:10 a.m.