Type: | Package |
Title: | Comparison of Survival Curves Between Two Groups |
Version: | 1.1.1 |
Date: | 2022-08-25 |
Description: | Various statistical methods for survival analysis in comparing survival curves between two groups, including overall hypothesis tests described in Li et al. (2015) <doi:10.1371/journal.pone.0116774> and Huang et al. (2020) <doi:10.1080/03610918.2020.1753075>, fixed-point tests in Klein et al. (2007) <doi:10.1002/sim.2864>, short-term tests, and long-term tests in Logan et al. (2008) <doi:10.1111/j.1541-0420.2007.00975.x>. Some commonly used descriptive statistics and plots are also included. |
Depends: | R (≥ 4.1), survival |
Imports: | survRM2, TSHRC, muhaz |
License: | GPL-2 |
Encoding: | UTF-8 |
Author: | Jingjing Lyu [aut], Zheng Chen [cre], Huimin Li [ctb], Jinbao Chen [ctb], Xinghui Huang [ctb] |
Maintainer: | Zheng Chen <zheng-chen@hotmail.com> |
NeedsCompilation: | no |
Packaged: | 2022-08-25 10:00:13 UTC; DELL |
Repository: | CRAN |
Date/Publication: | 2022-08-25 10:42:39 UTC |
Comparison of survival curves between two groups
Description
Various statistical methods for survival analysis in comparing survival curves between two groups, including overall hypothesis tests described in Li et al. (2015), fixed-point tests in Klein et al. (2007), short-term tests, and long-term tests in Logan et al. (2008). Some commonly used descriptive statistics and plots are also included.
Author(s)
Jingjing Lyu, Zheng Chen, Huimin Li, Jinbao Chen, Xinghui Huang. maintainer: Zheng Chen zheng-chen@hotmail.com
References
[1] Li H, Han D, Hou Y, et al. Statistical inference methods for two crossing survival curves: a comparison of methods. PLoS One, 2015, 10: e116774.
[2] Huang X, Lyu J, Hou Y, et al. A Nonparametric Statistical Method for Two Crossing Survival Curves. Communications in Statistics - Simulation and Computation, 2020. doi: 10.1080/03610918.2020.1753075.
[3] Klein JP, Logan B, Harhoff M, et al. Analyzing survival curves at a fixed point in time. Statistics in Medicine, 2007, 26(24):4505-4519.
[4] Logan BR, Klein JP, Zhang M. Comparing Treatments in the Presence of Crossing Survival Curves: An Application to Bone Marrow Transplantation. Biometrics, 2008, 64(3): 733-740.
The Data with Survival Curves Crossed
Description
Crossdata is a dataset from simulation, which is violated the proportional hazard ratio assumption.
Usage
data(Crossdata)
Format
A data frame with 200 observations on the following 3 variables.
- time
The follow up time for right censored data.
- status
The status indicator, normally 1=event, 0=alive or right censored.
- group
The group indicator for comparison, 0= control group, 1= treatment group.
Examples
data(Crossdata)
Plot for Cumulative Hazard Function
Description
A function used to plot the curves of cumulative hazard function.
Usage
Cumhazard.plot(time,status,group,col=c(1,4),lwd=c(1,1),lty=c(1,1)
,lab.x="",lab.y="",legend=FALSE,local.x=NULL,local.y=NULL
,legend.0="",legend.1="")
Arguments
time |
The follow up time for right censored data. |
status |
The status indicator, normally 1=event, 0=alive or right censored. |
group |
The group indicator for comparison, and the elements of this vector must take either 0 or 1. Normally, 0= control group, 1= treatment group. |
col |
A vector of integers specifying colors for each group. The default value is c(1,4). |
lwd |
A vector of numeric values for line widths. The default value is c(1,1). |
lty |
A vector of integers specifying line types for each curve. The default value is c(1,1). |
lab.x |
Label given to the x-axis. |
lab.y |
Label given to the y-axis. |
legend |
An indicator variable for adding a legend. If it is present this implies legend=FALSE. |
local.x |
Changed the x-axis scale for the legend if legend=TRUE. |
local.y |
Changed the y-axis scale for adding a legend if legend=TRUE. |
legend.0 |
Label given to the control group if legend=TRUE. |
legend.1 |
Label given to the treatment group if legend=TRUE. |
Value
None
See Also
Examples
#get 'Crossdata' from package
data(Crossdata)
data1<-Crossdata
#
#get cumulative hazard plot
Cumhazard.plot(data1$time, data1$status, data1$group, lab.x='Time', lab.y='Cumulative hazard'
,col=c(1,4), lwd=c(3,3), lty=c(1,1), legend=TRUE, local.x=0, local.y=3
,legend.0='group0', legend.1='group1')
Summarize Descriptive Statistics Commonly Used in Survival Data
Description
A function used to produce result summaries of the results of various descriptive statistics.
Usage
Descriptive.stat(time, status, group, tau="observed", alpha=0.05)
Arguments
time |
The follow up time for right censored data. |
status |
The status indicator, normally 1=event, 0=alive or right censored. |
group |
The group indicator for comparison, and the elements of this vector must take either 0 or 1. Normally, 0= control group, 1= treatment group. |
tau |
The truncation time point (numeric) for the RMST calculation, which needs to be smaller than or equal to the minimum of the largest observed time in each of the two groups. When tau="observed" (default), the minimum of the largest observed time in each of the two groups is used. It can be changed tp tau="event" to choose the minimum of the largest event time in each of the two groups. |
alpha |
The significance level, the default is 0.05. |
Value
A list containing the following components:
result.summary |
The summary statistics in each group, including sample.size, the number of event (event.num), censoring.rate, max.observed.time, max.event.time. |
result.mean |
The results of mean survival time in each group. |
result.quantile |
Quantiles and 0.95 CI of survival time in each group. |
tau |
The truncation time point for the restricted mean survival time (RMST) calculation. |
result.RMST |
The results of RMST in each group. See references for details. |
Examples
#get 'Crossdata' from package
data(Crossdata)
data2<-Crossdata
#
#get result of descriptive statistics with tau=the minimum of the largest observed time
Descriptive.stat(data2$time, data2$status, data2$group,tau="observed")
#get result of descriptive statistics with tau=the minimum of the largest event time
Descriptive.stat(data2$time, data2$status, data2$group,tau="event")
Statistical inference methods for testing at a fixed time point
Description
A function used to produce the results of various statistical inference methods for testing at a fixed time point.
Usage
Fixpoint.test(time, status, group, t0)
Arguments
time |
The follow up time for right censored data. |
status |
The status indicator, normally 1=event, 0=alive or right censored. |
group |
The group indicator for comparison, and the elements of this vector must take either 0 or 1. Normally, 0= control group, 1= treatment group. |
t0 |
The fixed time point for testing. |
Value
A list containing the following components:
est.g0 |
The estimation of survival rates at the fixed timepoint for control group. |
est.g1 |
The estimation of survival rates at the fixed timepoint for treatment group. |
test |
The results of statistical inference at the fixed timepoint. |
method |
Containing 5 types of statistical inference methods: naive, log, cloglog, arcsin, and logist. See more details in references. |
t0 |
The prespecified fixed time point. |
est |
The survival rate at the prespecified timepoint. |
lower.95.CI |
The lower 95 percent pointwise confidence interval for the survival function. |
upper.95.CI |
The upper 95 percent pointwise confidence interval for the survival function. |
statistic |
The statistics of corresponding methods. |
pvalue |
The test P value of corresponding methods. |
References
[1]Klein JP, Logan B, Harhoff M, et al. Analyzing survival curves at a fixed point in time. Statistics in Medicine, 2007, 26(24):4505-4519.
[2]Anderson JR, Pike LBC. Approximate Confidence Intervals for Probabilities of Survival and Quantiles in Life-Table Analysis. Biometrics, 1982, 38(2):407-416.
Examples
#get 'Crossdata' from package
data(Crossdata)
data1<-Crossdata
#
#if there exist differences at 6 months and 12 months
Fixpoint.test(data1$time,data1$status,data1$group,t0=0.5)
Fixpoint.test(data1$time,data1$status,data1$group,t0=1)
Plot for Kernel-Based Hazard Function
Description
A function used to plot the hazard functions. The hazard functions are estimated from right censored data using kernel-based methods.
Usage
Hazard.plot(time,status,group,max.0=NULL,max.1=NULL
,col=c(1,4),lwd=c(1,1),lty=c(1,1)
,lab.x="",lab.y="",legend=FALSE
,local.x=NULL,local.y=NULL,legend.0="",legend.1="")
Arguments
time |
The follow up time for right censored data. |
status |
The status indicator, normally 1=event, 0=alive or right censored. |
group |
The group indicator for comparison, and the elements of this vector must take either 0 or 1. Normally, 0= control group, 1= treatment group. |
max.0 |
A numeric value of the maximum horizontal plot coordinate in control group. The default value is max.0=NULL. |
max.1 |
A numeric value of the maximum horizontal plot coordinate in treatment group. The default value is max.0=NULL. |
col |
A vector of integers specifying colors for each group. The default value is c(1,4). |
lwd |
A vector of numeric values for line widths. The default value is c(1,1). |
lty |
A vector of integers specifying line types for each curve. The default value is c(1,1). |
lab.x |
Label given to the x-axis. |
lab.y |
Label given to the y-axis. |
legend |
An indicator variable for adding a legend. If it is present this implies legend=FALSE. |
local.x |
Changed the x-axis scale for the legend if legend=TRUE. |
local.y |
Changed the y-axis scale for adding a legend if legend=TRUE. |
legend.0 |
Label given to the control group if legend=TRUE. |
legend.1 |
Label given to the treatment group if legend=TRUE. |
Value
None
Note
In Hazard.plot, the kernel estimates are based on the package "muhaz". Here, the algorithm method is the "same bandwidth for all grid points", and the biquadratic is of the boundary kernel function to be used. More details can be found in package "muhaz", the function of muhaz.
See Also
Examples
#get 'Crossdata' from package
data(Crossdata)
data1<-Crossdata
#
#get kernel smooth hazard plot
Hazard.plot(data1$time, data1$status, data1$group, max.0=NULL,max.1=NULL
, lab.x='Time', lab.y='Smooth hazard ratio'
, col=c(1,4), lwd=c(3,3), lty=c(1,1), legend=TRUE, local.x=2.7, local.y=1.25
, legend.0='group0', legend.1='group1')
Statistical Inference Methods for Testing After a Specified Time Point
Description
A function used to produce the results of statistical inference methods for testing the difference after a specified time point.
Usage
Long.test(time,status,group,t0)
Arguments
time |
The follow up time for right censored data. |
status |
The status indicator, normally 1=event, 0=alive or right censored. |
group |
The group indicator for comparison, and the elements of this vector must take either 0 or 1. Normally, 0= control group, 1= treatment group. |
t0 |
The cut-point time, which should larger than the minimum of non-censored time and also less than the maximum of non-censored time. |
Value
A list containing the following components:
method |
Containing 4 statistical inference methods: partial log-rank, Zols, Zspp, and Chi-square(Qua). See more details in references. |
t0 |
The prespecified cut-point time. |
statistic |
The statistics of corresponding methods. |
pvalue |
The test P value of corresponding methods. |
Note
The partial log-rank method is different from the log-rank method in overall.test. Here, the "partial" means let all observations left truncated at the cut-point time t0.
References
Logan BR, Klein JP, Zhang M. Comparing Treatments in the Presence of Crossing Survival Curves: An Application to Bone Marrow Transplantation. Biometrics, 2008, 64(3): 733-740.
See Also
Examples
#get 'Crossdata' from package
data(Crossdata)
data1<-Crossdata
#
#get cross point
crosspoint(data1$time,data1$status,data1$group)
#two survival curves crossing at 1.69 years
#
#get the result after cross point (t0=1.69)
Long.test(data1$time,data1$status,data1$group,t0=1.69)
Statistical Inference Methods for Overall Hypothesis Tests
Description
A function used to produce the results of various statistical inference methods for overall hypothesis testing, along with the test result of proportional hazards assumption.
Usage
Overall.test(time, status, group, tau=NULL, nperm=500, seed=12345)
Arguments
time |
The follow up time for right censored data. |
status |
The status indicator, normally 1=event, 0=alive or right censored. |
group |
The group indicator for comparison, and the elements of this vector must take either 0 or 1. Normally, 0= control group, 1= treatment group. |
tau |
The truncation time point for the RMST calculation, which needs to be smaller than or equal to the minimum of the largest observed time in each of the two groups. When tau=NULL, the default value (the minimum of the largest event time in each of the two groups) is used. |
nperm |
The times of permutation in area between survival curves(ABS) permutation test, with default nperm=500. |
seed |
The seed number, with default seed=12345. |
Value
A list containing the following components:
method |
Containing 9 statistical inference methods: log-rank, Gehan-Wilcoxon, Tarone-Ware, Weighted Kaplan-Meier (KM), area between survival curves (ABS), ABS permutation, Two-stage, Squared differences, and restricted mean survival time (RMST). See more details of these methods in references. |
statistic |
The statistics of corresponding methods. |
pvalue |
The test P value of corresponding methods. |
Note
The results of Two-stage is based on the "TSHRC" package, more details can be found in package "TSHRC", the function of twostage.
The results of RMST is based on the "survRM2" package, more details can be found in package "survRM2", the function of rmst2.
References
[1] Li H, Han D, Hou Y, et al. Statistical inference methods for two crossing survival curves: a comparison of methods. PLoS One, 2015, 10: e116774.
[2] Qiu P, Sheng J. A two-stage procedure for comparing hazard rate functions. Journal of the Royal Statistical Society. Series B, Statistical Methodology, 2008, 70: 191-208.
[3] Huang X, Lyu J, Hou Y, et al. A Nonparametric Statistical Method for Two Crossing Survival Curves. Communications in Statistics - Simulation and Computation, 2020. doi: 10.1080/03610918.2020.1753075.
Examples
#get 'Crossdata' from package
data(Crossdata)
data1<-Crossdata
#
#get result of overall hypothesis testing
Overall.test(data1$time,data1$status,data1$group,nperm=10)
The Data Satisfied Proportional Hazard Assumption
Description
PHdata is a dataset from simulation, which is satisfied the proportional hazard ratio assumption.
Usage
data(PHdata)
Format
A data frame with 200 observations on the following 3 variables.
- time
The follow up time for right censored data.
- status
The status indicator, normally 1=event, 0=alive or right censored.
- group
The group indicator for comparison, 0= control group, 1= treatment group.
Examples
data(PHdata)
Statistical Inference Methods for Testing Before a Specified Time Point
Description
A function used to produce the results of statistical inference methods for testing the difference before a specified time point.
Usage
Short.test(time,status,group,t0)
Arguments
time |
The follow up time for right censored data. |
status |
The status indicator, normally 1=event, 0=alive or right censored. |
group |
The group indicator for comparison, and the elements of this vector must take either 0 or 1. Normally, 0= control group, 1= treatment group. |
t0 |
The cut-point time, which should larger than the minimum of non-censored time and also less than the maximum of all survival time. |
Value
A list containing the following components:
method |
Containing 2 types of statistical inference methods: partial Weighted Kaplan-Meier and partial log-rank. |
t0 |
The prespecified cut-point time. |
statistic |
The statistics of corresponding methods. |
pvalue |
The test P value of corresponding methods. |
Note
The partial Weighted Kaplan-Meier method and partial log-rank method are different from the Weighted Kaplan-Meier method and the log-rank method in overall.test. Here, the "partial" means let all observations right censored at the cut-point time t0.
See Also
Examples
#get 'Crossdata' from package
data(Crossdata)
data1<-Crossdata
#
#get cross point
crosspoint(data1$time,data1$status,data1$group)
#two survival curves crossing at 1.69 years
#
#get the result before cross point (t0=1.69)
Short.test(data1$time,data1$status,data1$group,t0=1.69)
Plot for Cumulative Survival Function
Description
A function used to plot the survival curves.
Usage
Survival.plot(time,status,group,...)
Arguments
time |
The follow up time for right censored data. |
status |
The status indicator, normally 1=event, 0=alive or right censored. |
group |
The group indicator for comparison, and the elements of this vector must take either 0 or 1. Normally, 0= control group, 1= treatment group. |
... |
Parameters in function plot() |
Value
None
Note
Survival.plot is based on the survival package, more details can be found in package "survival", the function of plot.survfit.
See Also
Examples
#get 'Crossdata' from package
data(Crossdata)
data1<-Crossdata
#
#get survival plot
Survival.plot(data1$time, data1$status, data1$group, xlab = "Time", ylab = "Survival"
, col = c(1, 4), lwd = c(3, 3), lty= c(1, 1))
legend(2.5, 1, c("group0", "group1"), col = c(1, 4), lwd = c(3, 3), lty= c(1, 1), bty="n")
Produce The Cross Time Point When Two Survival Curves Crossed Each Other
Description
A function used to produce the cross time points in two survival curves.
Usage
crosspoint(time,status,group)
Arguments
time |
The follow up time for right censored data. |
status |
The status indicator, normally 1=event, 0=alive or right censored. |
group |
The group indicator for comparison, and the elements of this vector must take either 0 or 1. Normally, 0= control group, 1= treatment group. |
Value
A list containing the following components:
crosspoint |
The crossing time points between two survival curves. When there is no crossing between two survival curves, the program will stop with "There is no crossing exists". |
Note
The crosspoint function only used to find the cross time point in survival curves.
Examples
#get 'Crossdata' from package
data(Crossdata)
data1<-Crossdata
#get cross point
#two survival curves crossing at 1.69 years or so
crosspoint(data1$time,data1$status,data1$group)
#
#get 'PHdata' from package
data(PHdata)
data2<-PHdata
#when there exists no crossing
#the program will stop "There is no crossing exists"
# Not run: crosspoint(data2$time,data2$status,data2$group)