Title: | Planning and Analysing Survival Studies under Non-Proportional Hazards |
---|---|
Description: | Piecewise constant hazard functions are used to flexibly model survival distributions with non-proportional hazards and to simulate data from the specified distributions. A function to calculate weighted log-rank tests for the comparison of two hazard functions is included. Also, a function to calculate a test using the maximum of a set of test statistics from weighted log-rank tests (MaxCombo test) is provided. This test utilizes the asymptotic multivariate normal joint distribution of the separate test statistics. The correlation is estimated from the data. These methods are described in Ristl et al. (2021) <doi:10.1002/pst.2062>. Finally, a function is provided for the estimation and inferential statistics of various parameters that quantify the difference between two survival curves. Eligible parameters are differences in survival probabilities, log survival probabilities, complementary log log (cloglog) transformed survival probabilities, quantiles of the survival functions, log transformed quantiles, restricted mean survival times, as well as an average hazard ratio, the Cox model score statistic (logrank statistic), and the Cox-model hazard ratio. Adjustments for multiple testing and simultaneous confidence intervals are calculated using a multivariate normal approximation to the set of selected parameters. |
Authors: | Robin Ristl [aut, cre], Nicolas Ballarini [ctb] |
Maintainer: | Robin Ristl <[email protected]> |
License: | GPL-3 |
Version: | 2.1 |
Built: | 2025-01-30 04:07:51 UTC |
Source: | https://github.com/cran/nph |
Calculates a MaxCombo test for the comparison of two groups based on the maximum of test statistics of a set of weighted log-rank tests
logrank.maxtest( time, event, group, alternative = c("two.sided", "less", "greater"), rho = c(0, 0, 1), gamma = c(0, 1, 0), event_time_weights = NULL, algorithm = mvtnorm::GenzBretz(maxpts = 50000, abseps = 1e-05, releps = 0) )
logrank.maxtest( time, event, group, alternative = c("two.sided", "less", "greater"), rho = c(0, 0, 1), gamma = c(0, 1, 0), event_time_weights = NULL, algorithm = mvtnorm::GenzBretz(maxpts = 50000, abseps = 1e-05, releps = 0) )
time |
Vector of observed event/censored times |
event |
logical vector or numeric vector with entries 0 or 1, indicating if an event was observed (TRUE or 1) or the time is censored (FALSE or 0) |
group |
Vector of group allocations |
alternative |
Either of |
rho |
Vector of parameter values rho for a set of weighting functions in the rho-gamma family |
gamma |
Vector of parameter values gamma for a set of weighting functions in the rho-gamma family |
event_time_weights |
Optional matrix, each column containing a different weighting vector for the event times. These weight vectors need to have one entry per event time (not per event, as multiple events may occur at the same time) and must be sorted by increasing event time. |
algorithm |
algorithm for the multivariate normal integration to be used in |
To perform a maximum-type combination test, a set of different weight
functions
is specified and the correspondingly
weighted logrank statistics
are calculated. The maximum
test statistic is
. If at least one of
the selected weight functions results in high power, we may expect a large
value of
.
Under the least favorable configuration in
, approximately
. The p-value of the maximum
test,
,
is calculated based on this multivariate normal approximation via numeric integration.
The integration is done using
pmvnorm
. The default settings in
logrank.maxtest
correspond to greater precision than the original default of
pmvnorm
. Precision can be set via the argument algorithm
.
Lower precision settings may speed up caclulation.
The multivariate normal approach automatically corrects for multiple testing with
different weights and does so efficiently since the correlation between the different
tests is incorporated in . For actual calculations,
is
replaced by an estimate.
A list with elements:
pmult
The two sided p-value for the null hypothesis of equal hazard functions in both groups, based on the multivariate normal approximation for the z-statistics of differently weighted log-rank tests.
p.Bonf
The two sided p-value for the null hypothesis of equal hazard functions in both groups, based on a Bonferroni multiplicity adjustment for differently weighted log-rank tests.
tests
Data frame with z-statistics and two-sided unadjusted p-values of the individual weighted log-rank tests
korr
Estimated correlation matrix for the z-statistics of the differently weighted log-rank tests.
Robin Ristl, [email protected]
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
Pranab Ghosh, Robin Ristl, Franz König, Martin Posch, Christopher Jennison, Heiko Götte, Armin Schüler, Cyrus Mehta. Robust group sequential designs for trials with survival endpoints and delayed response. Biometrical Journal. First published online: 21 December 2021
Tarone RE. On the distribution of the maximum of the logrank statistic and the modified wilcoxon statistic. Biometrics. 1981; 37:79-85.
Lee S-H. On the versatility of the combination of the weighted log-rank statistics. Comput Stat Data Anal. 2007; 51(12):6557-6564.
Karrison TG et al. Versatile tests for comparing survival curves based on weighted log-rank statistics. Stata J. 2016; 16(3):678-690.
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) B <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) dat <- sample_fun(A, B, r0 = 0.5, eventEnd = 30, lambdaRecr = 0.5, lambdaCens = 0.25 / 365, maxRecrCalendarTime = 2 * 365, maxCalendar = 4 * 365) logrank.maxtest(dat$y, dat$event, dat$group)
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) B <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) dat <- sample_fun(A, B, r0 = 0.5, eventEnd = 30, lambdaRecr = 0.5, lambdaCens = 0.25 / 365, maxRecrCalendarTime = 2 * 365, maxCalendar = 4 * 365) logrank.maxtest(dat$y, dat$event, dat$group)
Calculates a weighted log-rank test for the comparison of two groups.
logrank.test( time, event, group, alternative = c("two.sided", "less", "greater"), rho = 0, gamma = 0, event_time_weights = NULL )
logrank.test( time, event, group, alternative = c("two.sided", "less", "greater"), rho = 0, gamma = 0, event_time_weights = NULL )
time |
Vector of observed event/censored times |
event |
logical vector or numeric vector with entries 0 or 1, indicating if an event was observed (TRUE or 1) or the time is censored (FALSE or 0) |
group |
Vector of group allocations |
alternative |
Either of |
rho |
Parameter to calculate weights in the rho-gamma family |
gamma |
Parameter to calculate weights in the rho-gamma family |
event_time_weights |
Optional vector of user defined weights. This weight vector needs to have one entry per event time (not per event, as multiple events may occur at the same time) and must be sorted by increasing event time. |
For a given sample, let be the set of unique event times.
For a time-point
, let
and
be
the number of patients at risk in the control and treatment group and let
and
be the respective number of events.
The expected number of events in the control group is calculated under the
least favorable configuration in
,
, as
. The conditional variance of
is calculated from a hypergeometric distribution as
.
Further define a weighting function
.
The weighted logrank test statistic for a comparison of two groups is
Under the the least favorable configuration in ,
the test statistic is asymptotically standard normally distributed and large
values of
are in favor of the alternative.
The function consider particular weights in the Fleming-Harrington
family
.
Here,
is the pooled sample Kaplan-Meier estimator.
(Note: Prior to package version 2.1,
was used in the definition of
weights,
this was changed to
with version 2.1.)
Weights
correspond to the standard logrank test with
constant weights
. Choosing
puts more weight on
late events,
puts more weight on early events and
puts most weight on events at intermediate time points.
A list with elements:
D
A data frame event numbers, numbers at risk and expected number of events for each event time
test
A data frame containing the z and chi-squared statistic for the one-sided and two-sided test, respectively, of the null hypothesis of equal hazard functions in both groups and the p-value for the one-sided test.
var
The estimated variance of the sum of expected minus observed events in the first group.
Robin Ristl, [email protected]
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
Thomas R Fleming and David P Harrington. Counting processes and survival analysis. John Wiley & Sons, 2011
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) B <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) dat <- sample_fun(A, B, r0 = 0.5, eventEnd = 30, lambdaRecr = 0.5, lambdaCens = 0.25 / 365, maxRecrCalendarTime = 2 * 365, maxCalendar = 4 * 365) logrank.test(dat$y, dat$event, dat$group)
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) B <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) dat <- sample_fun(A, B, r0 = 0.5, eventEnd = 30, lambdaRecr = 0.5, lambdaCens = 0.25 / 365, maxRecrCalendarTime = 2 * 365, maxCalendar = 4 * 365) logrank.test(dat$y, dat$event, dat$group)
This helper function calculates the hazard rate per day of an exponential distribution from the median given in months.
m2r(x)
m2r(x)
x |
The median time in months to be transformed into rate |
Launch a GUI (shiny app) for the nph package
nph_gui()
nph_gui()
The packages shinycssloaders
, formatR
and styler
are required for correct display of the GUI.
The package rmarkdown
with access to pandoc is required to save reports.
Hypothesis tests with parametric multiple testing adjustment and simultaneous confidence intervals for a set of parameters, which quantify differences between two survival functions. Eligible parameters are differences in survival probabilities, log survival probabilities, complementary log log (cloglog) transformed survival probabilities, quantiles of the survival functions, log transformed quantiles, restricted mean survival times, as well as an average hazard ratio, the Cox model score statistic (logrank statistic), and the Cox-model hazard ratio.
nphparams( time, event, group, data = parent.frame(), param_type, param_par = NA, param_alternative = NA, lvl = 0.95, closed_test = FALSE, alternative_test = "two.sided", alternative_CI = "two.sided", haz_method = "local", rhs = 0, perturb = FALSE, Kpert = 500 )
nphparams( time, event, group, data = parent.frame(), param_type, param_par = NA, param_alternative = NA, lvl = 0.95, closed_test = FALSE, alternative_test = "two.sided", alternative_CI = "two.sided", haz_method = "local", rhs = 0, perturb = FALSE, Kpert = 500 )
time |
vector of observed event/censored times. |
event |
Vector with entries 0 or 1 (or FALSE/TRUE) indicating if an event was observed (1) or the time is censored (0). |
group |
group indicator, must be a vector with entries 0 or 1 indicating the allocation of a subject to one of two groups. Group 0 is regarded as reference group when calculating parameters. |
data |
an optional data frame containing the time, event and group data. |
param_type |
character vector defining the set of parameters that should be analysed. Possible entries are "S","logS","cloglogS", "Q","logQ","RMST","avgHR","score" and "HR", representing differences in survival probabilities, log survival probabilities, complementary log log (cloglog) transformed survival probabilities, quantiles of the survival functions, log transformed quantiles, restricted mean survival times, as well as an average hazard ratio, the Cox model score statistic (logrank statistic), and the Cox-model hazard ratio. |
param_par |
numeric vector which contains the time points at which the requested parameters are evaluated (e.g. x-year survival or RMST after x-years),
or, in case of analysing quantiles, the according probability. May be |
param_alternative |
optional character vector with entries "less" or "greater", defining the alternative for each parameter. Only required if one-sided tests or one-sided confidence intervals are requested. Note that group 0 is regarded as reference group when calculating parameters and therefore whether "greater" or "less" corresponds to a benefit may depend on the type of parameter. In general, to show larger survival in group 1 compared to group 0, alternatives would be "greater" for parameter types "S", "logS", "Q", "logQ" and "RMST" and would be "less" for parameters types "cloglogS", "avgHR","HR", and "score". (The score test is defined here such that alternative "less" corresponds to smaller hazard (and better survival) in group 1 compared to group 0.) |
lvl |
Confidence level. Applies to, both, unadjusted and multiplicity adjusted (simultaneous) confidence intervals. |
closed_test |
logical indicating whether p-values should be adjusted using a closed testing procedure. Default is |
alternative_test |
character with possible values "tow.sided" (default) or "one-sided". Specifies whether hypothesis tests should be two-sided or one-sided. In the #' latter case, |
alternative_CI |
character with possible values "tow.sided" (default) or "one-sided". Specifies whether confidence intervals should be two-sided or one-sided.
In the latter case, |
haz_method |
character with possible values "local" or "muhaz". Specifies whether local hazard should be calculated under a local constant hazard assumption (default) #' or using the function |
rhs |
right-hand side vector of null hypotheses. Refers to log-scaled difference for ratios. Default is to consider for all null hypothesis a difference of 0. |
perturb |
logical, indicating whether the perturbation based estiamte should be used instead of the asymptotic estimate to calculate the covariance matrix.
Defaults to |
Kpert |
The number of perturbation samples to be used with the perturbation approach for covariance estimation. |
A list of class nphparams
with elements:
est
Estimated differences (at log-scale in case of ratios).
V
Estimated covariance matrix of differences.
tab
A data frame with analysis results. Contains the parameter type (Parameter) and settings (Time_or_which_quantile), the estimated difference (Estimate), its standard error (SE), unadjusted confidence interval lower and upper bounds (lwr_unadjusted, upr_unadjusted), unadjusted p-values (p_unadj), mulitplicity adjusted confidence interval lower and upper bounds (lwr_adjusted, upr_adjusted), single-step multiplcity adjusted p-values (p_adj), closed-test adjusted p-values, if requested (p_adjusted_closed_test) and for comparison Bonferroni-Holm adjusted p-values (p_Holm).
param
The used parameter settings. If param_par
was NA
for "HR","avgHR" or "RMST", it is replaced by minmaxt
here.
paramin
The parameter settings as provided to the function. The only difference to param
is in param_par
, as NA
is not replaced here.
dat0
A data frame with information on all observed events in group 0. Contains time (t), number of events (ev), Nelson-Aalen estimate (NAsurv) and Kaplan-Meier estimate (KMsurv) of survival, and the number at risk (atrisk).
dat1
A data frame with information on all observed events in group 1. Contains time (t), number of events (ev), Nelson-Aalen estimate (NAsurv) and Kaplan-Meier estimate (KMsurv) of survival, and the number at risk (atrisk).
minmaxt
Minimum of the largest event times of the two groups.
est0
Estimated parameter values in group 0.
est1
Estimated parameter values in group 1.
V0
Estimated covariance matrix of parameter estimates in group 0.
V1
Estimated covariance matrix of parameter estimates in group 1.
Robin Ristl, [email protected]
print.nphparams
, plot.nphparams
data(pembro) set1<-nphparams(time=time, event=event, group=group,data=pembro, param_type=c("score","S"), param_par=c(3.5,2), param_alternative=c("less","greater"), closed_test=TRUE,alternative_test="one.sided") print(set1) plot(set1,trt_name="Pembrolizumab",ctr_name="Cetuximab") set2<-nphparams(time=time, event=event, group=group, data=pembro, param_type=c("S","S","S","Q","RMST"), param_par=c(0.5,1,2,0.5,3.5)) print(set2) plot(set2,showlines=TRUE,show_rmst_diff=TRUE) #Create a summary table for set2, showing parameter estimates for each group and the #estimated differences between groups. Also show unadjusted and multiplicity adjusted #confidence intervals using the multivariate normal method and, for comparison, #Bonferroni adjusted confidence intervals: set2Bonf<-nphparams(time=time, event=event, group=group, data=pembro, param_type=c("S","S","S","Q","RMST"), param_par=c(0.5,1,2,0.5,3.5), lvl=1-0.05/5) KI_paste<-function(x,r) { x<-round(x,r) paste("[",x[,1],", ",x[,2],"]",sep="") } r<-3 tab<-data.frame( Parameter=paste(set2$tab[,1],set2$tab[,2]), Pembrolizumab=round(set2$est1,r), Cetuximab=round(set2$est0,r), Difference=round(set2$tab$Estimate,r), CI_undadj=KI_paste(set2$tab[,5:6],r), CI_adj=KI_paste(set2$tab[,8:9],r), CI_Bonf=KI_paste(set2Bonf$tab[,c(5:6)],r)) tab
data(pembro) set1<-nphparams(time=time, event=event, group=group,data=pembro, param_type=c("score","S"), param_par=c(3.5,2), param_alternative=c("less","greater"), closed_test=TRUE,alternative_test="one.sided") print(set1) plot(set1,trt_name="Pembrolizumab",ctr_name="Cetuximab") set2<-nphparams(time=time, event=event, group=group, data=pembro, param_type=c("S","S","S","Q","RMST"), param_par=c(0.5,1,2,0.5,3.5)) print(set2) plot(set2,showlines=TRUE,show_rmst_diff=TRUE) #Create a summary table for set2, showing parameter estimates for each group and the #estimated differences between groups. Also show unadjusted and multiplicity adjusted #confidence intervals using the multivariate normal method and, for comparison, #Bonferroni adjusted confidence intervals: set2Bonf<-nphparams(time=time, event=event, group=group, data=pembro, param_type=c("S","S","S","Q","RMST"), param_par=c(0.5,1,2,0.5,3.5), lvl=1-0.05/5) KI_paste<-function(x,r) { x<-round(x,r) paste("[",x[,1],", ",x[,2],"]",sep="") } r<-3 tab<-data.frame( Parameter=paste(set2$tab[,1],set2$tab[,2]), Pembrolizumab=round(set2$est1,r), Cetuximab=round(set2$est0,r), Difference=round(set2$tab$Estimate,r), CI_undadj=KI_paste(set2$tab[,5:6],r), CI_adj=KI_paste(set2$tab[,8:9],r), CI_Bonf=KI_paste(set2Bonf$tab[,c(5:6)],r)) tab
Calculates hazard, cumulative hazard, survival and distribution function based on hazards that are constant over pre-specified time-intervals.
pchaz(Tint, lambda)
pchaz(Tint, lambda)
Tint |
vector of length |
lambda |
vector of length |
Given time intervals
with
, the function assume constant hazards
at each interval.
The resulting hazard function is
,
the cumulative hazard function is\
and the survival function
.
The output includes the functions values calculated for all integer time points
between 0 and the maximum of
Tint
.
Additionally, a list with functions is also given to calculate the values at any arbitrary point .
A list with class mixpch
containing the following components:
haz
Values of the hazard function over discrete times t.
cumhaz
Values of the cumulative hazard function over discrete times t.
S
Values of the survival function over discrete times t.
F
Values of the distribution function over discrete times t.
t
Time points for which the values of the different functions are calculated.
Tint
Input vector of boundaries of time intervals.
lambda
Input vector of piecewise constant hazards.
funs
A list with functions to calculate the hazard, cumulative hazard, survival, pdf and cdf over arbitrary continuous times.
Robin Ristl, [email protected], Nicolas Ballarini
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
subpop_pchaz
, pop_pchaz
, plot.mixpch
pchaz(Tint = c(0, 40, 100), lambda=c(.02, .05))
pchaz(Tint = c(0, 40, 100), lambda=c(.02, .05))
The data set was approximately reconstructed from the survival curves shown in Figure 2D of Burtness et al. 2019 (see references). It contains survival times and event #' indicator under treatment with pembrolizumab (group 1) versus cetuximab with chemotherapy (group 0).
data(pembro)
data(pembro)
A data frame.
Burtness, B., Harrington, K. J., Greil, R., Soulières, D., Tahara, M., de Castro Jr, G., ... & Abel, E. (2019). Pembrolizumab alone or with chemotherapy versus cetuximab with chemotherapy for recurrent or metastatic squamous cell carcinoma of the head and neck (KEYNOTE-048): a randomised, open-label, phase 3 study. The Lancet, 394(10212), 1915-1928.
data(pembro) head(pembro)
data(pembro) head(pembro)
A figure that shows the states and the possible transitions between them.
plot_diagram( A, B, A_subgr_labels = "", B_subgr_labels = "", which = c("Both", "Experimental", "Control"), treatment_labels = c("Experimental", "Control"), colors = "default", show.rate = TRUE )
plot_diagram( A, B, A_subgr_labels = "", B_subgr_labels = "", which = c("Both", "Experimental", "Control"), treatment_labels = c("Experimental", "Control"), colors = "default", show.rate = TRUE )
A |
An object of class |
B |
An object of class |
A_subgr_labels |
A character vector with the same length as A$p. It indicates names for the subgroups in A |
B_subgr_labels |
A character vector with the same length as B$p. It indicates names for the subgroups in B |
which |
Which treatment arm should be shown? One of "Both", "Experimental", "Control". |
treatment_labels |
A character vector of length 2 indicating the treatment labels. |
colors |
Either a vector of length two with colors for A and B, or "default". |
show.rate |
A logical indicating whether the rate should be shown in the diagram |
A convenience function that uses the generic plot function in the nph package to plot the three functions in a layout of 3 columns and 1 row.
plot_shhr(A, B, main = "", xmax = NULL, ymax_haz = NULL, ymax_hr = NULL)
plot_shhr(A, B, main = "", xmax = NULL, ymax_haz = NULL, ymax_hr = NULL)
A |
An object of class |
B |
An object of class |
main |
An overall title for the plot |
xmax |
A maximum value for the x-axis. The plot is drawn using xlim = c(0, xmax) |
ymax_haz |
A maximum value for the y-axis for the hazards plot. The plot is drawn using ylim = c(0, ymax_haz) |
ymax_hr |
A maximum value for the y-axis for the hazards ratio plot. The plot is drawn using ylim = c(0, ymax_hr) |
A figure that shows the composition of the population under study though time
plot_subgroups( A, B, colors = "default", max_time = max(A$Tint), position = c("stack", "fill"), title = "" )
plot_subgroups( A, B, colors = "default", max_time = max(A$Tint), position = c("stack", "fill"), title = "" )
A |
An object of class |
B |
An object of class |
colors |
Either a vector of length four with colors for A and B and subgroup 1 and 2, or "default". |
max_time |
the maximum value for the x-axis. |
position |
Either "stack" or "fill". By default (stack), the total population decreases through time. If position="fill", the size of the population is rescaled to show conditional percentages. |
title |
The text for the title. |
Robin Ristl, [email protected], Nicolas Ballarini
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
A <- pop_pchaz(Tint = c(0, 90, 365), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) B <- pop_pchaz(Tint = c(0, 90, 365), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) plot_subgroups(A, B, title = "position='stack'") plot_subgroups(A, B, position='fill', title = "position='fill'")
A <- pop_pchaz(Tint = c(0, 90, 365), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) B <- pop_pchaz(Tint = c(0, 90, 365), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) plot_subgroups(A, B, title = "position='stack'") plot_subgroups(A, B, position='fill', title = "position='fill'")
Plots survival and other functions stored in mixpch
objects versus time.
## S3 method for class 'mixpch' plot( x, fun = c("S", "F", "haz", "cumhaz"), add = FALSE, ylab = fun, xlab = "Time", ... )
## S3 method for class 'mixpch' plot( x, fun = c("S", "F", "haz", "cumhaz"), add = FALSE, ylab = fun, xlab = "Time", ... )
x |
an object of class |
fun |
character string in |
add |
logical, indicates if the drawing should be added to an existing plot. |
ylab |
label of the y-axis |
xlab |
label of the x-axis |
... |
further arguments passed to the plotting functions |
Robin Ristl, [email protected]
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
pchaz
, subpop_pchaz
, pop_pchaz
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) plot(A) plot(A, "haz", add = TRUE)
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) plot(A) plot(A, "haz", add = TRUE)
Plots the estimated survival distributions, shows numbers at risk and indicates the requested parameters for quantifying differences between the survival curves.
## S3 method for class 'nphparams' plot( x, xlim = NULL, ylim = c(0, 1), trt_name = "Treatment", ctr_name = "Control", xlab = "Time", ylab = "Survival", main = "", col_ctr = 1, col_trt = 2, atrisktimes = 0:3, bold = 2, showlines = FALSE, show_rmst_diff = FALSE, ... )
## S3 method for class 'nphparams' plot( x, xlim = NULL, ylim = c(0, 1), trt_name = "Treatment", ctr_name = "Control", xlab = "Time", ylab = "Survival", main = "", col_ctr = 1, col_trt = 2, atrisktimes = 0:3, bold = 2, showlines = FALSE, show_rmst_diff = FALSE, ... )
x |
an object of class |
xlim |
limits of the x-axis, must be a numeric vector of length two |
ylim |
limits of the y-axis, must be a numeric vector of length two |
trt_name |
character, an optional name for group 1 to be shown with the number at risk table in the plot. Default is "Treatment". |
ctr_name |
character, an optional name for group 0 to be shown with the number at risk table in the plot. Default is "Control". |
xlab |
character, an optional label for the x-axis. Default is "Time". |
ylab |
character, an optional label for the x-axis. Default is "Survival". |
main |
character, an optional title of the plot. Default is "", showing no title. |
col_ctr |
the color of the survival curve estimate of group 0. Default is 1 (black). |
col_trt |
the color of the survival curve estimate of group 1. Default is 2 (red). |
atrisktimes |
numeric vector of time-points for which the number at risk is displayed. |
bold |
numeric, passed to linewidth and font settings. Default is 2, resulting in lines of width 2 and boldfont. Use 1 for line-width 1 and standard font. |
showlines |
logical, indicating whether the time-points or the quantile-probabilites defined
for the requested parametes should be shown in terms of vertical or horizontal lines. Default is |
show_rmst_diff |
logical, indicating whether the estiamted difference in restricted mean survival times should by visualized by a gray background area. |
... |
further arguments, not used |
When setting show_lines
, line type 2 (dashed) is used for survival probabilities and quantiles, line type
3 (dotted) is used for the score test, average hazard ratio and Cox model hazard ratio and
line type 5 (long dashed) is used for restricted mean survival time.
Robin Ristl, [email protected]
data(pembro) set1<-nphparams(time=time, event=event, group=group,data=pembro, param_type=c("score","S"), param_par=c(3.5,2), param_alternative=c("less","greater"), closed_test=TRUE,alternative_test="one.sided") print(set1) plot(set1,trt_name="Pembrolizumab",ctr_name="Cetuximab") set2<-nphparams(time=time, event=event, group=group, data=pembro, param_type=c("S","S","S","Q","RMST"), param_par=c(0.5,1,2,0.5,3.5)) print(set2) plot(set2,showlines=TRUE,show_rmst_diff=TRUE)
data(pembro) set1<-nphparams(time=time, event=event, group=group,data=pembro, param_type=c("score","S"), param_par=c(3.5,2), param_alternative=c("less","greater"), closed_test=TRUE,alternative_test="one.sided") print(set1) plot(set1,trt_name="Pembrolizumab",ctr_name="Cetuximab") set2<-nphparams(time=time, event=event, group=group, data=pembro, param_type=c("S","S","S","Q","RMST"), param_par=c(0.5,1,2,0.5,3.5)) print(set2) plot(set2,showlines=TRUE,show_rmst_diff=TRUE)
Calculates hazard, cumulative hazard, survival and distribution function based on hazards that are constant over pre-specified time-intervals
pop_pchaz( Tint, lambdaMat1, lambdaMat2, lambdaProgMat, p, timezero = FALSE, int_control = list(rel.tol = .Machine$double.eps^0.4, abs.tol = 1e-09), discrete_approximation = FALSE )
pop_pchaz( Tint, lambdaMat1, lambdaMat2, lambdaProgMat, p, timezero = FALSE, int_control = list(rel.tol = .Machine$double.eps^0.4, abs.tol = 1e-09), discrete_approximation = FALSE )
Tint |
vector of length |
lambdaMat1 |
matrix of dimension |
lambdaMat2 |
matrix of dimension |
lambdaProgMat |
matrix of dimension |
p |
vector of length |
timezero |
logical, indicating whether after the changing event the timecount, governing which interval in |
int_control |
A list with additional paramaters to be passed to the |
discrete_approximation |
if TRUE, the function uses an approximation based on discretizing the time, instead of integrating. This speeds up the calculations |
Given subgroups with relative sizes
and
subgroup-specific survival functions
,
the marginal survival function is the mixture
.
Note that the respective hazard function is not a linear combination of the
subgroup-specific hazard functions.
It may be calculated by the general relation
.
In each subgroup, the hazard is modelled as a piecewise constant hazard, with
the possibility to also model disease progression.
Therefore, each row of the hazard rates is used in
subpop_pchaz
.
See pchaz
and subpop_pchaz
for more details.
The output includes the function values calculated for all integer time points
between 0 and the maximum of Tint
.
Note: this function may be very slow in cases where many time points need to be calculated. If this happens, use
discrete_approximation = TRUE
.
A list with class mixpch
containing the following components:
haz
Values of the hazard function.
cumhaz
Values of the cumulative hazard function.
S
Values of the survival function.
F
Values of the distribution function.
t
Time points for which the values of the different functions are calculated.
Robin Ristl, [email protected], Nicolas Ballarini
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
pchaz
, subpop_pchaz
, plot.mixpch
pop_pchaz(Tint = c(0, 40, 100), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2), lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2), lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2), p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE)
pop_pchaz(Tint = c(0, 40, 100), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2), lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2), lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2), p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE)
Prints the results table of an nphparams object.
## S3 method for class 'nphparams' print(x, ...)
## S3 method for class 'nphparams' print(x, ...)
x |
an object of class |
... |
further arguments, not used. |
Estiamtes corresponding to differences at a log scale are transformed by taking exp(), and are labelled as ratios. I.e. differnces in log urvival probabilites, differences in log quantiles, cloglog survival differences (equivalent to the log cumulative hazard ratio), log average hazard ratios or Cox model log hazard ratioss are transformed to survival probability ratios, quantile ratios, cumulative hazard ratios, average hazard ratios or Cox model hazard ratios, respectively. In the output, the standard error at the backtransformed scale is calculated by the delta-method. Confidence interval bounds are calculated at the log-scale, though, and then transformed by taking exp().
Robin Ristl, [email protected]
data(pembro) set1<-nphparams(time=time, event=event, group=group,data=pembro, param_type=c("score","S"), param_par=c(3.5,2), param_alternative=c("less","greater"), closed_test=TRUE,alternative_test="one.sided") print(set1) plot(set1,trt_name="Pembrolizumab",ctr_name="Cetuximab") set2<-nphparams(time=time, event=event, group=group, data=pembro, param_type=c("S","S","S","Q","RMST"), param_par=c(0.5,1,2,0.5,3.5)) print(set2) plot(set2,showlines=TRUE,show_rmst_diff=TRUE)
data(pembro) set1<-nphparams(time=time, event=event, group=group,data=pembro, param_type=c("score","S"), param_par=c(3.5,2), param_alternative=c("less","greater"), closed_test=TRUE,alternative_test="one.sided") print(set1) plot(set1,trt_name="Pembrolizumab",ctr_name="Cetuximab") set2<-nphparams(time=time, event=event, group=group, data=pembro, param_type=c("S","S","S","Q","RMST"), param_par=c(0.5,1,2,0.5,3.5)) print(set2) plot(set2,showlines=TRUE,show_rmst_diff=TRUE)
Draws independent random survival times from mixpch
objects conditional on
observed time.
rSurv_conditional_fun(x, y)
rSurv_conditional_fun(x, y)
x |
An object of class |
y |
A vector of observed right censored times |
Note that the mixpch object stores the survival function up to some time T. For random times equal or larger T, the value T is returned.
A vector of random survival times, conditional on the observed censored times.
Robin Ristl, [email protected]
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
rSurv_fun
, sample_fun
, sample_conditional_fun
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) rSurv_conditional_fun(x = A, y = c(10,15,9,2,1))
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) rSurv_conditional_fun(x = A, y = c(10,15,9,2,1))
Draws independent random survival times from mixpch
objects.
rSurv_fun(n, x)
rSurv_fun(n, x)
n |
Number of random draws |
x |
An object of class |
The mixpch object stores the survival function up to some time T. For random times equal or larger T, the value T is returned.
A vector of random survival times.
Robin Ristl, [email protected]
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
rSurv_conditional_fun
, sample_fun
, sample_conditional_fun
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) rSurv_fun(n = 10, x = A)
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) rSurv_fun(n = 10, x = A)
Simulates data for a randomized controlled survival study conditional on observed interim data.
sample_conditional_fun( dat, A, B, r0 = 0.5, eventEnd, lambdaRecr, lambdaCens, maxRecrCalendarTime, maxCalendar )
sample_conditional_fun( dat, A, B, r0 = 0.5, eventEnd, lambdaRecr, lambdaCens, maxRecrCalendarTime, maxCalendar )
dat |
A data frame with the same structure and column names as the output of |
A |
An object of class |
B |
An object of class |
r0 |
Allocation ratio to group 1 (must be a number between 0 and 1) |
eventEnd |
Number of events, after which the study stops |
lambdaRecr |
Rate per day for recruiting patients, assuming recruitung follows a Poisson process |
lambdaCens |
Rate per day for random censoring, assuming censoring times are exponential |
maxRecrCalendarTime |
Maximal duration of recruitment in days |
maxCalendar |
Maximal total study duration in days, after which the study stops |
For simulating the data, patients are allocated randomly to either group (unrestricted randomization).
A data frame with each line representing data for one patient and the following columns:
group
Treatment group
inclusion
Start of observation in terms of calendar time
y
Observed survival/censored time
yCalendar
End of observation in terms of calendar time.
event
logical, TRUE
indicates the observation ended with an event, FALSE
corresponds to censored times
adminCens
logical, True
indicates that the observation is subject to administrative censoring, i.e. the subject was observed until the
end of the study without an event.
cumEvents
Cumulative number of events over calendar time of end of observation
The data frame is ordered by yCalendar
Robin Ristl, [email protected]
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
rSurv_fun
, rSurv_conditional_fun
, sample_fun
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) B <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) datinterim <- sample_fun(A, B, r0 = 0.5, eventEnd = 30, lambdaRecr = 1, lambdaCens = 0.25 / 365, maxRecrCalendarTime = 3 * 365, maxCalendar = 4 * 365) datcond <- sample_conditional_fun(datinterim, A, B, r0 = 0.5, eventEnd = 60, lambdaRecr = 1, lambdaCens = 0.25 / 365, maxRecrCalendarTime = 3 * 365, maxCalendar = 4 * 365)
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) B <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) datinterim <- sample_fun(A, B, r0 = 0.5, eventEnd = 30, lambdaRecr = 1, lambdaCens = 0.25 / 365, maxRecrCalendarTime = 3 * 365, maxCalendar = 4 * 365) datcond <- sample_conditional_fun(datinterim, A, B, r0 = 0.5, eventEnd = 60, lambdaRecr = 1, lambdaCens = 0.25 / 365, maxRecrCalendarTime = 3 * 365, maxCalendar = 4 * 365)
Simulates data for a randomized controlled survival study.
sample_fun( A, B, r0 = 0.5, eventEnd, lambdaRecr, lambdaCens, maxRecrCalendarTime, maxCalendar )
sample_fun( A, B, r0 = 0.5, eventEnd, lambdaRecr, lambdaCens, maxRecrCalendarTime, maxCalendar )
A |
An object of class |
B |
An object of class |
r0 |
Allocation ratio to group 0 (must be a number between 0 and 1) |
eventEnd |
Number of events, after which the study stops |
lambdaRecr |
Rate per day for recruiting patients, assuming recruitung follows a Poisson process |
lambdaCens |
Rate per day for random censoring, assuming censoring times are exponential |
maxRecrCalendarTime |
Maximal duration of recruitment in days |
maxCalendar |
Maximal total study duration in days, after which the study stops |
For simulating the data, patients are allocated randomly to either group (unrestricted randomization).
A data frame with each line representing data for one patient and the following columns:
group
Treatment group
inclusion
Start of observation in terms of calendar time
y
Observed survival/censored time
yCalendar
End of observation in terms of calendar time.
event
logical, TRUE
indicates the observation ended with an event, FALSE
corresponds to censored times
adminCens
logical, True
indicates that the observation is subject to administrative censoring, i.e. the subject was observed until the
end of the study without an event.
cumEvents
Cumulative number of events over calendar time of end of observation
The data frame is ordered by yCalendar
Robin Ristl, [email protected]
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
rSurv_fun
, rSurv_conditional_fun
, sample_conditional_fun
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) B <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) plot(A) plot(B, add = TRUE) dat <- sample_fun(A, B, r0 = 0.5, eventEnd = 30, lambdaRecr = 0.5, lambdaCens = 0.25 / 365, maxRecrCalendarTime = 2 * 365, maxCalendar = 4 * 365)
A <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) B <- pop_pchaz(Tint = c(0, 90, 1500), lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365, lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365, lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365, p = c(0.8, 0.2), timezero = FALSE, discrete_approximation = TRUE) plot(A) plot(B, add = TRUE) dat <- sample_fun(A, B, r0 = 0.5, eventEnd = 30, lambdaRecr = 0.5, lambdaCens = 0.25 / 365, maxRecrCalendarTime = 2 * 365, maxCalendar = 4 * 365)
Calculates hazard, cumulative hazard, survival and distribution function based on hazards that are constant over pre-specified time-intervals
subpop_pchaz( Tint, lambda1, lambda2, lambdaProg, timezero = FALSE, int_control = list(rel.tol = .Machine$double.eps^0.4, abs.tol = 1e-09), discrete_approximation = FALSE )
subpop_pchaz( Tint, lambda1, lambda2, lambdaProg, timezero = FALSE, int_control = list(rel.tol = .Machine$double.eps^0.4, abs.tol = 1e-09), discrete_approximation = FALSE )
Tint |
vector of length |
lambda1 |
vector of length |
lambda2 |
vector of length |
lambdaProg |
vector of length |
timezero |
logical, indicating whether after the changeing event the timecount, governing which interval in |
int_control |
A list with the |
discrete_approximation |
if TRUE, the function uses an approximation based on discretizing the time, instead of integrating. This speeds up the calculations |
We assume that the time to disease progression is governed
by a separate process with hazard function
,
which does not depend on the hazard function for death
.
, too, may be modelled as piecewise constant or, for simplicity,
as constant over time. We define
and
as the hazard functions for death before and after disease progression.
Conditional on
, the hazard function for death is
.
The conditional survival function is
.
The unconditional survival function results from integration over all
possible progression times as
.
The output includes the function values calculated for all integer time points
between 0 and the maximum of
Tint
.
Additionally, a list with functions is also given to calculate the values at any arbitrary point .
A list with class mixpch
containing the following components:
haz
Values of the hazard function.
cumhaz
Values of the cumulative hazard function.
S
Values of the survival function.
F
Values of the distribution function.
t
Time points for which the values of the different functions are calculated.
Tint
Input vector of boundaries of time intervals.
lambda1
Input vector of piecewise constant hazards before the changing event happen.
lambda2
Input vector of piecewise constant hazards after the changing event happen.
lambdaProg
Input vector of piecewise constant hazards for the changing event.
funs
A list with functions to calculate the hazard, cumulative hazard, survival, and cdf over arbitrary continuous times.
Robin Ristl, [email protected], Nicolas Ballarini
Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.
subpop_pchaz(Tint = c(0, 40, 100), lambda1 = c(0.2, 0.4), lambda2 = c(0.1, 0.01), lambdaProg = c(0.5, 0.4),timezero = FALSE, discrete_approximation = TRUE) subpop_pchaz(Tint = c(0, 40, 100), lambda1 = c(0.2, 0.4), lambda2 = c(0.1, 0.01), lambdaProg = c(0.5, 0.4), timezero = TRUE, discrete_approximation = TRUE)
subpop_pchaz(Tint = c(0, 40, 100), lambda1 = c(0.2, 0.4), lambda2 = c(0.1, 0.01), lambdaProg = c(0.5, 0.4),timezero = FALSE, discrete_approximation = TRUE) subpop_pchaz(Tint = c(0, 40, 100), lambda1 = c(0.2, 0.4), lambda2 = c(0.1, 0.01), lambdaProg = c(0.5, 0.4), timezero = TRUE, discrete_approximation = TRUE)