Package 'bcfrailphdv'

Title: Bivariate Correlated Frailty Models with Varied Variances
Description: Fit and simulate bivariate correlated frailty models with proportional hazard structure. Frailty distributions, such as gamma and lognormal models are supported for semiparametric procedures. Frailty variances of the two subjects can be varied or equal. Details on the models are available in book of Wienke (2011,ISBN:978-1-4200-7388-1). Bivariate gamma fit is obtained using the approach given in Iachine (1995) with modifications. Lognormal fit is based on the approach by Ripatti and Palmgren (2000) <doi:10.1111/j.0006-341X.2000.01016.x>. Frailty distributions, such as gamma, inverse gaussian and power variance frailty models are supported for parametric approach.
Authors: Mesfin Tsegaye [aut, cre], Yehenew Kifle [aut, ctb]
Maintainer: Mesfin Tsegaye <[email protected]>
License: GPL (>= 2)
Version: 0.1.1
Built: 2024-11-26 06:27:14 UTC
Source: CRAN

Help Index


Semi-parametric bivariate correlated frailty models fit.

Description

Fit a semiparametric Bivariate correlated frailty model with Proportional Hazard structure. Here, frailty variances of pairs can be different.

Usage

bcfraildv(
  formula,
  data,
  initfrailp = NULL,
  frailty = c("gamma", "lognormal"),
  control = bcfraildv.control(),
  comonvar = FALSE,
  ...
)

Arguments

formula

A formula object, with the response on the left of a ~ operator, and the terms on the right. The response must be a survival object as returned by the Surv function.

data

A dataframe contain survival time, censor, covariate etc with data in columns.

initfrailp

Initial estimates for the frailty parameters. If not specified, initial frailty parameters will be obtained from bcfrailph fit for gamma model and from coxph with univariate frailty model and for correlation c(0) for lognormal model.

frailty

A type of frailty distribution to be used in fit. Either gamma or lognormal. The default is gamma.

control

Arguments to control bcfraildv fit. The default is bcfraildv.control.

comonvar

An argument whether to assume common frailty variance. The default is comonvar=FALSE. If comonvar=TRUE, then the result of bcfrailph fit is displayed.

...

further arguments

Value

An object of that contains the following components.

  • coefficients - A vector of estimated Covariate coefficients.

  • frailparest - A vector of estimated Frailty parameters i.e. frailty variance and correlation.

  • stderr-A vector containing the Standard error of the Estimated parameters both covariate coefficients and frailty parameters.

  • loglilk0- Log likelihood of without frailty model or loglik of coxph fit.

  • loglilk-Log likelihood of Cox PH model with frailty.

  • Iloglilk- Log likelihood of with frailty. For gamma fit it is I-likelihood or the likelihood after integrating out the frailty term.For lognormal fit it is the approximate likelihood.

  • bhaz- an array containing unique event times and estimated baseline hazard.

  • X-Matrix of observed covariates.

  • time-the observed survival time.

  • censor-censoring indicator.

  • resid-the martingale residuals.

  • lin.prid-the vector of linear predictors.

  • frail-estimated Frailty values.

  • iteration-Number of outer iterations.

  • e.time-the vector of unique event times.

  • n.event- the number of events at each of the unique event times.

  • convergence-an indicator, 0 if converge and 1 otherwise.

Note

Parameters of Bivariate correlated gamma frailty model was estimated using a modified EM approach given in Kifle et al (2022) with modification for different frailty variances in a pair. Parameters of Bivariate correlated lognormal frailty model is based on the penalized partial likelihood approach by Rippatti and Palmgren (2000).

References

Kifle YG, Chen DG, Haileyesus MT (2022). Multivariate Frailty Models using Survey Weights with Applications to Twins Infant Mortality in Ethiopia. Statistics and Its Interface,106(4), 1\-10.

Rippatti, S. and Palmgren, J (2000). Estimation of multivariate frailty models using penalized partial likelihood. Biometrics, 56: 1016-1022.

See Also

bcfrailph, simbcfraildv

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

fitbcfrail=bcfraildv(Surv(time,censor)~ X1+frailty(PID) ,data=dataa,frailty="gamma")
fitbcfrail


# for lognormal

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.5,-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

#fit
fitbcfrlogn=bcfraildv(Surv(time,censor)~ X1+X2+X3+frailty(PID) ,data=dataa,frailty="lognormal")
fitbcfrlogn

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

## one can set the initial parameter for the frailty parameters
fitbcfrail=bcfraildv(Surv(time,censor)~ X1+frailty(PID) ,data=dataa,
frailty="gamma",initfrailp = c(0.2,0.2,0.4))
fitbcfrail

