diff --git a/404.html b/404.html index f2967906..91e437db 100644 --- a/404.html +++ b/404.html @@ -1,66 +1,27 @@ - - -
- + + + + -Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
-This Code of Conduct is adapted from the Contributor Covenant (http:contributor-covenant.org), version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/
+This Code of Conduct is adapted from the Contributor Covenant (http:contributor-covenant.org), version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/
Developed by Sahir Bhatnagar, Maxime Turgeon, Jesse Islam, Olli Saarela, James Hanley.
+Developed by Sahir Bhatnagar, Maxime Turgeon, Jesse Islam, Olli Saarela, James Hanley.
Developed by Sahir Bhatnagar, Maxime Turgeon, Jesse Islam, Olli Saarela, James Hanley.
+Developed by Sahir Bhatnagar, Maxime Turgeon, Jesse Islam, Olli Saarela, James Hanley.
From this last plot, we can see that there is no censoring during the first 10 months. Moreover, we see that the last competing event occurs around 20 months. Putting all this information together, we have evidence of two types of patients: very sick patients who either relapse or have a competing event early on, and healthier patients who are eventually lost to follow-up.
+From this last plot, we can see that there is no censoring during the +first 10 months. Moreover, we see that the last competing event occurs +around 20 months. Putting all this information together, we have +evidence of two types of patients: very sick patients who either relapse +or have a competing event early on, and healthier patients who are +eventually lost to follow-up.
We now turn to the analysis of this dataset. The population-time plots above give evidence of non-constant hazard; therefore, we will explicitly include time in the model. Note that we also include all other variables as possible confounders. First, we include time as a linear term:
+We now turn to the analysis of this dataset. The population-time +plots above give evidence of non-constant hazard; therefore, we will +explicitly include time in the model. Note that we also include all +other variables as possible confounders. First, we include time as a +linear term:
-model1 <- fitSmoothHazard(Status ~ ftime + Sex + D + Phase + Source + Age,
- data = bmtcrr,
- ratio = 100,
- time = "ftime")
-summary(model1)
##
-## Call:
-## fitSmoothHazard(formula = Status ~ ftime + Sex + D + Phase +
-## Source + Age, data = bmtcrr, time = "ftime", ratio = 100)
-##
-## Coefficients:
-## Estimate Std. Error z value Pr(>|z|)
-## (Intercept):1 -3.527146 0.685168 -5.148 2.63e-07 ***
-## (Intercept):2 -2.648451 0.463012 -5.720 1.06e-08 ***
-## ftime:1 -0.070927 0.014929 -4.751 2.02e-06 ***
-## ftime:2 -0.105177 0.018349 -5.732 9.93e-09 ***
-## SexM:1 -0.289067 0.283217 -1.021 0.307418
-## SexM:2 -0.382981 0.236935 -1.616 0.106008
-## DAML:1 -0.575749 0.299617 -1.922 0.054654 .
-## DAML:2 -0.100149 0.274099 -0.365 0.714833
-## PhaseCR2:1 0.186766 0.467042 0.400 0.689237
-## PhaseCR2:2 0.286425 0.332270 0.862 0.388673
-## PhaseCR3:1 0.586630 0.696521 0.842 0.399660
-## PhaseCR3:2 0.310781 0.530986 0.585 0.558353
-## PhaseRelapse:1 1.448907 0.391878 3.697 0.000218 ***
-## PhaseRelapse:2 0.792938 0.307933 2.575 0.010023 *
-## SourcePB:1 0.456442 0.571108 0.799 0.424162
-## SourcePB:2 -1.013983 0.355666 -2.851 0.004359 **
-## Age:1 -0.005242 0.011917 -0.440 0.660007
-## Age:2 0.028597 0.009929 2.880 0.003976 **
-## ---
-## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
-##
-## Names of linear predictors: log(mu[,2]/mu[,1]), log(mu[,3]/mu[,1])
-##
-## Residual deviance: 1409.076 on 26444 degrees of freedom
-##
-## Log-likelihood: -704.5378 on 26444 degrees of freedom
-##
-## Number of Fisher scoring iterations: 10
-##
-## Warning: Hauck-Donner effect detected in the following estimate(s):
-## '(Intercept):1', '(Intercept):2', 'ftime:1', 'ftime:2'
-##
-##
-## Reference group is level 1 of the response
-Because of the results in Turgeon et al (n.d.), the standard errors we obtain from the multinomial logit fit are asymptotically correct, and therefore can be used to construct asymptotic confidence intervals.
-From this summary, we see that time is indeed significant, as is Phase (only relapse vs. CR1). Interestingly, we see that the type of disease is only significant for the event of interest, whereas the type of transplant and the age of the patient are only significant for the competing event.
-Next, we include the logarithm of time in the model (which leads to a Weibull hazard):
+model1 <- fitSmoothHazard(Status ~ ftime + Sex + D + Phase + Source + Age,
+ data = bmtcrr,
+ ratio = 100,
+ time = "ftime")
+summary(model1)
##
+## Call:
+## fitSmoothHazard(formula = Status ~ ftime + Sex + D + Phase +
+## Source + Age, data = bmtcrr, time = "ftime", ratio = 100)
+##
+## Coefficients:
+## Estimate Std. Error z value Pr(>|z|)
+## (Intercept):1 -3.527146 0.685168 -5.148 2.63e-07 ***
+## (Intercept):2 -2.648451 0.463012 -5.720 1.06e-08 ***
+## ftime:1 -0.070927 0.014929 -4.751 2.02e-06 ***
+## ftime:2 -0.105177 0.018349 -5.732 9.93e-09 ***
+## SexM:1 -0.289067 0.283217 -1.021 0.307418
+## SexM:2 -0.382981 0.236935 -1.616 0.106008
+## DAML:1 -0.575749 0.299617 -1.922 0.054654 .
+## DAML:2 -0.100149 0.274099 -0.365 0.714833
+## PhaseCR2:1 0.186766 0.467042 0.400 0.689237
+## PhaseCR2:2 0.286425 0.332270 0.862 0.388673
+## PhaseCR3:1 0.586630 0.696521 0.842 0.399660
+## PhaseCR3:2 0.310781 0.530986 0.585 0.558353
+## PhaseRelapse:1 1.448907 0.391878 3.697 0.000218 ***
+## PhaseRelapse:2 0.792938 0.307933 2.575 0.010023 *
+## SourcePB:1 0.456442 0.571108 0.799 0.424162
+## SourcePB:2 -1.013983 0.355666 -2.851 0.004359 **
+## Age:1 -0.005242 0.011917 -0.440 0.660007
+## Age:2 0.028597 0.009929 2.880 0.003976 **
+## ---
+## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
+##
+## Names of linear predictors: log(mu[,2]/mu[,1]), log(mu[,3]/mu[,1])
+##
+## Residual deviance: 1409.076 on 26444 degrees of freedom
+##
+## Log-likelihood: -704.5378 on 26444 degrees of freedom
+##
+## Number of Fisher scoring iterations: 10
+##
+## Warning: Hauck-Donner effect detected in the following estimate(s):
+## '(Intercept):1', '(Intercept):2', 'ftime:1', 'ftime:2'
+##
+##
+## Reference group is level 1 of the response
+Because of the results in Turgeon et al (In Preparation), the standard errors we obtain +from the multinomial logit fit are asymptotically correct, and therefore +can be used to construct asymptotic confidence intervals.
+From this summary, we see that time is indeed significant, as is +Phase (only relapse vs. CR1). Interestingly, we see that the type of +disease is only significant for the event of interest, whereas the type +of transplant and the age of the patient are only significant for the +competing event.
+Next, we include the logarithm of time in the model (which leads to a +Weibull hazard):
-model2 <- fitSmoothHazard(Status ~ log(ftime) + Sex + D + Phase + Source + Age,
- data = bmtcrr,
- ratio = 100,
- time = "ftime")
-summary(model2)
##
-## Call:
-## fitSmoothHazard(formula = Status ~ log(ftime) + Sex + D + Phase +
-## Source + Age, data = bmtcrr, time = "ftime", ratio = 100)
-##
-## Coefficients:
-## Estimate Std. Error z value Pr(>|z|)
-## (Intercept):1 -3.976762 0.699660 -5.684 1.32e-08 ***
-## (Intercept):2 -3.069308 0.465495 -6.594 4.29e-11 ***
-## log(ftime):1 -0.327063 0.069777 -4.687 2.77e-06 ***
-## log(ftime):2 -0.403220 0.056786 -7.101 1.24e-12 ***
-## SexM:1 -0.413731 0.291497 -1.419 0.15580
-## SexM:2 -0.521801 0.240157 -2.173 0.02980 *
-## DAML:1 -0.695303 0.306421 -2.269 0.02326 *
-## DAML:2 -0.180805 0.287170 -0.630 0.52895
-## PhaseCR2:1 0.252923 0.468205 0.540 0.58906
-## PhaseCR2:2 0.365004 0.332952 1.096 0.27296
-## PhaseCR3:1 0.441402 0.710580 0.621 0.53448
-## PhaseCR3:2 0.118189 0.535142 0.221 0.82521
-## PhaseRelapse:1 1.447889 0.394226 3.673 0.00024 ***
-## PhaseRelapse:2 0.821988 0.309721 2.654 0.00796 **
-## SourcePB:1 0.662955 0.598582 1.108 0.26806
-## SourcePB:2 -0.920304 0.370576 -2.483 0.01301 *
-## Age:1 -0.003153 0.011766 -0.268 0.78873
-## Age:2 0.028695 0.009869 2.908 0.00364 **
-## ---
-## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
-##
-## Names of linear predictors: log(mu[,2]/mu[,1]), log(mu[,3]/mu[,1])
-##
-## Residual deviance: 1508.083 on 26444 degrees of freedom
-##
-## Log-likelihood: -754.0415 on 26444 degrees of freedom
-##
-## Number of Fisher scoring iterations: 8
-##
-## Warning: Hauck-Donner effect detected in the following estimate(s):
-## '(Intercept):1', '(Intercept):2'
-##
-##
-## Reference group is level 1 of the response
-As we can see, the results are similar to the ones with a Gompertz hazard, although Sex is now significant for the competing event.
-Finally, using splines, we can be quite flexible about the way the hazard depends on time:
+model2 <- fitSmoothHazard(Status ~ log(ftime) + Sex + D + Phase + Source + Age,
+ data = bmtcrr,
+ ratio = 100,
+ time = "ftime")
+summary(model2)
##
+## Call:
+## fitSmoothHazard(formula = Status ~ log(ftime) + Sex + D + Phase +
+## Source + Age, data = bmtcrr, time = "ftime", ratio = 100)
+##
+## Coefficients:
+## Estimate Std. Error z value Pr(>|z|)
+## (Intercept):1 -3.976762 0.699660 -5.684 1.32e-08 ***
+## (Intercept):2 -3.069308 0.465495 -6.594 4.29e-11 ***
+## log(ftime):1 -0.327063 0.069777 -4.687 2.77e-06 ***
+## log(ftime):2 -0.403220 0.056786 -7.101 1.24e-12 ***
+## SexM:1 -0.413731 0.291497 -1.419 0.15580
+## SexM:2 -0.521801 0.240157 -2.173 0.02980 *
+## DAML:1 -0.695303 0.306421 -2.269 0.02326 *
+## DAML:2 -0.180805 0.287170 -0.630 0.52895
+## PhaseCR2:1 0.252923 0.468205 0.540 0.58906
+## PhaseCR2:2 0.365004 0.332952 1.096 0.27296
+## PhaseCR3:1 0.441402 0.710580 0.621 0.53448
+## PhaseCR3:2 0.118189 0.535142 0.221 0.82521
+## PhaseRelapse:1 1.447889 0.394226 3.673 0.00024 ***
+## PhaseRelapse:2 0.821988 0.309721 2.654 0.00796 **
+## SourcePB:1 0.662955 0.598582 1.108 0.26806
+## SourcePB:2 -0.920304 0.370576 -2.483 0.01301 *
+## Age:1 -0.003153 0.011766 -0.268 0.78873
+## Age:2 0.028695 0.009869 2.908 0.00364 **
+## ---
+## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
+##
+## Names of linear predictors: log(mu[,2]/mu[,1]), log(mu[,3]/mu[,1])
+##
+## Residual deviance: 1508.083 on 26444 degrees of freedom
+##
+## Log-likelihood: -754.0415 on 26444 degrees of freedom
+##
+## Number of Fisher scoring iterations: 8
+##
+## Warning: Hauck-Donner effect detected in the following estimate(s):
+## '(Intercept):1', '(Intercept):2'
+##
+##
+## Reference group is level 1 of the response
+As we can see, the results are similar to the ones with a Gompertz +hazard, although Sex is now significant for the competing event.
+Finally, using splines, we can be quite flexible about the way the +hazard depends on time:
-model3 <- fitSmoothHazard(
- Status ~ splines::bs(ftime) + Sex + D + Phase + Source + Age,
- data = bmtcrr,
- ratio = 100,
- time = "ftime")
-summary(model3)
##
-## Call:
-## fitSmoothHazard(formula = Status ~ splines::bs(ftime) + Sex +
-## D + Phase + Source + Age, data = bmtcrr, time = "ftime",
-## ratio = 100)
-##
-## Coefficients:
-## Estimate Std. Error z value Pr(>|z|)
-## (Intercept):1 -3.714285 0.697993 -5.321 1.03e-07 ***
-## (Intercept):2 -3.168984 0.498239 -6.360 2.01e-10 ***
-## splines::bs(ftime)1:1 -0.212237 2.256878 -0.094 0.925077
-## splines::bs(ftime)1:2 6.902278 3.669973 1.881 0.060007 .
-## splines::bs(ftime)2:1 -15.567038 8.068389 NA NA
-## splines::bs(ftime)2:2 -76.712396 25.661616 NA NA
-## splines::bs(ftime)3:1 -2.723383 10.472710 NA NA
-## splines::bs(ftime)3:2 -2.864418 22.204096 NA NA
-## SexM:1 -0.283588 0.282655 -1.003 0.315715
-## SexM:2 -0.420961 0.236815 -1.778 0.075470 .
-## DAML:1 -0.623451 0.301696 -2.066 0.038782 *
-## DAML:2 -0.127162 0.275996 -0.461 0.644985
-## PhaseCR2:1 0.120167 0.464896 0.258 0.796035
-## PhaseCR2:2 0.215708 0.330313 0.653 0.513729
-## PhaseCR3:1 0.494530 0.692452 0.714 0.475121
-## PhaseCR3:2 0.228801 0.525830 0.435 0.663473
-## PhaseRelapse:1 1.451148 0.392110 3.701 0.000215 ***
-## PhaseRelapse:2 0.821627 0.310515 2.646 0.008145 **
-## SourcePB:1 0.444775 0.571636 0.778 0.436526
-## SourcePB:2 -1.127417 0.358987 -3.141 0.001686 **
-## Age:1 -0.005600 0.011888 -0.471 0.637619
-## Age:2 0.028070 0.009914 2.831 0.004634 **
-## ---
-## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
-##
-## Names of linear predictors: log(mu[,2]/mu[,1]), log(mu[,3]/mu[,1])
-##
-## Residual deviance: 1402.024 on 26440 degrees of freedom
-##
-## Log-likelihood: -701.0122 on 26440 degrees of freedom
-##
-## Number of Fisher scoring iterations: 16
-##
-## Warning: Hauck-Donner effect detected in the following estimate(s):
-## '(Intercept):1', '(Intercept):2', 'splines::bs(ftime)2:1', 'splines::bs(ftime)2:2', 'splines::bs(ftime)3:1', 'splines::bs(ftime)3:2'
-##
-##
-## Reference group is level 1 of the response
-Again, we see that the results are quite similar for this third model.
-model3 <- fitSmoothHazard(
+ Status ~ splines::bs(ftime) + Sex + D + Phase + Source + Age,
+ data = bmtcrr,
+ ratio = 100,
+ time = "ftime")
+summary(model3)
##
+## Call:
+## fitSmoothHazard(formula = Status ~ splines::bs(ftime) + Sex +
+## D + Phase + Source + Age, data = bmtcrr, time = "ftime",
+## ratio = 100)
+##
+## Coefficients:
+## Estimate Std. Error z value Pr(>|z|)
+## (Intercept):1 -3.714285 0.697993 -5.321 1.03e-07 ***
+## (Intercept):2 -3.168984 0.498239 -6.360 2.01e-10 ***
+## splines::bs(ftime)1:1 -0.212237 2.256878 -0.094 0.925077
+## splines::bs(ftime)1:2 6.902278 3.669973 1.881 0.060007 .
+## splines::bs(ftime)2:1 -15.567038 8.068389 NA NA
+## splines::bs(ftime)2:2 -76.712396 25.661616 NA NA
+## splines::bs(ftime)3:1 -2.723383 10.472710 NA NA
+## splines::bs(ftime)3:2 -2.864418 22.204096 NA NA
+## SexM:1 -0.283588 0.282655 -1.003 0.315715
+## SexM:2 -0.420961 0.236815 -1.778 0.075470 .
+## DAML:1 -0.623451 0.301696 -2.066 0.038782 *
+## DAML:2 -0.127162 0.275996 -0.461 0.644985
+## PhaseCR2:1 0.120167 0.464896 0.258 0.796035
+## PhaseCR2:2 0.215708 0.330313 0.653 0.513729
+## PhaseCR3:1 0.494530 0.692452 0.714 0.475121
+## PhaseCR3:2 0.228801 0.525830 0.435 0.663473
+## PhaseRelapse:1 1.451148 0.392110 3.701 0.000215 ***
+## PhaseRelapse:2 0.821627 0.310515 2.646 0.008145 **
+## SourcePB:1 0.444775 0.571636 0.778 0.436526
+## SourcePB:2 -1.127417 0.358987 -3.141 0.001686 **
+## Age:1 -0.005600 0.011888 -0.471 0.637619
+## Age:2 0.028070 0.009914 2.831 0.004634 **
+## ---
+## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
+##
+## Names of linear predictors: log(mu[,2]/mu[,1]), log(mu[,3]/mu[,1])
+##
+## Residual deviance: 1402.024 on 26440 degrees of freedom
+##
+## Log-likelihood: -701.0122 on 26440 degrees of freedom
+##
+## Number of Fisher scoring iterations: 16
+##
+## Warning: Hauck-Donner effect detected in the following estimate(s):
+## '(Intercept):1', '(Intercept):2', 'splines::bs(ftime)2:1', 'splines::bs(ftime)2:2', 'splines::bs(ftime)3:1', 'splines::bs(ftime)3:2'
+##
+##
+## Reference group is level 1 of the response
+Again, we see that the results are quite similar for this third +model.
+We now look at the 2-year risk of relapse:
-linearRisk <- absoluteRisk(object = model1, time = 24, newdata = bmtcrr[1:10,])
-logRisk <- absoluteRisk(object = model2, time = 24, newdata = bmtcrr[1:10,])
-splineRisk <- absoluteRisk(object = model3, time = 24, newdata = bmtcrr[1:10,])
linearRisk <- absoluteRisk(object = model1, time = 24, newdata = bmtcrr[1:10,])
+logRisk <- absoluteRisk(object = model2, time = 24, newdata = bmtcrr[1:10,])
+splineRisk <- absoluteRisk(object = model3, time = 24, newdata = bmtcrr[1:10,])
-plot(linearRisk, logRisk,
- xlab = "Linear", ylab = "Log/Spline", pch = 19,
- xlim = c(0,1), ylim = c(0,1), col = 'red')
-points(linearRisk, splineRisk,
- col = 'blue', pch = 19)
-abline(a = 0, b = 1, lty = 2, lwd = 2)
-legend("topleft", legend = c("Log", "Spline"),
- pch = 19, col = c("red", "blue"))
plot(linearRisk, logRisk,
+ xlab = "Linear", ylab = "Log/Spline", pch = 19,
+ xlim = c(0,1), ylim = c(0,1), col = 'red')
+points(linearRisk, splineRisk,
+ col = 'blue', pch = 19)
+abline(a = 0, b = 1, lty = 2, lwd = 2)
+legend("topleft", legend = c("Log", "Spline"),
+ pch = 19, col = c("red", "blue"))
## R version 4.0.2 (2020-06-22)
-## Platform: x86_64-pc-linux-gnu (64-bit)
-## Running under: Ubuntu 16.04.6 LTS
-##
-## Matrix products: default
-## BLAS: /usr/lib/openblas-base/libblas.so.3
-## LAPACK: /usr/lib/libopenblasp-r0.2.18.so
-##
-## attached base packages:
-## [1] stats graphics grDevices utils datasets methods base
-##
-## other attached packages:
-## [1] casebase_0.9.1.9999
-##
-## loaded via a namespace (and not attached):
-## [1] highr_0.8 compiler_4.0.2 pillar_1.4.7 tools_4.0.2
-## [5] digest_0.6.27 lattice_0.20-41 nlme_3.1-148 evaluate_0.14
-## [9] memoise_2.0.0 lifecycle_0.2.0 tibble_3.0.6 gtable_0.3.0
-## [13] mgcv_1.8-31 pkgconfig_2.0.3 rlang_0.4.10 Matrix_1.2-18
-## [17] yaml_2.2.1 pkgdown_1.6.1 xfun_0.20 fastmap_1.1.0
-## [21] stringr_1.4.0 knitr_1.31 desc_1.2.0 fs_1.5.0
-## [25] vctrs_0.3.6 systemfonts_1.0.0 stats4_4.0.2 rprojroot_2.0.2
-## [29] grid_4.0.2 glue_1.4.2 data.table_1.13.6 R6_2.5.0
-## [33] textshaping_0.2.1 survival_3.1-12 VGAM_1.1-5 rmarkdown_2.6
-## [37] ggplot2_3.3.3 magrittr_2.0.1 scales_1.1.1 htmltools_0.5.1.1
-## [41] ellipsis_0.3.1 splines_4.0.2 assertthat_0.2.1 colorspace_2.0-0
-## [45] ragg_0.4.1 stringi_1.5.3 munsell_0.5.0 cachem_1.0.3
-## [49] crayon_1.4.0
+## R version 4.3.1 (2023-06-16)
+## Platform: x86_64-pc-linux-gnu (64-bit)
+## Running under: Ubuntu 22.04.2 LTS
+##
+## Matrix products: default
+## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
+## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
+##
+## attached base packages:
+## [1] stats graphics grDevices utils datasets methods base
+##
+## other attached packages:
+## [1] casebase_0.10.2.9999
+##
+## loaded via a namespace (and not attached):
+## [1] sass_0.4.7 utf8_1.2.3 generics_0.1.3 stringi_1.7.12
+## [5] lattice_0.21-8 digest_0.6.33 magrittr_2.0.3 evaluate_0.21
+## [9] grid_4.3.1 fastmap_1.1.1 rprojroot_2.0.3 jsonlite_1.8.7
+## [13] Matrix_1.5-4.1 survival_3.5-5 mgcv_1.8-42 purrr_1.0.1
+## [17] fansi_1.0.4 scales_1.2.1 textshaping_0.3.6 jquerylib_0.1.4
+## [21] cli_3.6.1 rlang_1.1.1 munsell_0.5.0 splines_4.3.1
+## [25] cachem_1.0.8 yaml_2.3.7 tools_4.3.1 memoise_2.0.1
+## [29] dplyr_1.1.2 colorspace_2.1-0 ggplot2_3.4.2 VGAM_1.1-8
+## [33] vctrs_0.6.3 R6_2.5.1 stats4_4.3.1 lifecycle_1.0.3
+## [37] stringr_1.5.0 fs_1.6.3 ragg_1.2.5 pkgconfig_2.0.3
+## [41] desc_1.4.2 pkgdown_2.0.7 bslib_0.5.0 pillar_1.9.0
+## [45] gtable_0.3.3 data.table_1.14.8 glue_1.6.2 systemfonts_1.0.4
+## [49] xfun_0.39 tibble_3.2.1 tidyselect_1.2.0 highr_0.10
+## [53] knitr_1.43 htmltools_0.5.5 nlme_3.1-162 rmarkdown_2.23
+## [57] compiler_4.3.1
-Efron, Bradley. 1977. “The Efficiency of Cox’s Likelihood Function for Censored Data.” Journal of the American Statistical Association 72 (359). Taylor & Francis Group: 557–65. +Efron, Bradley. 1977. “The Efficiency of Cox’s Likelihood Function for +Censored Data.” Journal of the American Statistical Association +72 (359). Taylor & Francis Group: 557–65.
-Hanley, James A, and Olli S Miettinen. 2009. “Fitting Smooth-in-Time Prognostic Risk Functions via Logistic Regression.” The International Journal of Biostatistics 5 (1). +Hanley, James A, and Olli S Miettinen. 2009. “Fitting Smooth-in-Time +Prognostic Risk Functions via Logistic Regression.” The +International Journal of Biostatistics 5 (1).
-Mantel, Nathan. 1973. “Synthetic Retrospective Studies and Related Topics.” Biometrics. JSTOR, 479–86. +Mantel, Nathan. 1973. “Synthetic Retrospective Studies and Related +Topics.” Biometrics. JSTOR, 479–86.
-Saarela, Olli. 2015. “A Case-Base Sampling Method for Estimating Recurrent Event Intensities.” Lifetime Data Analysis. Springer, 1–17. +Saarela, Olli. 2015. “A Case-Base Sampling Method for Estimating +Recurrent Event Intensities.” Lifetime Data Analysis. Springer, +1–17.
-Saarela, Olli, and Elja Arjas. 2015. “Non-Parametric Bayesian Hazard Regression for Chronic Disease Risk Assessment.” Scandinavian Journal of Statistics 42 (2). Wiley Online Library: 609–26. +Saarela, Olli, and Elja Arjas. 2015. “Non-Parametric Bayesian Hazard +Regression for Chronic Disease Risk Assessment.” Scandinavian +Journal of Statistics 42 (2). Wiley Online Library: 609–26.
-Scrucca, L, A Santucci, and F Aversa. 2010. “Regression Modeling of Competing Risk Using R: An in Depth Guide for Clinicians.” Bone Marrow Transplantation 45 (9). Nature Publishing Group: 1388–95. +Scrucca, L, A Santucci, and F Aversa. 2010. “Regression Modeling of +Competing Risk Using R: An in Depth Guide for Clinicians.” Bone +Marrow Transplantation 45 (9). Nature Publishing Group: 1388–95.
-Kalbfleisch, John D., and Ross L. Prentice. The statistical analysis of failure time data. Vol. 360. John Wiley & Sons, 2011. +Kalbfleisch, John D., and Ross L. Prentice. The statistical analysis of +failure time data. Vol. 360. John Wiley & Sons, 2011.
-Cox, D. R. “Regression models and life tables.” Journal of the Royal Statistical Society 34 (1972): 187-220. +Cox, D. R. “Regression models and life tables.” Journal of the Royal +Statistical Society 34 (1972): 187-220.
Scrucca, L., A. Santucci, and F. Aversa. 2010. “Regression Modeling of Competing Risk Using R: An in Depth Guide for Clinicians.” Bone Marrow Transplantation 45 (9). Nature Publishing Group: 1388–95.
+Turgeon, M., S. Bhatnagar, and O. Saarela. n.d. “A Novel Approach to Competing Risk Analysis Using Case-Base Sampling.”
+Developed by Sahir Bhatnagar, Maxime Turgeon, Jesse Islam, Olli Saarela, James Hanley.
+ +Developed by Sahir Bhatnagar, Maxime Turgeon, Jesse Islam, Olli Saarela, James Hanley.
The default arguments to the facet.params
argument is given by:
The default arguments to the facet.params
argument is
+given by:
-exposure_variable <- attr(x, "exposure")
-default_facet_params <- list(facets = exposure_variable, ncol = 1)
The population time area stratified by treatment arm is then plotted using the following code
+exposure_variable <- attr(x, "exposure")
+default_facet_params <- list(facets = exposure_variable, ncol = 1)
The population time area stratified by treatment arm is then plotted +using the following code
-ggplot() +
- base::do.call("geom_ribbon", new_ribbon_params) +
- base::do.call("facet_wrap", default_facet_params)
ggplot() +
+ base::do.call("geom_ribbon", new_ribbon_params) +
+ base::do.call("facet_wrap", default_facet_params)
-# this is equivalent to
-# plot(x, add.case.series = FALSE)
We can modify the facet labels by either changing the factor labels in the data or specifying the labeller
argument. See this blog post for further details. Here is an example of how we can change the facet labels using the plot
method provided by the casebase package:
# this is equivalent to
+# plot(x, add.case.series = FALSE)
We can modify the facet labels by either changing the factor labels
+in the data or specifying the labeller
argument. See this
+blog post for further details. Here is an example of how we can
+change the facet labels using the plot
method provided by
+the casebase package:
-# Use character vectors as lookup tables:
-group_status <- c(
- `0` = "Control Arm",
- `1` = "Screening Arm"
-)
-
-plot(x,
- add.case.series = FALSE, # do not plot the case serires
- facet.params = list(labeller = labeller(ScrArm = group_status), # change labels
- strip.position = "right") # change facet position
- )
# Use character vectors as lookup tables:
+group_status <- c(
+ `0` = "Control Arm",
+ `1` = "Screening Arm"
+)
+
+plot(x,
+ add.case.series = FALSE, # do not plot the case serires
+ facet.params = list(labeller = labeller(ScrArm = group_status), # change labels
+ strip.position = "right") # change facet position
+ )
Suppose we want to change the color of the points and the legend labels. We use the bmtcrr
dataset as the example in this section.
The reason there are both fill.params
and color.params
arguments, is because by default, we use shape = 21
which is a filled circle (see the pch
argument of the graphics::points
function for details). Shapes from 21 to 25 can be colored and filled with different colors: color.params
gives the border color and fill.params
gives the fill color (sometimes referred to as the background color).
The default fill colors for the case series, base series and competing event are given by the qualitative palette from the colorspace
R package:
Suppose we want to change the color of the points and the legend
+labels. We use the bmtcrr
dataset as the example in this
+section.
The reason there are both fill.params
and
+color.params
arguments, is because by default, we use
+shape = 21
which is a filled circle (see the
+pch
argument of the graphics::points
function
+for details). Shapes from 21 to 25 can be colored and filled with
+different colors: color.params
gives the border color and
+fill.params
gives the fill color (sometimes referred to as
+the background color).
The default fill colors for the case series, base series and
+competing event are given by the qualitative palette from the colorspace
+R package:
-fill_cols <- colorspace::qualitative_hcl(n = 3, palette = "Dark3")
-
-(fill_colors <- c("Case series" = fill_cols[1],
- "Competing event" = fill_cols[3],
- "Base series" = fill_cols[2]))
## Case series Competing event Base series
-## "#E16A86" "#009ADE" "#50A315"
-The corresponding default border colors are given by the colorspace::darken
function applied to the fill colors above:
fill_cols <- colorspace::qualitative_hcl(n = 3, palette = "Dark3")
+
+(fill_colors <- c("Case series" = fill_cols[1],
+ "Competing event" = fill_cols[3],
+ "Base series" = fill_cols[2]))
## Case series Competing event Base series
+## "#E16A86" "#009ADE" "#50A315"
+The corresponding default border colors are given by the
+colorspace::darken
function applied to the fill colors
+above:
-color_cols <- colorspace::darken(col = fill_cols, amount = 0.3)
-
-(color_colors <- c("Case series" = color_cols[1],
- "Competing event" = color_cols[3],
- "Base series" = color_cols[2]))
## Case series Competing event Base series
-## "#AB3A59" "#026A9A" "#347004"
+color_cols <- colorspace::darken(col = fill_cols, amount = 0.3)
+
+(color_colors <- c("Case series" = color_cols[1],
+ "Competing event" = color_cols[3],
+ "Base series" = color_cols[2]))
## Case series Competing event Base series
+## "#AB3A59" "#026A9A" "#347004"
This is what the points look like:
-If you only want to change the color points, you must specify a named vector exactly as specified in the fill_colors
object created above. Note that the names Case series
, Base Series
and Competing event
must remain the same, otherwise the function won’t know how to map the colors to the corresponding points. This is because the colour
and fill
aesthetic mappings in the geom_point
functions have been set to Case series
, Base Series
and Competing event
. For example, the default call to geom_point
for the case series is given by:
If you only want to change the color points, you must specify a named
+vector exactly as specified in the fill_colors
object
+created above. Note that the names Case series
,
+Base Series
and Competing event
must remain
+the same, otherwise the function won’t know how to map the colors to the
+corresponding points. This is because the colour
and
+fill
aesthetic mappings in the geom_point
+functions have been set to Case series
,
+Base Series
and Competing event
. For example,
+the default call to geom_point
for the case series is given
+by:
-ggplot() + do.call("geom_point", list(data = x[event == 1],
- mapping = aes(x = time, y = yc,
- colour = "Case series", fill = "Case series"),
- size = 1.5,
- alpha = 0.5,
- shape = 21))
ggplot() + do.call("geom_point", list(data = x[event == 1],
+ mapping = aes(x = time, y = yc,
+ colour = "Case series", fill = "Case series"),
+ size = 1.5,
+ alpha = 0.5,
+ shape = 21))
We define a new set of colors using a sequential (multi-hue) palette:
+We define a new set of colors using a sequential (multi-hue) +palette:
-fill_cols <- colorspace::sequential_hcl(n = 3, palette = "Viridis")
-
-(fill_colors <- c("Case series" = fill_cols[1],
- "Competing event" = fill_cols[3],
- "Base series" = fill_cols[2]))
## Case series Competing event Base series
-## "#4B0055" "#FDE333" "#009B95"
+fill_cols <- colorspace::sequential_hcl(n = 3, palette = "Viridis")
+
+(fill_colors <- c("Case series" = fill_cols[1],
+ "Competing event" = fill_cols[3],
+ "Base series" = fill_cols[2]))
## Case series Competing event Base series
+## "#4B0055" "#FDE333" "#009B95"
-color_cols <- colorspace::darken(col = fill_cols, amount = 0.3)
-
-(color_colors <- c("Case series" = color_cols[1],
- "Competing event" = color_cols[3],
- "Base series" = color_cols[2]))
## Case series Competing event Base series
-## "#3A0142" "#AC9900" "#0A6B66"
-We then pass fill_cols
and color_cols
to the fill.params
and color.params
arguments, respectively. Internally, this gets passed to the ggplot2::scale_fill_manual
and ggplot2::scale_color_manual
functions, respectively:
color_cols <- colorspace::darken(col = fill_cols, amount = 0.3)
+
+(color_colors <- c("Case series" = color_cols[1],
+ "Competing event" = color_cols[3],
+ "Base series" = color_cols[2]))
## Case series Competing event Base series
+## "#3A0142" "#AC9900" "#0A6B66"
+We then pass fill_cols
and color_cols
to
+the fill.params
and color.params
arguments,
+respectively. Internally, this gets passed to the ggplot2::scale_fill_manual
+and ggplot2::scale_color_manual
+functions, respectively:
-do.call("scale_fill_manual", utils::modifyList(
- list(name = element_blank(),
- breaks = c("Case series", "Competing event", "Base series"),
- values = old_cols), list(values = fill_colors))
-)
-
-do.call("scale_colour_manual", utils::modifyList(
- list(name = element_blank(),
- breaks = c("Case series", "Competing event", "Base series"),
- values = old_cols), list(values = color_colors))
-)
do.call("scale_fill_manual", utils::modifyList(
+ list(name = element_blank(),
+ breaks = c("Case series", "Competing event", "Base series"),
+ values = old_cols), list(values = fill_colors))
+)
+
+do.call("scale_colour_manual", utils::modifyList(
+ list(name = element_blank(),
+ breaks = c("Case series", "Competing event", "Base series"),
+ values = old_cols), list(values = color_colors))
+)
Here is the code to only change the colors:
-# this data ships with the casebase package
-data("bmtcrr")
-
-popTimeData <- popTime(data = bmtcrr, time = "ftime", exposure = "D")
## 'Status' will be used as the event variable
+# this data ships with the casebase package
+data("bmtcrr")
+
+popTimeData <- popTime(data = bmtcrr, time = "ftime", exposure = "D")
+## 'Status' will be used as the event variable
-plot(popTimeData,
- add.case.series = TRUE,
- add.base.series = TRUE,
- add.competing.event = TRUE,
- comprisk = TRUE,
- fill.params = list(values = fill_colors),
- color.params = list(value = color_colors))
plot(popTimeData,
+ add.case.series = TRUE,
+ add.base.series = TRUE,
+ add.competing.event = TRUE,
+ comprisk = TRUE,
+ fill.params = list(values = fill_colors),
+ color.params = list(value = color_colors))
-Note that if you only specify one of the fill.params
or color.params
arguments, the plot method will automatically set one equal to the other and return a warning message:
Note that if you only specify one of the fill.params
or
+color.params
arguments, the plot method will automatically
+set one equal to the other and return a warning message:
-plot(popTimeData,
- add.case.series = TRUE,
- add.base.series = TRUE,
- add.competing.event = TRUE,
- ratio = 1,
- comprisk = TRUE,
- legend = TRUE,
- fill.params = list(values = fill_colors))
## Warning in plot.popTime(popTimeData, add.case.series = TRUE, add.base.series
-## = TRUE, : fill.params has been specified by the user but color.params has not.
-## Setting color.params to be equal to fill.params.
+plot(popTimeData,
+ add.case.series = TRUE,
+ add.base.series = TRUE,
+ add.competing.event = TRUE,
+ ratio = 1,
+ comprisk = TRUE,
+ legend = TRUE,
+ fill.params = list(values = fill_colors))
+## Warning in plot.popTime(popTimeData, add.case.series = TRUE, add.base.series =
+## TRUE, : fill.params has been specified by the user but color.params has not.
+## Setting color.params to be equal to fill.params.
-In order to change both the point colors and legend labels, we must modify the aesthetic mapping of the geom_point
calls as follows:
In order to change both the point colors and legend labels, we must
+modify the aesthetic mapping of the geom_point
calls as
+follows:
-# this data ships with the casebase package
-data("bmtcrr")
-
-popTimeData <- popTime(data = bmtcrr, time = "ftime", exposure = "D")
## 'Status' will be used as the event variable
+# this data ships with the casebase package
+data("bmtcrr")
+
+popTimeData <- popTime(data = bmtcrr, time = "ftime", exposure = "D")
## 'Status' will be used as the event variable
-plot(popTimeData,
- add.case.series = TRUE,
- add.base.series = TRUE,
- add.competing.event = TRUE,
- comprisk = TRUE,
- case.params = list(mapping = aes(x = time, y = yc, fill = "Relapse", colour = "Relapse")),
- base.params = list(mapping = aes(x = time, y = ycoord, fill = "Base series", colour = "Base series")),
- competing.params = list(mapping = aes(x = time, y = yc, fill = "Competing event", colour = "Competing event")),
- fill.params = list(name = "Legend Name",
- breaks = c("Relapse", "Base series", "Competing event"),
- values = c("Relapse" = "blue", "Competing event" = "hotpink", "Base series" = "orange")))
## Warning in plot.popTime(popTimeData, add.case.series = TRUE, add.base.series
-## = TRUE, : fill.params has been specified by the user but color.params has not.
-## Setting color.params to be equal to fill.params.
+plot(popTimeData,
+ add.case.series = TRUE,
+ add.base.series = TRUE,
+ add.competing.event = TRUE,
+ comprisk = TRUE,
+ case.params = list(mapping = aes(x = time, y = yc, fill = "Relapse", colour = "Relapse")),
+ base.params = list(mapping = aes(x = time, y = ycoord, fill = "Base series", colour = "Base series")),
+ competing.params = list(mapping = aes(x = time, y = yc, fill = "Competing event", colour = "Competing event")),
+ fill.params = list(name = "Legend Name",
+ breaks = c("Relapse", "Base series", "Competing event"),
+ values = c("Relapse" = "blue", "Competing event" = "hotpink", "Base series" = "orange")))
## Warning in plot.popTime(popTimeData, add.case.series = TRUE, add.base.series =
+## TRUE, : fill.params has been specified by the user but color.params has not.
+## Setting color.params to be equal to fill.params.
-NOTE: the lists being passed to the .params
arguments must be named arguments, otherwise they will give unexpected behavior. For example
NOTE: the lists being passed to the .params
arguments
+must be named arguments, otherwise they will give unexpected behavior.
+For example
-# this will work because mapping is the name of the
-# argument of the list
-case.params = list(mapping = aes(x = time, y = yc, colour = "Relapse", fill = "Relapse"))
# this will work because mapping is the name of the
+# argument of the list
+case.params = list(mapping = aes(x = time, y = yc, colour = "Relapse", fill = "Relapse"))
-# this will NOT work because the argument of the list has no name
-# and therefore utils::modifyList, will not override the defaults.
-case.params = list(aes(x = time, y = yc, colour = "Relapse", fill = "Relapse"))
# this will NOT work because the argument of the list has no name
+# and therefore utils::modifyList, will not override the defaults.
+case.params = list(aes(x = time, y = yc, colour = "Relapse", fill = "Relapse"))
-## R version 4.0.2 (2020-06-22)
-## Platform: x86_64-pc-linux-gnu (64-bit)
-## Running under: Ubuntu 16.04.6 LTS
-##
-## Matrix products: default
-## BLAS: /usr/lib/openblas-base/libblas.so.3
-## LAPACK: /usr/lib/libopenblasp-r0.2.18.so
-##
-## attached base packages:
-## [1] stats graphics grDevices utils datasets methods base
-##
-## other attached packages:
-## [1] colorspace_2.0-0 data.table_1.13.6 ggplot2_3.3.3
-## [4] casebase_0.9.1.9999 survival_3.1-12
-##
-## loaded via a namespace (and not attached):
-## [1] highr_0.8 pillar_1.4.7 compiler_4.0.2 tools_4.0.2
-## [5] digest_0.6.27 nlme_3.1-148 evaluate_0.14 memoise_2.0.0
-## [9] lifecycle_0.2.0 tibble_3.0.6 gtable_0.3.0 lattice_0.20-41
-## [13] mgcv_1.8-31 pkgconfig_2.0.3 rlang_0.4.10 Matrix_1.2-18
-## [17] yaml_2.2.1 pkgdown_1.6.1 xfun_0.20 fastmap_1.1.0
-## [21] withr_2.4.1 stringr_1.4.0 knitr_1.31 vctrs_0.3.6
-## [25] desc_1.2.0 fs_1.5.0 systemfonts_1.0.0 stats4_4.0.2
-## [29] rprojroot_2.0.2 grid_4.0.2 glue_1.4.2 R6_2.5.0
-## [33] textshaping_0.2.1 VGAM_1.1-5 rmarkdown_2.6 farver_2.0.3
-## [37] magrittr_2.0.1 scales_1.1.1 htmltools_0.5.1.1 ellipsis_0.3.1
-## [41] splines_4.0.2 assertthat_0.2.1 labeling_0.4.2 ragg_0.4.1
-## [45] stringi_1.5.3 munsell_0.5.0 cachem_1.0.3 crayon_1.4.0
+## R version 4.3.1 (2023-06-16)
+## Platform: x86_64-pc-linux-gnu (64-bit)
+## Running under: Ubuntu 22.04.2 LTS
+##
+## Matrix products: default
+## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
+## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
+##
+## attached base packages:
+## [1] stats graphics grDevices utils datasets methods base
+##
+## other attached packages:
+## [1] colorspace_2.1-0 data.table_1.14.8 ggplot2_3.4.2
+## [4] casebase_0.10.2.9999 survival_3.5-5
+##
+## loaded via a namespace (and not attached):
+## [1] sass_0.4.7 utf8_1.2.3 generics_0.1.3 stringi_1.7.12
+## [5] lattice_0.21-8 digest_0.6.33 magrittr_2.0.3 evaluate_0.21
+## [9] grid_4.3.1 fastmap_1.1.1 rprojroot_2.0.3 jsonlite_1.8.7
+## [13] Matrix_1.5-4.1 mgcv_1.8-42 purrr_1.0.1 fansi_1.0.4
+## [17] scales_1.2.1 textshaping_0.3.6 jquerylib_0.1.4 cli_3.6.1
+## [21] rlang_1.1.1 munsell_0.5.0 splines_4.3.1 withr_2.5.0
+## [25] cachem_1.0.8 yaml_2.3.7 tools_4.3.1 memoise_2.0.1
+## [29] dplyr_1.1.2 VGAM_1.1-8 vctrs_0.6.3 R6_2.5.1
+## [33] stats4_4.3.1 lifecycle_1.0.3 stringr_1.5.0 fs_1.6.3
+## [37] ragg_1.2.5 pkgconfig_2.0.3 desc_1.4.2 pkgdown_2.0.7
+## [41] bslib_0.5.0 pillar_1.9.0 gtable_0.3.3 glue_1.6.2
+## [45] systemfonts_1.0.4 highr_0.10 xfun_0.39 tibble_3.2.1
+## [49] tidyselect_1.2.0 knitr_1.43 farver_2.1.1 nlme_3.1-162
+## [53] htmltools_0.5.5 labeling_0.4.2 rmarkdown_2.23 compiler_4.3.1
Developed by Sahir Bhatnagar, Maxime Turgeon, Jesse Islam, Olli Saarela, James Hanley.
+ +Developed by Sahir Bhatnagar, Maxime Turgeon, Jesse Islam, Olli Saarela, James Hanley.