biv.rec.np {BivRec} | R Documentation |
This function allows the user to apply a non-parametric method to estimate the joint cumulative distribution function (cdf) for the two alternating events gap times (xij and yij) as well as the marginal survival function for type I gap times (xij) and the conditional cdf of the type II gap times (yij) given an interval of type I gap times (xij). See Huang and Wang (2005) for more details.
biv.rec.np(formula, data, CI, ai, u1, u2, conditional, given.interval, jointplot, marginalplot, condiplot)
formula |
A formula with six variables indicating the bivariate alternating gap time response on the left of the ~ operator and a 1 on the right. The six variables on the left must have the same length and be given as ID + episode + xij + yij + delta_x + delta_y ~ 1, where
|
data |
A data frame that includes all the vectors listed in the formula. |
CI |
The level for confidence intervals for joint cdf plot, marginal plot and conditional cdf. Must be between 0.50 and 0.99, where 0.99 would give 99% CI. Default is 0.95. |
ai |
A real non-negative function of censoring time. See details. |
u1 |
A vector or single number to be used for estimation of joint cdf P(X0 ≤ u1, Y0 ≤ u2) in the non-parametric method. |
u2 |
A vector or single number to be used for estimation of joint cdf P(X0 ≤ u1, Y0 ≤ u2) in the non-parametric method. |
conditional |
A logical value. If TRUE, this function will calculate the conditional cdf for the type II gap time given an interval of the type I gap time and the bootstrap standard error and confidence interval at the specified confidence level. Default is FALSE. |
given.interval |
A vector c(v1, v2) that must be specified if conditional = TRUE. The vector indicates an interval for the type I gap time to use for estimation of the cdf of the type II gap time given this interval. If given.interval = c(v1, v2), the function calculates P(Y0 ≤ y | v1 ≤ X0 ≤ v2). The given values v1 and v2 must be in the range of gap times in the estimated marginal survival. Valid values for these times are given in the "Time" column of the marginal survival data frame that results from biv.rec.np(). |
jointplot |
A logical value. If TRUE (default), this function will create a 3D plot of the joint cdf for the two gap times with pointwise large sample confidence interval at the specified confidence level. |
marginalplot |
A logical value. If TRUE (default), this function will plot the marginal survival function for the type I gap times with pointwise large sample confidence interval at the specified confidence level. |
condiplot |
A logical value. Can only be TRUE if conditional=TRUE. If TRUE, this function will plot the conditional cdf with bootstrap confidence interval at the specified confidence level. Default is FALSE. |
ai indicates a real non-negative function of censoring times to be used as weights in the non-parametric method. This variable can take on values of 1 or 2 which indicate:
1: the weights are simply 1 for all subjects a(C_i) = 1 (default).
2: the weight for each subject is his/her censoring time a(C_i) = C_i.
For further information, see Huang and Wang (2005).
Plots as specified from jointplot, marginalplot, conditional and a BivRec list object containing:
joint.cdf: Data frame with joint cdf and standard error for the two alternating gap times.
marginal.survival: Data frame with marginal survival for the first gap time and standard error.
conditional.cdf: Data frame with conditional cdf, bootstrap standard error and bootstrap confidence interval.
formula: The formula used to specify components of bivariate recurrent response.
ai: The function of censoring time used as weights.
Huang CY, Wang MC (2005). Nonparametric estimation of the bivariate recurrence time distribution. Biometrics, 61: 392-402. doi.org/10.1111/j.1541-0420.2005.00328.x
library(BivRec) # Simulate bivariate alternating recurrent event data set.seed(1234) biv.rec.data <- biv.rec.sim(nsize=150, beta1=c(0.5,0.5), beta2=c(0,-0.5), tau_c=63, set=1.1) # Apply the non-parametric method of Huang and Wang (2005) and # Visualize joint cdf and marginal survival results nonpar.result <- biv.rec.np(formula = id + epi + xij + yij + d1 + d2 ~ 1, data=biv.rec.data, ai=1, u1 = c(2, 5, 10, 20), u2 = c(1, 5, 10, 15), conditional = FALSE, given.interval=c(0, 10), jointplot=TRUE, marginalplot = TRUE, condiplot = FALSE) head(nonpar.result$joint.cdf) head(nonpar.result$marginal.survival) ## Not run: #This is an example with longer runtime. library(BivRec) # Simulate bivariate alternating recurrent event data set.seed(1234) biv.rec.data <- biv.rec.sim(nsize=150, beta1=c(0.5,0.5), beta2=c(0,-0.5), tau_c=63, set=1.1) # Apply the non-parametric method of Huang and Wang (2005) and Visualize all results nonpar.result <- biv.rec.np(formula = id + epi + xij + yij + d1 + d2 ~ 1, data=biv.rec.data, ai=1, u1 = c(2, 5, 10, 20), u2 = c(1, 5, 10, 15), conditional = TRUE, given.interval=c(0, 10), jointplot=TRUE, marginalplot = TRUE, condiplot = TRUE) head(nonpar.result$joint.cdf) head(nonpar.result$marginal.survival) head(nonpar.result$conditional.cdf) ## End(Not run)