# Not run

#if covariates are not included
fitmoe=try(bcfraildv(Surv(time,censor)~0+frailty(PID),data=dataa,
frailty="lognormal"),silent = TRUE)

fitmoe=try(bcfraildv(Surv(time,censor)~1+frailty(PID),data=dataa),silent = TRUE)

# if control is not specified correctly.
# if one needs to change only max.iter to be 100,

fitmoe=try(bcfraildv(Surv(time,censor)~ X1+frailty(PID),data=dataa,
control=c(max.iter=100)),silent = TRUE)

#the correct way is
fitmoe=bcfraildv(Surv(time,censor)~ X1+frailty(PID),data=dataa,
control=bcfraildv.control(max.iter=100))
fitmoe

#if initial frailty parameters are in the boundary of parameter space
fitmoe=try(bcfraildv(Surv(time,censor)~ X1+frailty(PID),data=dataa,
initfrailp=c(0.2,0.3,1)),silent = TRUE)

fitmoe=try(bcfraildv(Surv(time,censor)~ X1+frailty(PID),data=dataa,
initfrailp=c(0,0.5,0.1)),silent = TRUE)

#if a frailty distribution other than gamma and lognormal are specified

fitmoe=try(bcfraildv(Surv(time,censor)~ X1,data=dataa,frailty="exp"),silent = TRUE)

# End Not run

Arguments for controlling bcfraildv fits.

Description

This is used to set various numeric parameters controlling a bcfraildv model fit as a single list.

Usage

bcfraildv.control(
  max.iter = 500,
  tol = 1e-04,
  eval.max = 500,
  iter.max = 500,
  trace = 0,
  abs.tol = 1e-20,
  rel.tol = 1e-10,
  x.tol = 1.5e-08,
  xf.tol = 2.2e-14,
  step.min = 1,
  step.max = 1
)

Arguments

max.iter

Maximum number of iterations allowed. The default is 500.

tol

A tolerance for convergence i.e the maximum differences of loglikelihood between succssive iterations.The default is 1e-04.

eval.max

argument used to control nlminb fits used.

iter.max

argument used to control nlminb fits used.

trace

argument used to control nlminb fits used.

abs.tol

argument used to control nlminb fits used.

rel.tol

argument used to control nlminb fits used.

x.tol

argument used to control nlminb fits used.

xf.tol

argument used to control nlminb fits used.

step.min

argument used to control nlminb fits used.

step.max

argument used to control nlminb fits used.

Value

A list of control parameters.

See Also

bcfraildv


Parametric bivariate correlated frailty models fit.

Description

Fit a parametric Bivariate correlated gamma, inverse gaussian and power variance frailty models with Proportional Hazard structure.

Usage

bcfrailpar(
  formula,
  data,
  initfrailp = NULL,
  inithazp = NULL,
  initbeta = NULL,
  haz = c("weibull", "gompertz", "exponential"),
  frailty = c("gamma", "invgauss", "pv"),
  comonvar = TRUE,
  ...
)

Arguments

formula

A formula object, with the response on the left of a ~ operator, and the terms on the right. The response must be a survival object as returned by the Surv function.

data

A dataframe contain survival time, censor, covariate etc with data in columns.

initfrailp

Initial estimates for the frailty parameters. The default is c(0.5,0.5).

inithazp

Initial estimates for the baseline hazard distribution parameters. The default is c(0.05) for both scale and shape parameters.

initbeta

Initial estimates for the covariate coefficients if there are any included. The default is taken from coxph fit.

haz

A baseline hazard distribution. Either weibull, gompertz or exponential distributions are possible.

frailty

A type of frailty distribution. Either gamma, inverse gaussian frailty="invgauss" or power variance frailty="pv" frailty distributions are possible.

comonvar

An argument whether to assume common frailty variance. The default is comonvar=TRUE. If comonvar=FALSE, then only gamma frailty model is possible.

...

further arguments.

Value

An object of that contains the following components.

  • coefficients - A vector of estimated Covariate coefficients.

  • frailparest - A vector of estimated Frailty parameters i.e. frailty variance and correlation.

  • basehazpar - A vector of estimated baseline hazard parameters i.e. scale and shape.

  • stderr-A vector containing the Standard errors of the Estimated parameters with the order of frailty parameters,baseline hazard parameters and covariate coefficients.

  • vcov- Variance Covariance matrix of the Estimated parameters.

  • loglik-Log likelihood of the model.

  • AIC-AIC of the model.

  • BIC-BIC of the model.

  • iterations-Number of outer iterations.SeeconstrOptim for further.

  • convergence-An indicator of convergence. SeeconstrOptim for further.

Examples

set.seed(4)
simdata<-simbcfraildv(psize=500, 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

fitbcfrail=bcfrailpar(Surv(time,censor)~ X1+frailty(PID) ,data=dataa,frailty="gamma")
fitbcfrail



set.seed(18)
simdata<-simbcfraildv(psize=300, cenr= c(0.3),beta=c(2),frailty=c("gamma"),
frailpar=c(0.5,0.5,0.4),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

#fit with power variance frailty distribution
fitbcfrail=bcfrailpar(Surv(time,censor)~ X1+frailty(PID) ,data=dataa,
frailty="pv")
fitbcfrail

## one can set the initial parameter for the frailty parameters
fitbcfrail=bcfrailpar(Surv(time,censor)~ X1+frailty(PID) ,data=dataa,initfrailp = c(0.4,0.3),
frailty="gamma")
fitbcfrail

# Not run

#if initial frailty parameters are in the boundary of parameter space
fitmoe=try(bcfrailpar(Surv(time,censor)~ X1+frailty(PID),data=dataa,
initfrailp=c(0.2,1)),silent = TRUE)

#if a frailty distribution other than gamma, invgauss or pv is specified

fitmoe=try(bcfrailpar(Surv(time,censor)~ X1,data=dataa,frailty="exp"),silent = TRUE)

# End Not run

Print bcfraildv

Description

Generics to print the S3 class bcfraildv.

Usage

## S3 method for class 'bcfraildv'
print(x, ...)

Arguments

x

A class bcfraildv object.

...

ignored

Details

Calls print.bcfraildv().

Value

An object of print.bcfraildv, with some more human-readable results from bcfraildv object.

Note

The summary function is currently identical to the print function.

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

fitbcfrail=bcfraildv(Surv(time,censor)~ X1+frailty(PID) ,data=dataa)
fitbcfrail
summary(fitbcfrail)

Print bcfrailpar

Description

Generics to print the S3 class bcfrailpar.

Usage

## S3 method for class 'bcfrailpar'
print(x, ...)

Arguments

x

A class bcfrailpar object.

...

ignored

Details

Calls print.bcfrailpar().

Value

An object of print.bcfrailpar, with some more human-readable results from bcfrailpar object.

Note

The summary function is currently identical to the print function.

See Also

bcfrailpar

Examples

set.seed(4)
simdata<-simbcfraildv(psize=500, cenr= c(0),beta=c(-1),frailty=c("gamma"),
frailpar=c(0.4,0.4,0.5),bhaz=c("weibull"),
bhazpar=list(shape =c(0.9), scale = c(2)),
covartype= c("B"),covarpar=list(fargs=c(1),sargs=c(0.5)))
dataa<-simdata$data ## the simulated data set

#fit
parbcfit=bcfrailpar(Surv(time, censor) ~ X1+frailty(PID),data=dataa)
parbcfit

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)

Print bcfraildv

Description

Generics to print the S3 class bcfraildv.

Usage

## S3 method for class 'bcfraildv'
summary(object, ...)

Arguments

object

A class bcfraildv object.

...

ignored

Details

Calls print.bcfraildv().

Value

An object of print.bcfraildv, with some more human-readable results from bcfraildv object.

Note

The summary function is currently identical to the print function.

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

fitbcfrail=bcfraildv(Surv(time,censor)~ X1+frailty(PID) ,data=dataa)
fitbcfrail
summary(fitbcfrail)

Print bcfrailpar

Description

Generics to print the S3 class bcfrailpar.

Usage

## S3 method for class 'bcfrailpar'
summary(object, ...)

Arguments

object

A class bcfrailpar object.

...

ignored

Details

Calls print.bcfrailpar().

Value

An object of summary.bcfrailpar, with some more human-readable results from bcfrailpar object.

Note

The summary function is currently identical to the print function.

See Also

bcfrailpar

Examples

set.seed(40)
simdata<-simbcfraildv(psize=500, cenr= c(0.3),beta=c(-1),frailty=c("gamma"),
frailpar=c(0.4,0.4,0.5),bhaz=c("gompertz"),
bhazpar=list(shape =c(0.09), scale = c(0.2)),
covartype= c("B"),covarpar=list(fargs=c(1),sargs=c(0.5)))
dataa<-simdata$data

fitbcfrail=bcfrailpar(Surv(time,censor)~ X1+frailty(PID) ,
data=dataa,haz="gompertz")
fitbcfrail
summary(fitbcfrail)