├── .Rbuildignore ├── .gitignore ├── DESCRIPTION ├── MD5 ├── NAMESPACE ├── NEWS.md ├── R ├── ELOS.R ├── LMAJ.R ├── MarkovTest.R ├── create.wData.omega.R ├── crprep.R ├── cuminc.R ├── cutLMms.R ├── datasets.R ├── etm2msdata.R ├── events.R ├── expand.covs.R ├── ggplot.Cuminc.R ├── ggplot.helpers.R ├── ggplot.msfit.R ├── ggplot.probtrans.R ├── imports.R ├── misc.R ├── msboot.R ├── msfit.R ├── msprep.R ├── mssample.R ├── paths.R ├── plot.Cuminc.R ├── plot.MarkovTest.R ├── plot.msfit.R ├── plot.probtrans.R ├── print.Cuminc.R ├── print.MarkovTest.R ├── print.msdata.R ├── probtrans.R ├── redrank.R ├── relsurv.haz_function.R ├── relsurv.match.ratetable.R ├── relsurv.msboot.relsurv.R ├── relsurv.msboot.relsurv.boot.R ├── relsurv.msfit.relsurv.R ├── relsurv.rformulate.R ├── relsurv.transMat.R ├── relsurv.varHaz.fixed.R ├── summary.Cuminc.R ├── summary.msfit.R ├── summary.probtrans.R ├── trans.R ├── transMat.R ├── transhelp.R ├── vis.mirror.pt.R ├── vis.multiple.pt.R └── xsect.R ├── README.md ├── _pkgdown.yml ├── data ├── aidssi.RData ├── aidssi2.RData ├── bmt.RData ├── ebmt1.RData ├── ebmt2.RData ├── ebmt3.RData ├── ebmt4.RData └── prothr.RData ├── docs ├── 404.html ├── articles │ ├── index.html │ ├── visuals_demo.html │ └── visuals_demo_files │ │ ├── accessible-code-block-0.0.1 │ │ └── empty-anchor.js │ │ ├── anchor-sections-1.0 │ │ ├── anchor-sections.css │ │ └── anchor-sections.js │ │ └── figure-html │ │ ├── mirror1-1.png │ │ ├── mirror2-1.png │ │ ├── msfitplot_base_1-1.png │ │ ├── msfitplot_base_2-1.png │ │ ├── msfitplot_confint1-1.png │ │ ├── msfitplot_confint2-1.png │ │ ├── msfitplot_customs-1.png │ │ ├── msfitplot_customs-2.png │ │ ├── msfitplot_ggplot2_1-1.png │ │ ├── msfitplot_ggplot_2-1.png │ │ ├── msfitplot_ggplot_2-2.png │ │ ├── plot.Cuminc1-1.png │ │ ├── plot.cuminc_x-1.png │ │ ├── plot.cuminc_x-2.png │ │ ├── plot_pt_filled1-1.png │ │ ├── plot_pt_filled2-1.png │ │ ├── plot_pt_filled3-1.png │ │ ├── plot_pt_filled4-1.png │ │ ├── plot_pt_separate1-1.png │ │ ├── plot_pt_separate2-1.png │ │ ├── plot_pt_single1-1.png │ │ ├── plot_pt_single2-1.png │ │ ├── plot_pt_single3-1.png │ │ ├── plot_pt_stacked-1.png │ │ ├── vis_multiple_plot-1.png │ │ └── vis_multiple_plot2-1.png ├── authors.html ├── bootstrap-toc.css ├── bootstrap-toc.js ├── deps │ ├── bootstrap-5.3.1 │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ └── bootstrap.min.css │ ├── bootstrap-toc-1.0.1 │ │ └── bootstrap-toc.min.js │ ├── clipboard.js-2.0.11 │ │ └── clipboard.min.js │ ├── data-deps.txt │ ├── font-awesome-6.5.2 │ │ ├── css │ │ │ ├── all.css │ │ │ ├── all.min.css │ │ │ ├── v4-shims.css │ │ │ └── v4-shims.min.css │ │ └── webfonts │ │ │ ├── fa-brands-400.ttf │ │ │ ├── fa-brands-400.woff2 │ │ │ ├── fa-regular-400.ttf │ │ │ ├── fa-regular-400.woff2 │ │ │ ├── fa-solid-900.ttf │ │ │ ├── fa-solid-900.woff2 │ │ │ ├── fa-v4compatibility.ttf │ │ │ └── fa-v4compatibility.woff2 │ ├── headroom-0.11.0 │ │ ├── headroom.min.js │ │ └── jQuery.headroom.min.js │ ├── jquery-3.6.0 │ │ ├── jquery-3.6.0.js │ │ ├── jquery-3.6.0.min.js │ │ └── jquery-3.6.0.min.map │ └── search-1.0.0 │ │ ├── autocomplete.jquery.min.js │ │ ├── fuse.min.js │ │ └── mark.min.js ├── docsearch.css ├── docsearch.js ├── index.html ├── katex-auto.js ├── lightswitch.js ├── link.svg ├── news │ └── index.html ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml ├── reference │ ├── EBMT-cause-of-death-data.html │ ├── EBMT-data.html │ ├── EBMT-platelet-recovery-data.html │ ├── EBMT-year-of-relapse-data.html │ ├── ELOS.html │ ├── LMAJ-1.png │ ├── LMAJ.html │ ├── Liver-cirrhosis-data.html │ ├── MarkovTest-1.png │ ├── MarkovTest-2.png │ ├── MarkovTest.html │ ├── Rplot001.png │ ├── Rplot002.png │ ├── Rplot003.png │ ├── Rplot004.png │ ├── absorbing.html │ ├── aidssi.html │ ├── aidssi2.html │ ├── bmt.html │ ├── crprep.default-1.png │ ├── crprep.default-2.png │ ├── crprep.default.html │ ├── crprep.html │ ├── cuminc.html │ ├── cutLMms.html │ ├── ebmt1.html │ ├── ebmt2.html │ ├── ebmt3.html │ ├── ebmt4.html │ ├── etm2msdata.html │ ├── events.html │ ├── expand.covs.default.html │ ├── expand.covs.html │ ├── expand.covs.msdata.html │ ├── haz_function.html │ ├── index.html │ ├── is.circular.html │ ├── modify_transMat.html │ ├── msboot.html │ ├── msboot.relsurv.boot.html │ ├── msboot.relsurv.html │ ├── msdata2etm.html │ ├── msfit.html │ ├── msfit.relsurv.html │ ├── msprep.html │ ├── mssample.html │ ├── mstate-package.html │ ├── mstate.html │ ├── optimal_weights_matrix.html │ ├── optimal_weights_multiple.html │ ├── paths.html │ ├── plot.Cuminc-1.png │ ├── plot.Cuminc-2.png │ ├── plot.Cuminc.html │ ├── plot.MarkovTest.html │ ├── plot.msfit-1.png │ ├── plot.msfit-2.png │ ├── plot.msfit-3.png │ ├── plot.msfit-4.png │ ├── plot.msfit.html │ ├── plot.probtrans-1.png │ ├── plot.probtrans-2.png │ ├── plot.probtrans-3.png │ ├── plot.probtrans-4.png │ ├── plot.probtrans.html │ ├── print.Cuminc.html │ ├── print.MarkovTest.html │ ├── print.msdata.html │ ├── print.summary.msfit.html │ ├── print.summary.probtrans.html │ ├── probtrans.html │ ├── prothr.html │ ├── redrank.html │ ├── summary.Cuminc.html │ ├── summary.msfit.html │ ├── summary.probtrans.html │ ├── to.trans2.html │ ├── tra2trans.html │ ├── trans.comprisk.html │ ├── trans.illdeath.html │ ├── trans2Q.html │ ├── trans2tra.html │ ├── transMat.html │ ├── transhelp.html │ ├── varHaz.fixed.html │ ├── vis.mirror.pt-1.png │ ├── vis.mirror.pt.html │ ├── vis.multiple.pt-1.png │ ├── vis.multiple.pt.html │ └── xsect.html ├── search.json └── sitemap.xml ├── inst └── CITATION ├── man ├── Cuminc.Rd ├── EBMT-cause-of-death-data.Rd ├── EBMT-data.Rd ├── EBMT-platelet-recovery-data.Rd ├── EBMT-year-of-relapse-data.Rd ├── ELOS.Rd ├── LMAJ.Rd ├── Liver-cirrhosis-data.Rd ├── MarkovTest.Rd ├── aidssi.Rd ├── bmt.Rd ├── crprep.default.Rd ├── cutLMms.Rd ├── etm2msdata.Rd ├── events.Rd ├── expand.covs.Rd ├── expand.covs.msdata.Rd ├── haz_function.Rd ├── modify_transMat.Rd ├── msboot.Rd ├── msboot.relsurv.Rd ├── msboot.relsurv.boot.Rd ├── msdata2etm.Rd ├── msfit.Rd ├── msfit.relsurv.Rd ├── msprep.Rd ├── mssample.Rd ├── mstate-package.Rd ├── paths.Rd ├── plot.Cuminc.Rd ├── plot.MarkovTest.Rd ├── plot.msfit.Rd ├── plot.probtrans.Rd ├── print.MarkovTest.Rd ├── print.msdata.Rd ├── print.summary.msfit.Rd ├── print.summary.probtrans.Rd ├── probtrans.Rd ├── redrank.Rd ├── summary.Cuminc.Rd ├── summary.msfit.Rd ├── summary.probtrans.Rd ├── trans2tra.Rd ├── transMat.Rd ├── transhelp.Rd ├── varHaz.fixed.Rd ├── vis.mirror.pt.Rd ├── vis.multiple.pt.Rd └── xsect.Rd ├── mstate.Rproj ├── src-i386 ├── agmssurv.c ├── agmssurv.o ├── mstate_init.c └── mstate_init.o ├── src ├── agmssurv.c └── mstate_init.c └── vignettes ├── Tutorial.Rnw ├── Tutorial.bib └── visuals_demo.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^_pkgdown\.yml$ 2 | ^docs$ 3 | ^pkgdown$ 4 | ^.*\.Rproj$ 5 | ^\.Rproj\.user$ 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | src/*.o 6 | src/*.so 7 | src/*.dll 8 | old 9 | Meta 10 | inst/doc 11 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: mstate 2 | Version: 0.3.3 3 | Date: 2024-07-03 4 | Title: Data Preparation, Estimation and Prediction in Multi-State 5 | Models 6 | Authors@R: c( 7 | person( 8 | given = "Hein", 9 | family = "Putter", 10 | role = c("aut", "cre"), 11 | email = "H.Putter@lumc.nl"), 12 | person( 13 | given = "Liesbeth C.", 14 | family = "de Wreede", 15 | role = "aut" 16 | ), 17 | person( 18 | given = "Marta", 19 | family = "Fiocco", 20 | role = "aut" 21 | ), 22 | person( 23 | given = "Ronald B.", 24 | family = "Geskus", 25 | role = "ctb" 26 | ), 27 | person( 28 | given = "Edouard F.", 29 | family = "Bonneville", 30 | role = "aut" 31 | ), 32 | person( 33 | given = "Damjan", 34 | family = "Manevski", 35 | role = "ctb" 36 | ) 37 | ) 38 | Depends: 39 | survival (>= 3.1) 40 | Imports: 41 | rlang, 42 | data.table, 43 | lattice, 44 | RColorBrewer, 45 | viridisLite 46 | Suggests: 47 | cmprsk, 48 | ggplot2, 49 | knitr, 50 | rmarkdown, 51 | relsurv (>= 2.2-5) 52 | Description: Contains functions for data preparation, descriptives, hazard estimation and prediction with Aalen-Johansen or simulation in competing risks and multi-state models, see Putter, Fiocco, Geskus (2007) . 53 | License: GPL (>= 2) 54 | Encoding: UTF-8 55 | URL: https://github.com/hputter/mstate 56 | NeedsCompilation: yes 57 | Repository: CRAN 58 | Packaged: 2019-12-11 12:02:31 UTC; hputter 59 | Date/Publication: 2019-12-11 12:30:03 UTC 60 | RoxygenNote: 7.2.3 61 | BugReports: https://github.com/hputter/mstate/issues 62 | VignetteBuilder: knitr 63 | -------------------------------------------------------------------------------- /MD5: -------------------------------------------------------------------------------- 1 | 1ca42212b71f1c7c15acc58fb221f239 *ChangeLog 2 | f25c320ee520a811053bad092885e3bb *DESCRIPTION 3 | da5736866d791a12f3c3c51352e59a68 *NAMESPACE 4 | cf6b68c89448fcaee15cadf449753fb3 *R/ELOS.R 5 | d369e315dc026f7e36d1bdf26f2fb426 *R/LMAJ.R 6 | 22bf5f84cce96947b6df7f102cb82f82 *R/create.wData.omega.R 7 | aaea2b8ab6ddef1828b6421b5d83ebf4 *R/crprep.R 8 | a6a509d0f112350266a9c450caff1432 *R/cuminc.R 9 | ccf54551b5665b7b6ba3d3cce88b0394 *R/cutLMms.R 10 | 4c5e0cef97da9aca8344f906894d2dd7 *R/events.R 11 | 3ec3d77d9138f092122ccd550e9e02ba *R/expand.covs.R 12 | ea5907c94c03e64f598b47490f452365 *R/misc.R 13 | 8cc8b9787d37627ec9d0b481a988baa5 *R/msboot.R 14 | 4cd2927fa5f9726785b3241aa7997d8a *R/msfit.R 15 | 78b63abc8f3bc97b88525409ed1a57f7 *R/msprep.R 16 | 1613b35f36100d20d66bf86616adb824 *R/mssample.R 17 | 6e434ed107d48e4ac353cd4c9c5ee130 *R/paths.R 18 | a6b2b5e3d816f7ef20950694aa57b657 *R/plot.Cuminc.R 19 | a7041706bfe0ec06ce9b32e6fee0a4e9 *R/plot.msfit.R 20 | f1b884b90f08d1fda2852bb4da5f9e5b *R/plot.probtrans.R 21 | 2a6f9f30f15add7c87896b0c6429f947 *R/print.Cuminc.R 22 | 7552ae3128033724fc5845fa33b80133 *R/print.msdata.R 23 | 95cc3c4f631982518b22cf3c69965fc1 *R/probtrans.R 24 | a439a6e4eb77909eff1624611efd015d *R/redrank.R 25 | 111e5134cf75c3891ff0fd43f3177cad *R/summary.Cuminc.R 26 | 89cad9efe2de2f9aaf9a6ad8664ed11c *R/summary.msfit.R 27 | 1f25d58ff130637251ef3f541b46db8a *R/summary.probtrans.R 28 | fa783783890a0bac5f9aeffbe07ca504 *R/trans.R 29 | 5a6cde929eac7888e056fca798dc9bbd *R/transMat.R 30 | 298dc94d5b126e953fe574e2a1313c2c *R/xsect.R 31 | a2304ac3a09a60752455f19f2077cf28 *build/vignette.rds 32 | b3e829108c3ba4c2e9608f6bc162f981 *data/aidssi.RData 33 | 2a9dd89d650c4ddce0a78fabcde20219 *data/aidssi2.RData 34 | b646f096fad989d70c8e95166f9a6a97 *data/bmt.RData 35 | cece4edb8f444d47e21186e77567c269 *data/ebmt1.RData 36 | 4c34d40a850cbefe0f8bc77098c158f0 *data/ebmt2.RData 37 | 3484e0128c2708e64b33e3a436b00d25 *data/ebmt3.RData 38 | 6a0a03f249e8a3a24ba7d5e5149b279a *data/ebmt4.RData 39 | 99614ac11305b572b6bf74ca21127a93 *data/prothr.RData 40 | 4337fe9f24a3a65f9a6685f02a360da3 *inst/CITATION 41 | 842d781148c142c24656bedc8366c45b *inst/doc/Tutorial.R 42 | 29814187a5412ceab2861076392d8e4d *inst/doc/Tutorial.Rnw 43 | daa5421791ce365292b1d47b9feac080 *inst/doc/Tutorial.pdf 44 | 9bc07610479af471584a394cbd8148d0 *man/ELOS.Rd 45 | 425fedc28e7ab4d0b857e014439b64c0 *man/LMAJ.Rd 46 | 5594ed00678dd5082f6948b40fb95f7c *man/aidssi.Rd 47 | 23c585b2724de92079e271012c1b556f *man/bmt.Rd 48 | e5033dacc7e43f003ad585fcf7b9f23b *man/crprep.Rd 49 | e3791b1bf1440e12350f7bd8e7c0f560 *man/cuminc.Rd 50 | 6fc52126006836262875f7f10a99497b *man/cutLMms.Rd 51 | bff297c8c6ab3f81f0783ddeb6a8a1d9 *man/ebmt1.Rd 52 | 34ea3140cfd7c0c90e6272a3b79c01c4 *man/ebmt2.Rd 53 | ea0eaad29bffc69930fe75a16248b133 *man/ebmt3.Rd 54 | c32f4c58f1f90af8b97ae3bdb0880cc6 *man/ebmt4.Rd 55 | b8213a472e68e172c522c3d61d03c554 *man/events.Rd 56 | 222cd5e1dc5d99f2e1f874e563a7f28b *man/expand.covs.Rd 57 | ca70c61942e50ae5546ea088a9e80ec1 *man/expand.covs.msdata.Rd 58 | c4cbee0c74d576e31538b6f0dc042e0f *man/msboot.Rd 59 | 048207a9620cb8f3021147f095b2fef2 *man/msfit.Rd 60 | 987edd5ddf8e17b9f72e8e3327e912e1 *man/msprep.Rd 61 | 14d4ad468d4d63b30357a7f9116ad12f *man/mssample.Rd 62 | 5eaef54f6bb4e834f4f8882942489e91 *man/mstate-package.Rd 63 | 9f00970080ad435ab2e6ab208dca8bc5 *man/paths.Rd 64 | bf10bf50e6e0f7fffc1760bc0c7b1f83 *man/plot.msfit.Rd 65 | b7bca5e8fd1cbeec85f9e0e480a39f87 *man/plot.probtrans.Rd 66 | 78960a918973977301240166b44ca6af *man/print.msdata.Rd 67 | d62f3128ae1157a30a28b5bf9cfe0ca1 *man/probtrans.Rd 68 | e611e1994e980004b0675323e46c6744 *man/prothr.Rd 69 | 354e05991063e3a3be5a0cc3b8e92927 *man/redrank.Rd 70 | 346127457eae3575425cedbfbb09ccbb *man/summary.msfit.Rd 71 | c1530d4ed5f3566d092601ce0358b0c2 *man/summary.probtrans.Rd 72 | a1ed9db3a51251aa4d73f7fcc0a4fb7d *man/trans.Rd 73 | 1ea6e0877a4fc8f7e1b0d8fbc375c387 *man/xsect.Rd 74 | b82b99b4cfce15e8bc284daec18e0fb5 *src/agmssurv.c 75 | 62353ac3eefc346b934822be3d4070a9 *src/mstate_init.c 76 | 29814187a5412ceab2861076392d8e4d *vignettes/Tutorial.Rnw 77 | 97f0b104a37a0cd4c6d74278db2825fb *vignettes/Tutorial.bib 78 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(crprep,default) 4 | S3method(expand.covs,default) 5 | S3method(expand.covs,msdata) 6 | S3method(plot,Cuminc) 7 | S3method(plot,MarkovTest) 8 | S3method(plot,msfit) 9 | S3method(plot,probtrans) 10 | S3method(print,Cuminc) 11 | S3method(print,MarkovTest) 12 | S3method(print,msdata) 13 | S3method(print,summary.msfit) 14 | S3method(print,summary.probtrans) 15 | S3method(summary,Cuminc) 16 | S3method(summary,msfit) 17 | S3method(summary,probtrans) 18 | export(Cuminc) 19 | export(ELOS) 20 | export(LMAJ) 21 | export(MarkovTest) 22 | export(absorbing) 23 | export(crprep) 24 | export(cutLMms) 25 | export(etm2msdata) 26 | export(events) 27 | export(expand.covs) 28 | export(haz_function) 29 | export(is.circular) 30 | export(modify_transMat) 31 | export(msboot) 32 | export(msboot.relsurv) 33 | export(msboot.relsurv.boot) 34 | export(msdata2etm) 35 | export(msfit) 36 | export(msfit.relsurv) 37 | export(msprep) 38 | export(mssample) 39 | export(optimal_weights_matrix) 40 | export(optimal_weights_multiple) 41 | export(paths) 42 | export(probtrans) 43 | export(redrank) 44 | export(to.trans2) 45 | export(tra2trans) 46 | export(trans.comprisk) 47 | export(trans.illdeath) 48 | export(trans2Q) 49 | export(trans2tra) 50 | export(transMat) 51 | export(varHaz.fixed) 52 | export(vis.mirror.pt) 53 | export(vis.multiple.pt) 54 | export(xsect) 55 | import(survival) 56 | importFrom(data.table,.N) 57 | importFrom(data.table,.SD) 58 | importFrom(data.table,`:=`) 59 | importFrom(graphics,box) 60 | importFrom(graphics,lines) 61 | importFrom(graphics,par) 62 | importFrom(graphics,plot) 63 | importFrom(graphics,polygon) 64 | importFrom(graphics,text) 65 | importFrom(graphics,title) 66 | importFrom(lattice,xyplot) 67 | importFrom(rlang,.data) 68 | importFrom(stats,aggregate) 69 | importFrom(stats,approx) 70 | importFrom(stats,approxfun) 71 | importFrom(stats,as.formula) 72 | importFrom(stats,delete.response) 73 | importFrom(stats,model.frame) 74 | importFrom(stats,model.matrix) 75 | importFrom(stats,model.offset) 76 | importFrom(stats,model.response) 77 | importFrom(stats,qnorm) 78 | importFrom(stats,quantile) 79 | importFrom(stats,rnorm) 80 | importFrom(stats,rpois) 81 | importFrom(stats,terms) 82 | importFrom(stats,time) 83 | importFrom(stats,weighted.mean) 84 | importFrom(utils,flush.console) 85 | importFrom(utils,head) 86 | importFrom(utils,tail) 87 | useDynLib(mstate, .registration=TRUE) 88 | -------------------------------------------------------------------------------- /R/ELOS.R: -------------------------------------------------------------------------------- 1 | #' Expected length of stay 2 | #' 3 | #' Given a \code{"probtrans"} object, ELOS calculates the (restricted) expected 4 | #' length of stay in each of the states of the multi-state model. 5 | #' 6 | #' The object \code{pt} needs to be a \code{"probtrans"} object, obtained with 7 | #' forward prediction (the default, \code{direction}=\code{"forward"}, in the 8 | #' call to \code{\link{probtrans}}). The restriction to \code{tau} is there 9 | #' because, as in ordinary survival analysis, the probability of being in a 10 | #' state can be positive until infinity, resulting in infinite values. The 11 | #' (restricted, until tau) expected length of stay in state h, given in state g 12 | #' at time s, is given by the integral from s to tau of P_gh(s,t), see for 13 | #' instance Beyersmann and Putter (2014). 14 | #' 15 | #' @param pt An object of class \code{"probtrans"} 16 | #' @param tau The horizon until which ELOS is calculated; if missing, the 17 | #' maximum of the observed transition times is taken 18 | #' @return A K x K matrix (with K number of states), with the (g,h)'th element 19 | #' containing E_gh(s,tau). The starting time point s is inferred from \code{pt} 20 | #' (the smallest time point, should be equal to the \code{predt} value in the 21 | #' call to \code{\link{probtrans}}. The row- and column names of the matrix 22 | #' have been named "from1" until "fromK" and "in1" until "inK", respectively. 23 | #' @author Hein Putter \email{H.Putter@@lumc.nl} 24 | #' @keywords univar 25 | #' @examples 26 | #' 27 | #' # transition matrix for illness-death model 28 | #' tmat <- trans.illdeath() 29 | #' # data in wide format, for transition 1 this is dataset E1 of 30 | #' # Therneau & Grambsch (2000) 31 | #' tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), 32 | #' dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), 33 | #' x1=c(1,1,1,0,0,0),x2=c(6:1)) 34 | #' # data in long format using msprep 35 | #' tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"), 36 | #' data=tg,keep=c("x1","x2"),trans=tmat) 37 | #' # events 38 | #' events(tglong) 39 | #' table(tglong$status,tglong$to,tglong$from) 40 | #' # expanded covariates 41 | #' tglong <- expand.covs(tglong,c("x1","x2")) 42 | #' # Cox model with different covariate 43 | #' cx <- coxph(Surv(Tstart,Tstop,status)~x1.1+x2.2+strata(trans), 44 | #' data=tglong,method="breslow") 45 | #' summary(cx) 46 | #' # new data, to check whether results are the same for transition 1 as 47 | #' # those in appendix E.1 of Therneau & Grambsch (2000) 48 | #' newdata <- data.frame(trans=1:3,x1.1=c(0,0,0),x2.2=c(0,1,0),strata=1:3) 49 | #' HvH <- msfit(cx,newdata,trans=tmat) 50 | #' # probtrans 51 | #' pt <- probtrans(HvH,predt=0) 52 | #' # ELOS until last observed time point 53 | #' ELOS(pt) 54 | #' # Restricted ELOS until tau=10 55 | #' ELOS(pt, tau=10) 56 | #' 57 | #' @export ELOS 58 | ELOS <- function(pt, tau) { 59 | if (!inherits(pt, "probtrans")) 60 | stop("'pt' must be a 'probtrans' object") 61 | if (pt$direction != "forward") 62 | stop("ELOS only works if direction==\"forward\" ") 63 | tt <- pt[[1]]$time 64 | if (missing(tau)) tau <- max(tt) 65 | if (tauLM,] 42 | msdata$Tstart[msdata$Tstartcens] <- 0 45 | msdata$Tstop[msdata$Tstop>cens] <- cens 46 | msdata <- msdata[msdata$Tstop>=msdata$Tstart,] 47 | } 48 | msdata$time <- msdata$Tstop - msdata$Tstart 49 | attr(msdata, "trans") <- tmat 50 | return(msdata) 51 | } 52 | -------------------------------------------------------------------------------- /R/events.R: -------------------------------------------------------------------------------- 1 | #' Count number of observed transitions 2 | #' 3 | #' Given a dataset in long format, for instance generated by 4 | #' \code{\link{msprep}}, and a transition matrix for the multi-state model, 5 | #' this function counts the number of observed transitions in the multi-state 6 | #' model and gives their percentages. 7 | #' 8 | #' Although \code{msdata} does not need to be the result of a call to 9 | #' \code{\link{msprep}}, it does need to be an object of class \code{"msdata"}, 10 | #' which is essentially a data frame in long format, with one row for each 11 | #' transition for which the subject is at risk. The columns \code{from}, 12 | #' \code{to}, and \code{status} need to be present, with appropriate meaning, 13 | #' see \code{\link{msprep}}. The \code{msdata} argument needs to have a 14 | #' \code{"trans"} attributes, which holds the transition matrix of the 15 | #' multi-state model. 16 | #' 17 | #' @param msdata An object of class \code{"msdata"}, such as output by 18 | #' \code{\link{msprep}} 19 | #' @return A list containing two tables, the first, called \code{Frequencies}, 20 | #' with the number of observed transitions in the multi-state model occurring 21 | #' in \code{msdata}, the second, called \code{Proportions}, with the 22 | #' corresponding proportions. 23 | #' @author Hein Putter \email{H.Putter@@lumc.nl} 24 | #' @keywords univar 25 | #' @examples 26 | #' 27 | #' tmat <- trans.illdeath(names=c("Tx","PR","RelDeath")) 28 | #' data(ebmt3) # data from Section 4 of Putter, Fiocco & Geskus (2007) 29 | #' msebmt <- msprep(time=c(NA,"prtime","rfstime"),status=c(NA,"prstat","rfsstat"), 30 | #' data=ebmt3,trans=tmat) 31 | #' events(msebmt) # see Fig 13 of Putter, Fiocco & Geskus (2007) 32 | #' 33 | #' @export events 34 | `events` <- function(msdata) 35 | { 36 | trans <- attr(msdata, "trans") 37 | K <- nrow(trans) 38 | absorbing <- which(apply(is.na(trans), 1, all)) 39 | if (!is.null(dimnames(trans))) states <- dimnames(trans)[[1]] 40 | else states <- as.character(1:K) 41 | from <- factor(msdata$from,levels=1:K,labels=states) 42 | to <- factor(msdata$to,levels=1:K,labels=states) 43 | tbl <- table(from[msdata$status==1],to[msdata$status==1],dnn=c("from","to")) 44 | counts <- tbl 45 | tbl <- table(from,to,dnn=c("from","to")) 46 | total <- apply(tbl,1,max) 47 | total[absorbing] <- apply(counts[,absorbing,drop=FALSE], 2, sum) 48 | noevent <- total - apply(counts,1,sum) 49 | counts <- cbind(counts,noevent,total) 50 | dn <- dimnames(counts) 51 | dn[[2]][(K+1):(K+2)] <- c("no event","total entering") 52 | names(dn) <- c("from","to") 53 | dimnames(counts) <- dn 54 | class(counts) <- "table" 55 | freqs <- (counts/total)[,-(K+2)] 56 | class(freqs) <- "table" 57 | return(list(Frequencies=counts,Proportions=freqs)) 58 | } 59 | -------------------------------------------------------------------------------- /R/ggplot.Cuminc.R: -------------------------------------------------------------------------------- 1 | ##***********************************## 2 | ## ggplot2 version of plot.Cuminc ## 3 | ## using geom_ribbons ## 4 | ##***********************************## 5 | 6 | 7 | prep_Cuminc_df <- function(x, 8 | shift_vars, 9 | conf.type, 10 | conf.int) { 11 | 12 | # For data.table warnings 13 | . <- prob <- se <- NULL 14 | 15 | # Get list of se cols and prob cols (Cumin will always return SEs) 16 | prob_cols <- grep(x = names(x), pattern = "^CI", value = TRUE) 17 | se_cols <- grep(x = names(x), pattern = "^seCI", value = TRUE) 18 | 19 | # Prepare long df 20 | df_long <- data.table::melt.data.table( 21 | data = data.table::data.table(x), 22 | measure.vars = list(prob_cols, se_cols), 23 | value.name = c("prob", "se"), 24 | variable.name = "state" 25 | ) 26 | 27 | df_long[, ':=' ( 28 | CI_low = make_prob_confint(prob, se, conf.type, conf.int, bound = "low"), 29 | CI_upp = make_prob_confint(prob, se, conf.type, conf.int, bound = "upp") 30 | ), by = shift_vars] 31 | 32 | # Shift for the ribbons 33 | df_steps <- rbind(df_long, df_long) 34 | data.table::setorder(x = df_steps, time) 35 | 36 | # Shift time by 1, creating steps, equi to dplyr::lead(time, n = 1) 37 | df_steps[, time := data.table::shift( 38 | x = time, 39 | fill = NA, 40 | n = 1, 41 | type = "lead" 42 | ), by = shift_vars] 43 | 44 | return(df_steps[!is.na(time)]) 45 | } 46 | 47 | 48 | ggplot.Cuminc <- function(x, 49 | xlab = "Time", 50 | ylab = "Probability", 51 | xlim, 52 | ylim, 53 | lty, 54 | legend, 55 | cols, 56 | conf.type = "log", 57 | conf.int = 0.95, 58 | legend.pos = "right", 59 | facet = FALSE) { 60 | 61 | # Check for ggplot2 62 | if (!requireNamespace("ggplot2", quietly = TRUE)) { 63 | stop("Package ggplot2 needed for this function to work. Please install it.", call. = FALSE) 64 | } 65 | 66 | # For data.table warnings 67 | state.grp <- state <- group <- NULL 68 | 69 | # Check whether group was specified and facets 70 | shift_vars <- if ("group" %in% names(x)) c("state", "group") else "state" 71 | if (facet & length(shift_vars) == 1) stop("Cannot facet for Cuminc object without group specified") 72 | 73 | # Format data 74 | df_steps <- prep_Cuminc_df( 75 | x = x, 76 | shift_vars = shift_vars, 77 | conf.type = conf.type, 78 | conf.int = conf.int 79 | ) 80 | 81 | # If group, add interaction variable for plotting 82 | if (!facet & length(shift_vars) > 1) { 83 | df_steps[, state.grp := interaction(state, group)] 84 | grp <- rlang::sym("state.grp") 85 | } else grp <- rlang::sym("state") 86 | 87 | # Grps 88 | n_grps_plotted <- length(unique(df_steps[[grp]])) 89 | 90 | # Set up graphical parameters of plot 91 | if (missing(xlim)) xlim <- c(0, max(df_steps$time)) 92 | if (missing(ylim)) ylim <- c(0, 1) 93 | if (missing(lty)) lty <- rep(1, n_grps_plotted) 94 | if (missing(legend)) legend <- levels(factor(df_steps[[grp]])) 95 | if (missing(cols)) cols <- set_colours(n_grps_plotted, type = "lines") 96 | col_ribb <- ifelse(conf.type == "none", NA, "grey70") 97 | 98 | # Start plot 99 | p <- ggplot2::ggplot( 100 | data = df_steps, 101 | ggplot2::aes( 102 | x = .data$time, 103 | y = .data$prob, 104 | col = !!grp, 105 | group = !!grp, 106 | linetype = !!grp 107 | ) 108 | ) + 109 | ggplot2::geom_ribbon( 110 | ggplot2::aes(ymin = .data$CI_low, ymax = .data$CI_upp), 111 | fill = col_ribb, 112 | col = NA, 113 | alpha = 0.5 114 | ) + 115 | ggplot2::geom_line(size = 1) + 116 | ggplot2::coord_cartesian(xlim = xlim, ylim = ylim, expand = 0) + 117 | ggplot2::scale_linetype_manual(values = lty, labels = legend) + 118 | ggplot2::scale_color_manual(values = cols, labels = legend) + 119 | ggplot2::theme(legend.position = legend.pos) + 120 | ggplot2::labs(x = xlab, y = ylab) 121 | 122 | if (facet) { 123 | p <- p + ggplot2::facet_wrap(. ~ group) 124 | } 125 | 126 | return(p) 127 | } 128 | 129 | -------------------------------------------------------------------------------- /R/ggplot.helpers.R: -------------------------------------------------------------------------------- 1 | # Helper function to set default plot colours 2 | set_colours <- function(n, type) { 3 | 4 | if (type == "lines") { 5 | 6 | # Rcolorbrewer Dark2 - max 8 colours 7 | full_pal <- RColorBrewer::brewer.pal(n = 8, name = "Dark2") 8 | 9 | if (n <= 8) { 10 | cols <- full_pal[seq_len(n)] 11 | } else { 12 | dark2_extended <- grDevices::colorRampPalette(colors = full_pal) 13 | cols <- dark2_extended(n) 14 | } 15 | 16 | } else if(type == "areas") { 17 | cols <- viridisLite::viridis(n = n) 18 | } else stop("Type should be either 'lines' or 'areas'!") 19 | 20 | return(cols) 21 | } -------------------------------------------------------------------------------- /R/imports.R: -------------------------------------------------------------------------------- 1 | #' @import survival 2 | #' @importFrom data.table .N `:=` .SD 3 | #' @importFrom rlang .data 4 | #' @importFrom graphics box lines par plot polygon text title 5 | #' @importFrom stats as.formula delete.response model.frame model.matrix 6 | #' model.offset model.response rnorm terms time aggregate approxfun 7 | #' quantile rpois weighted.mean approx qnorm 8 | #' @importFrom utils flush.console head tail 9 | #' @importFrom lattice xyplot 10 | #' 11 | #' @useDynLib mstate, .registration=TRUE 12 | NULL -------------------------------------------------------------------------------- /R/misc.R: -------------------------------------------------------------------------------- 1 | `NAfix` <- function(x, subst=-Inf) { 2 | ### Written by Christian Hoffmann; propagate last known non-NA value 3 | ### Input: 4 | ### x: numeric vector 5 | ### subst: scalar inidicating which value should replace NA 6 | ### if x starts with a series of NA's 7 | ### Output: 8 | ### (numeric) vector, with NA's replaced by last known non-NA value, 9 | ### or 'subst' 10 | spec <- max(x[!is.na(x)])+1 11 | x <- c(spec,x) 12 | while (any(is.na(x))) x[is.na(x)] <- x[(1:length(x))[is.na(x)]-1] 13 | x[x==spec] <- subst 14 | x <- x[-1] 15 | x 16 | } 17 | 18 | `my.rbind` <- function(mat1, mat2) 19 | { 20 | ### rbind "extended" to bind matrices with differing number of columns 21 | m <- max(ncol(mat1), ncol(mat2)) 22 | if (ncol(mat1) 25 | #' @references Fiocco M, Putter H, van Houwelingen HC (2008). Reduced-rank 26 | #' proportional hazards regression and simulation-based prediction for 27 | #' multi-state models. \emph{Statistics in Medicine} \bold{27}, 4340--4358. 28 | #' @keywords datagen 29 | #' @examples 30 | #' 31 | #' tmat <- trans.illdeath() 32 | #' data(ebmt1) 33 | #' covs <- c("score","yrel") 34 | #' msebmt <- msprep(time=c(NA,"rel","srv"),status=c(NA,"relstat","srvstat"), 35 | #' data=ebmt1,id="patid",keep=covs,trans=tmat) 36 | #' # define a function (this one returns vector of regression coef's) 37 | #' regcoefvec <- function(data) { 38 | #' cx <- coxph(Surv(Tstart,Tstop,status)~score+strata(trans), 39 | #' data=data,method="breslow") 40 | #' return(coef(cx)) 41 | #' } 42 | #' regcoefvec(msebmt) 43 | #' set.seed(1234) 44 | #' msboot(theta=regcoefvec,data=msebmt,id="patid") 45 | #' 46 | #' @export msboot 47 | `msboot` <- function(theta,data,B=5,id="id",verbose=0,...) 48 | { 49 | if (!inherits(data, "msdata")) 50 | stop("'data' must be a 'msdata' object") 51 | trans <- attr(data, "trans") 52 | ids <- unique(data[[id]]) 53 | n <- length(ids) 54 | th <- theta(data,...) # actually only used to get the length 55 | res <- matrix(NA,length(th),B) 56 | for (b in 1:B) { 57 | if (verbose>0) { 58 | cat("\nBootstrap replication",b,"\n") 59 | flush.console() 60 | } 61 | bootdata <- NULL 62 | bids <- sample(ids,replace=TRUE) 63 | bidxs <- unlist(sapply(bids, function(x) which(x==data[[id]]))) 64 | bootdata <- data[bidxs,] 65 | if (verbose>0) { 66 | print(date()) 67 | print(events(bootdata)) 68 | cat("applying theta ...") 69 | } 70 | thstar <- theta(bootdata,...) 71 | res[,b] <- thstar 72 | } 73 | if (verbose) cat("\n") 74 | return(res) 75 | } 76 | -------------------------------------------------------------------------------- /R/paths.R: -------------------------------------------------------------------------------- 1 | #' Find all possible trajectories through a given multi-state model 2 | #' 3 | #' For a given multi-state model, specified through a transition matrix, 4 | #' \code{paths} recursively finds all the possible trajectories or paths 5 | #' through that multi-state starting from a specified state. DO NOT USE for 6 | #' reversible or cyclic multi-state models. 7 | #' 8 | #' The function is recursive. It starts in \code{start}, looks at what states 9 | #' can be visited from \code{start}, and appends the results of the next call 10 | #' to the current value (matrix). If the transition matrix contains loops, the 11 | #' function will find infinitely many paths, so do not use \code{paths} for 12 | #' reversible or cyclic multi-state models. A warning is not yet incorporated! 13 | #' 14 | #' @param trans The transition matrix describing the multi-state model, see 15 | #' \code{\link{msprep}} 16 | #' @param start The starting state for the trajectories 17 | #' @return A matrix, each row of which specifies a possible path through the 18 | #' multi-state model. 19 | #' @author Hein Putter 20 | #' @keywords array 21 | #' @examples 22 | #' 23 | #' tmat <- matrix(NA,5,5) 24 | #' tmat[1,2:3] <- 1:2 25 | #' tmat[1,5] <- 3 26 | #' tmat[2,4:5] <- 4:5 27 | #' tmat[3,4:5] <- 6:7 28 | #' tmat[4,5] <- 8 29 | #' paths(tmat) 30 | #' paths(tmat, start=3) 31 | #' 32 | #' @export paths 33 | `paths` <- function(trans,start=1) 34 | { 35 | ### Find all paths through a multi-state model from a starting state 36 | ### All direct transitions are specified through transition matrix 37 | ### trans 38 | ### Input: 39 | ### start: numeric, specifying the starting state 40 | ### trans: transition matrix 41 | ### Output: 42 | ### matrix specifying all possible paths 43 | ### Details: recursive 44 | if (is.circular(trans)) stop("transition matrix is circular, so there will be infinitely many paths") 45 | nstates <- trans[start,] 46 | nstates <- which(!is.na(nstates)) 47 | if (length(nstates)==0) ## i.e. in absorbing state 48 | return(matrix(start,1,1)) 49 | else { 50 | fpmat <- startmat <- matrix(start,1,1) 51 | for (nstate in nstates) { 52 | fpmat <- my.rbind(fpmat, my.cbind2(start,Recall(trans,start=nstate))) 53 | } 54 | } 55 | return(fpmat) 56 | } 57 | -------------------------------------------------------------------------------- /R/plot.Cuminc.R: -------------------------------------------------------------------------------- 1 | #' Plot method for Cuminc objects 2 | #' 3 | #' Plot the estimates of the non-parametric Aalen-Johansen estimate of the 4 | #' cumulative incidence functions (competing risks data). Note this is a method 5 | #' for \code{mstate::Cuminc} and not \code{cmprsk::cuminc}. Both return the same 6 | #' estimates, though the former does so in a dataframe, and the latter in the list. 7 | #' 8 | #' Grouped cumulative incidences can be plotted either in the same plot or in facets, 9 | #' see the \code{facet} argument. 10 | #' 11 | #' @param x Object of class \code{"Cuminc"} to be printed or plotted 12 | #' @inheritParams plot.probtrans 13 | #' @param legend Character vector corresponding to number of absorbing states. 14 | #' In case of a grouped \code{"Cuminc"} object, with facet = FALSE the 15 | #' length of the vector is number absorbing states * group levels. 16 | #' Only relevant when use.ggplot = TRUE 17 | #' @param facet Logical, in case of group used for \code{"Cuminc"}, facet by it - 18 | #' only relevant when use.ggplot = TRUE 19 | #' @param cols Vector (numeric or character) specifying colours of the lines 20 | #' @param \dots Further arguments to plot or print method 21 | #' 22 | #' @return A ggplot object if use.ggplot = T used, otherwise NULL. 23 | #' 24 | #' @author Edouard F. Bonneville \email{e.f.bonneville@@lumc.nl} 25 | #' 26 | #' @examples 27 | #' library(ggplot2) 28 | #' 29 | #' data("aidssi") 30 | #' head(aidssi) 31 | #' si <- aidssi 32 | #' 33 | #' # No grouping 34 | #' cum_incid <- Cuminc( 35 | #' time = "time", 36 | #' status = "status", 37 | #' data = si 38 | #' ) 39 | #' 40 | #' plot( 41 | #' x = cum_incid, 42 | #' use.ggplot = TRUE, 43 | #' conf.type = "none", 44 | #' lty = 1:2, 45 | #' conf.int = 0.95 46 | #' ) 47 | #' 48 | #' # With grouping 49 | #' cum_incid_grp <- Cuminc( 50 | #' time = "time", 51 | #' status = "status", 52 | #' group = "ccr5", 53 | #' data = si 54 | #' ) 55 | #' 56 | #' plot( 57 | #' x = cum_incid_grp, 58 | #' use.ggplot = TRUE, 59 | #' conf.type = "none", 60 | #' lty = 1:4, 61 | #' facet = TRUE 62 | #' ) 63 | #' 64 | #' @export 65 | plot.Cuminc <- function(x, 66 | use.ggplot = FALSE, 67 | xlab = "Time", 68 | ylab = "Probability", 69 | xlim, 70 | ylim, 71 | lty, 72 | legend, 73 | cols, 74 | conf.type = c("log", "plain", "none"), 75 | conf.int = 0.95, 76 | legend.pos = "right", 77 | facet = FALSE, 78 | ...) { 79 | 80 | if (!inherits(x, "Cuminc")) stop("'x' must be a 'Cuminc' object") 81 | 82 | # Ggplot version 83 | if (use.ggplot) { 84 | 85 | # Check for ggplot2 86 | if (!requireNamespace("ggplot2", quietly = TRUE)) { 87 | stop("Package ggplot2 needed for this function to work. Please install it.", call. = FALSE) 88 | } 89 | 90 | conf.type <- match.arg(conf.type) 91 | 92 | p <- ggplot.Cuminc( 93 | x = x, 94 | xlab = xlab, 95 | ylab = ylab, 96 | xlim = xlim, 97 | ylim = ylim, 98 | lty = lty, 99 | legend = legend, 100 | cols = cols, 101 | conf.type = conf.type, 102 | conf.int = conf.int, 103 | legend.pos = legend.pos, 104 | facet = facet 105 | ) 106 | 107 | return(p) 108 | } else { 109 | 110 | # Set up base R arguments 111 | base_args <- list(..., "conf.int" = conf.int, "xlab" = xlab, "ylab" = ylab) 112 | survfit_obj <- attr(x, "survfit") 113 | base_args$x <- survfit_obj 114 | if (!missing(cols)) base_args$col <- cols 115 | if (!missing(lty)) base_args$lty <- lty 116 | if (!missing(xlim)) base_args$xlim <- xlim 117 | if (!missing(ylim)) base_args$ylim <- ylim 118 | 119 | # Call plot.survfit 120 | do.call("plot", args = base_args) 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /R/print.Cuminc.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | print.Cuminc <- function(x, ...) 3 | { 4 | if (!inherits(x, "Cuminc")) 5 | stop("'x' must be a 'Cuminc' object") 6 | 7 | print(as.data.frame(x)) 8 | } 9 | -------------------------------------------------------------------------------- /R/print.MarkovTest.R: -------------------------------------------------------------------------------- 1 | #' Print method for a MarkovTest object 2 | #' 3 | #' Print method for an object of class 'MarkovTest' 4 | #' 5 | #' 6 | #' @param x Object of class 'markovTest', as obtained by call to 7 | #' \code{\link{MarkovTest}} 8 | #' @param \dots Further arguments to print 9 | #' @return No return value 10 | #' @author Hein Putter \email{H.Putter@@lumc.nl} 11 | #' @seealso \code{\link{MarkovTest}} 12 | #' @keywords hplot 13 | #' @examples 14 | #' 15 | #' \dontrun{ 16 | #' # Example provided by the prothrombin data 17 | #' data("prothr") 18 | #' # Apply Markov test to grid of monthly time points over the first 7.5 years 19 | #' year <- 365.25 20 | #' month <- year / 12 21 | #' grid <- month * (1:90) 22 | #' # Markov test for transition 1 (wild bootstrap based on 25 replications for brevity) 23 | #' MT <- MarkovTest(prothr, id = "id", transition = 1, 24 | #' grid = grid, B = 25) 25 | #' MT 26 | #' } 27 | #' 28 | #' @export 29 | print.MarkovTest <- function(x, ...) 30 | { 31 | cat("Log-rank based Markov test for transition ", x$trans, " (", x$from, " -> ", x$to, ")\n", sep="") 32 | cat("Qualifying states: ", x$qualset, "\n") 33 | cat("\nP-values based on ", x$B, " wild bootstrap replications with ") 34 | if (x$dist == "poisson") cat("centred Poisson") 35 | if (x$dist == "normal") cat("standard normal") 36 | cat(" distributed random weights\n") 37 | 38 | cat("\nQualifying state specific tests:\n") 39 | nfuns <- nrow(x$orig_stat) 40 | for (j in 1:nfuns) { 41 | cat("\n") 42 | print(x$fn[[1]][[j]]) 43 | cat("\n") 44 | tmp <- t(rbind(x$qualset, x$orig_stat[j, ], x$p_stat_wb[j, ])) 45 | tmp <- as.data.frame(tmp) 46 | names(tmp) <- c("Qualstate", "u", "P(|U| > u)") 47 | print(tmp, row.names = FALSE) 48 | } 49 | 50 | cat("\nOverall test:\n") 51 | nfuns <- length(x$orig_ch_stat) 52 | for (j in 1:nfuns) { 53 | cat("\n") 54 | print(x$fn2[[j]]) 55 | cat("\n") 56 | tmp <- matrix(c(x$orig_ch_stat[j], x$p_ch_stat_wb), 1, 2) 57 | tmp <- as.data.frame(tmp) 58 | names(tmp) <- c("chisq", "P(|U| > u)") 59 | print(tmp, row.names = FALSE) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /R/print.msdata.R: -------------------------------------------------------------------------------- 1 | #' Print method for a msdata object 2 | #' 3 | #' Print method for an object of class 'msdata' 4 | #' 5 | #' 6 | #' @param x Object of class 'msdata', as prepared for instance by 7 | #' \code{\link{msprep}} 8 | #' @param trans Boolean specifying whether or not the transition matrix should 9 | #' be printed as well; default is \code{FALSE} 10 | #' @param \dots Further arguments to print 11 | #' @return No return value 12 | #' @author Hein Putter \email{H.Putter@@lumc.nl} 13 | #' @seealso \code{\link{probtrans}} 14 | #' @keywords hplot 15 | #' @examples 16 | #' 17 | #' # transition matrix for illness-death model 18 | #' tmat <- trans.illdeath() 19 | #' # some data in wide format 20 | #' tg <- data.frame(stt=rep(0,6),sts=rep(0,6), 21 | #' illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), 22 | #' dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), 23 | #' x1=c(1,1,1,2,2,2),x2=c(6:1)) 24 | #' tg$x1 <- factor(tg$x1,labels=c("male","female")) 25 | #' tg$patid <- factor(2:7,levels=1:8,labels=as.character(1:8)) 26 | #' # define time, status and covariates also as matrices 27 | #' tt <- matrix(c(rep(NA,6),tg$illt,tg$dt),6,3) 28 | #' st <- matrix(c(rep(NA,6),tg$ills,tg$ds),6,3) 29 | #' keepmat <- data.frame(gender=tg$x1,age=tg$x2) 30 | #' # data in long format using msprep 31 | #' msp <- msprep(time=tt,status=st,trans=tmat,keep=as.matrix(keepmat)) 32 | #' print(msp) 33 | #' print(msp, trans=TRUE) 34 | #' 35 | #' @export 36 | print.msdata <- function(x,trans=FALSE,...) 37 | { 38 | if (!inherits(x, "msdata")) 39 | stop("'x' must be an 'msdata' object") 40 | cat("An object of class 'msdata'\n\nData:\n") 41 | print.data.frame(x) 42 | if (trans) { 43 | trans <- attr(x, "trans") 44 | cat("\nTransition matrix:\n") 45 | print(trans) 46 | } 47 | return(invisible()) 48 | } 49 | -------------------------------------------------------------------------------- /R/relsurv.match.ratetable.R: -------------------------------------------------------------------------------- 1 | `match.ratetable.mstate` <- function (R, ratetable) 2 | { 3 | # Function match.ratetable taken from survival and adapted for use in mstate. 4 | 5 | datecheck <- function(x) inherits(x, c("Date", "POSIXt", 6 | "date", "chron", "rtabledate")) 7 | if (!is.ratetable(ratetable)) 8 | stop("Invalid rate table") 9 | dimid <- names(dimnames(ratetable)) 10 | if (is.null(dimid)) 11 | dimid <- attr(ratetable, "dimid") 12 | datecut <- sapply(attr(ratetable, "cutpoints"), datecheck) 13 | rtype <- attr(ratetable, "type") 14 | if (is.null(rtype)) { 15 | temp <- attr(ratetable, "factor") 16 | rtype <- 1 * (temp == 1) + ifelse(datecut, 3, 2) * (temp == 17 | 0) + 4 * (temp > 1) 18 | } 19 | if (is.matrix(R)) { 20 | attR <- attributes(R) 21 | attributes(R) <- attR["dim"] 22 | Rnames <- attR$dimnames[[2]] 23 | isDate <- attR[["isDate"]] 24 | levlist <- attR[["levlist"]] 25 | } 26 | else { 27 | Rnames <- names(R) 28 | levlist <- lapply(R, levels) 29 | isDate <- sapply(R, datecheck) 30 | } 31 | ord <- match(dimid, Rnames) 32 | if (any(is.na(ord))) 33 | stop(paste("Argument '", dimid[is.na(ord)], "' needed by the ratetable was not found in the data", 34 | sep = "")) 35 | if (any(duplicated(ord))) 36 | stop("A ratetable argument appears twice in the data") 37 | R <- R[, ord, drop = FALSE] 38 | levlist <- levlist[ord] 39 | isDate <- isDate[ord] 40 | dtemp <- dimnames(ratetable) 41 | if (any((rtype < 3) & isDate)) { 42 | indx <- which(rtype < 3 & isDate) 43 | stop(paste("Data has a date type variable, but the reference", 44 | "ratetable is not a date variable:", paste(dimid[indx], 45 | collapse = " "))) 46 | } 47 | if (any((rtype > 2) & !isDate)) { 48 | indx <- which(rtype > 2 & !isDate) 49 | } 50 | for (i in (1:ncol(R))) { 51 | if (rtype[i] > 2) 52 | R[, i] <- ratetableDate(R[, i]) 53 | if (length(levlist[[i]]) > 0) { 54 | if (rtype[i] != 1) 55 | stop(paste("for this ratetable,", dimid[i], 56 | "must be a continuous variable")) 57 | temp <- charmatch(casefold(levlist[[i]]), casefold(dtemp[[i]])) 58 | if (any(is.na(temp))) 59 | stop(paste("Levels do not match for ratetable() variable", 60 | dimid[i])) 61 | if (any(temp == 0)) 62 | stop(paste("Non-unique ratetable match for variable", 63 | dimid[i])) 64 | R[, i] <- temp[as.numeric(R[, i])] 65 | } 66 | else { 67 | R[, i] <- unclass(R[, i]) 68 | if (rtype[i] == 1) { 69 | temp <- R[, i] 70 | if (any(floor(temp) != temp) || any(temp <= 0) || 71 | max(temp) > length(dtemp[[i]])) 72 | stop(paste("The variable", dimid[i], 73 | "is out of range")) 74 | } 75 | } 76 | } 77 | R <- as.matrix(R) 78 | summ <- function(R){ 79 | x <- c(format(round(min(R[, 1])/365.241, 1)), 80 | format(round(max(R[,1])/365.241, 1)), sum(R[, 3] == 1), sum(R[, 3] == 2)) 81 | x2 <- as.character(as.Date(c(min(R[, 2]), max(R[, 2])), origin=as.Date('1970-01-01'))) 82 | paste(" age ranges from", x[1], "to", x[2], "years\n", " male:", 83 | x[3], " female:", x[4], "\n", " date of entry from", 84 | x2[1], "to", x2[2], "\n") 85 | } 86 | cutpoints <- lapply(attr(ratetable, "cutpoints"), ratetableDate) 87 | if (is.null(summ)) 88 | list(R = R, cutpoints = cutpoints) 89 | else list(R = R, cutpoints = cutpoints, summ = summ(R)) 90 | } -------------------------------------------------------------------------------- /R/relsurv.varHaz.fixed.R: -------------------------------------------------------------------------------- 1 | #' Upgrade the varHaz object 2 | #' 3 | #' A function that upgrades varHaz from the msfit object where the variances are 4 | #' estimated using the Greenwood estimator; it is further assumed that variances for the population 5 | #' hazards are equal to zero. 6 | #' @param varHaz The varHaz object (present in a msfit object). 7 | #' @param link_trans A list that gives the linkage between the original and upgraded 8 | #' transition matrix. 9 | #' @param varHaz_original The original varHaz object from msfit (without the eventual time conversion). 10 | #' @return Return the upgraded varHaz object containing variances for the split transitions. 11 | #' @author Damjan Manevski \email{damjan.manevski@@mf.uni-lj.si} 12 | #' 13 | #' @export 14 | `varHaz.fixed` <- function(varHaz, link_trans, varHaz_original){ 15 | 16 | # Define new varHaz object: 17 | varHaz_new <- varHaz[0,] 18 | 19 | # Find all covariance combinations: 20 | var_trans <- unique(varHaz[,c("trans1","trans2")]) 21 | 22 | # For every combination write down the (co)variance: 23 | for(i in 1:nrow(var_trans)){ 24 | 25 | trans1 <- var_trans$trans1[i] 26 | trans2 <- var_trans$trans2[i] 27 | 28 | # Find the adequate transitions in trans_new: 29 | trans1_new <- link_trans[[ trans1 ]] 30 | trans2_new <- link_trans[[ trans2 ]] 31 | 32 | varHaz_tmp <- varHaz[(varHaz$trans1 == trans1) & 33 | (varHaz$trans2 == trans2), ] 34 | 35 | if((length(trans1_new) == 1) & (length(trans2_new) == 1)){ 36 | # Replace suitable tranistions and add matrix: 37 | varHaz_tmp$trans1 <- trans1_new 38 | varHaz_tmp$trans2 <- trans2_new 39 | varHaz_tmp$time <- varHaz_original$time[(varHaz_original$trans1 == trans1) & 40 | (varHaz_original$trans2 == trans2)] 41 | varHaz_new <- rbind(varHaz_new, varHaz_tmp) 42 | } 43 | else if(length(trans1_new) == 1){ 44 | # Replace suitable tranistions and add matrices: 45 | varHaz_tmp$trans1 <- trans1_new 46 | varHaz_tmp$trans2 <- trans2_new[2] 47 | varHaz_tmp$time <- varHaz_original$time[(varHaz_original$trans1 == trans1) & 48 | (varHaz_original$trans2 == trans2)] 49 | varHaz_tmp2 <- varHaz_tmp 50 | 51 | varHaz_tmp$trans2 <- trans2_new[1] 52 | varHaz_tmp$varHaz <- 0 53 | varHaz_new <- rbind(varHaz_new, varHaz_tmp, varHaz_tmp2) 54 | } 55 | else if(length(trans2_new) == 1){ 56 | # Replace suitable tranistions and add matrices: 57 | varHaz_tmp$trans1 <- trans1_new[2] 58 | varHaz_tmp$trans2 <- trans2_new 59 | varHaz_tmp$time <- varHaz_original$time[(varHaz_original$trans1 == trans1) & 60 | (varHaz_original$trans2 == trans2)] 61 | varHaz_tmp2 <- varHaz_tmp 62 | 63 | varHaz_tmp$trans1 <- trans1_new[1] 64 | varHaz_tmp$varHaz <- 0 65 | varHaz_new <- rbind(varHaz_new, varHaz_tmp, varHaz_tmp2) 66 | } 67 | else{ 68 | # Replace suitable tranistions and add matrices: 69 | varHaz_tmp$trans1 <- trans1_new[2] 70 | varHaz_tmp$trans2 <- trans2_new[2] 71 | varHaz_tmp$time <- varHaz_original$time[(varHaz_original$trans1 == trans1) & 72 | (varHaz_original$trans2 == trans2)] 73 | varHaz_tmp2 <- varHaz_tmp 74 | 75 | varHaz_tmp$trans1 <- trans1_new[1] 76 | varHaz_tmp$trans2 <- trans2_new[1] 77 | varHaz_tmp$varHaz <- 0 78 | varHaz_new <- rbind(varHaz_new, varHaz_tmp) 79 | 80 | varHaz_tmp$trans1 <- trans1_new[1] 81 | varHaz_tmp$trans2 <- trans2_new[2] 82 | varHaz_new <- rbind(varHaz_new, varHaz_tmp) 83 | 84 | if(!identical(trans1_new, trans2_new)){ 85 | varHaz_tmp$trans1 <- trans1_new[2] 86 | varHaz_tmp$trans2 <- trans2_new[1] 87 | varHaz_new <- rbind(varHaz_new, varHaz_tmp) 88 | } 89 | varHaz_new <- rbind(varHaz_new, varHaz_tmp2) 90 | } 91 | } 92 | 93 | return(varHaz_new) 94 | } -------------------------------------------------------------------------------- /R/summary.Cuminc.R: -------------------------------------------------------------------------------- 1 | #' Summary method for a summary.Cuminc object 2 | #' 3 | #' @param object Object of class 'Cuminc', to be summarised 4 | #' @param \dots Further arguments to summarise 5 | #' 6 | #' @export 7 | summary.Cuminc <- function(object, ...) 8 | { 9 | if (!inherits(object, "Cuminc")) 10 | stop("'object' must be a 'Cuminc' object") 11 | 12 | summary(attr(object, "survfit"), ...) 13 | } 14 | 15 | -------------------------------------------------------------------------------- /R/trans.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | `trans.comprisk` <- function(K, names) 3 | { 4 | tmat <- matrix(NA, K+1, K+1) 5 | tmat[1, 2:(K+1)] <- 1:K 6 | if (missing(names)) 7 | names <- c("eventfree",paste("cause",1:K,sep="")) 8 | else { 9 | if (length(names)==K) names <- c("eventfree",names) 10 | else { 11 | if (length(names) != K+1) 12 | stop("incorrect length of \"names\" argument") 13 | } 14 | } 15 | dimnames(tmat) <- list(from=names, to=names) 16 | return(tmat) 17 | } 18 | 19 | #' @export 20 | `trans.illdeath` <- function(names) 21 | { 22 | tmat <- matrix(NA, 3, 3) 23 | tmat[1, 2:3] <- 1:2 24 | tmat[2, 3] <- 3 25 | if (missing(names)) 26 | names <- c("healthy","illness","death") 27 | else { 28 | if (length(names)!=3) stop("incorrect length of \"names\" argument") 29 | } 30 | dimnames(tmat) <- list(from=names, to=names) 31 | return(tmat) 32 | } 33 | 34 | -------------------------------------------------------------------------------- /R/transMat.R: -------------------------------------------------------------------------------- 1 | #' Define transition matrix for multi-state model 2 | #' 3 | #' Define transition matrices for multi-state model. Specific functions for 4 | #' defining such transition matrices are pre-defined for common multi-state 5 | #' models like the competing risks model and the illness-death model. 6 | #' 7 | #' If \code{names} is missing, the names \code{"eventfree"}, \code{"cause1"}, 8 | #' etcetera are assigned in \code{trans.comprisk}, or \code{"healthy"}, 9 | #' \code{"illness"}, \code{"death"} in \code{trans.illdeath}. 10 | #' 11 | #' @aliases transMat trans.illdeath trans.comprisk 12 | #' @param x List of possible transitions; x[[i]] consists of a vector of state 13 | #' numbers reachable from state i 14 | #' @param names A character vector containing the names of either the competing 15 | #' risks or the states in the multi-state model specified by the competing 16 | #' risks or illness-death model. \code{names} should have the same length as 17 | #' the list \code{x} (for \code{transMat}), or either \code{K} or \code{K}+1 18 | #' (for \code{trans.comprisk}), or 3 (for \code{trans.illdeath}) 19 | #' @return A transition matrix describing the states and transitions in the 20 | #' multi-state model. 21 | #' @author Steven McKinney ; Hein Putter 22 | #' 23 | #' @keywords array 24 | #' @examples 25 | #' 26 | #' transMat(list(c(2, 3), c(), c(1, 2)), 27 | #' names = c("Disease-free", "Death", "Relapsed")) 28 | #' tmat <- transMat(x = list( c(2, 3), c(1, 3), c() ), 29 | #' names = c("Normal", "Low", "Death")) 30 | #' tmat 31 | #' transListn <- list("Normal" = c(2, 3), "Low" = c(1, 3), "Death" = c()) 32 | #' transMat(transListn) 33 | #' trans.comprisk(3) 34 | #' trans.comprisk(3,c("c1","c2","c3")) 35 | #' trans.comprisk(3,c("nothing","c1","c2","c3")) 36 | #' trans.illdeath() 37 | #' trans.illdeath(c("nothing","ill","death")) 38 | #' 39 | #' @export transMat 40 | transMat <- function(x, names) { 41 | ## transMat: produce transition matrix for use in package 'mstate'. 42 | ## Arguments: 43 | ## x: List of possible transitions. 44 | ## x[[i]] consists of a vector of state numbers 45 | ## reachable from state i. 46 | ## names: Character vector of state names, having the same length 47 | ## as x. 48 | ## Example: States 1 and 2 are reachable from one 49 | ## another. State 3 is absorbing, reachable from 50 | ## states 1 and 2. 51 | ## transMat( x = list( c(2, 3), c(1, 3), c() ) ) 52 | if ( !is.list(x) ) stop("x must be a list") 53 | ns <- length(x) ## number of states 54 | tmat <- matrix(NA, nrow = ns, ncol = ns) ## transition matrix 55 | if ( missing(names) ) { 56 | if ( !is.null( base::names(x) ) ) { 57 | namesList <- list(from = base::names(x), to = base::names(x)) 58 | } else { 59 | namesList <- list(from = paste("State", seq(nrow(tmat))), 60 | to = paste("State", seq(nrow(tmat)))) 61 | } 62 | } else { 63 | if ( length(names) != ns ) stop("length of 'names' must equal length of 'x'") 64 | namesList <- list(from = names, to = names) 65 | } 66 | idxmat <- cbind(unlist(lapply(seq(ns), 67 | function(i, y){ 68 | rep(i, length(y[[i]]))}, x)), 69 | unlist(x)) 70 | if ( max(idxmat) > ns ) 71 | stop("Largest state in transition list exceeds number of states") 72 | tmat[idxmat] <- seq(nrow(idxmat)) 73 | dimnames(tmat) <- namesList 74 | tmat 75 | } 76 | -------------------------------------------------------------------------------- /R/transhelp.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | `to.trans2` <- function(trans) 3 | { 4 | dm <- dim(trans) 5 | if (dm[1] != dm[2]) stop("transition matrix should be square") 6 | S <- dm[1] 7 | mx <- max(trans, na.rm=TRUE) 8 | res <- matrix(NA, mx, 3) 9 | res[, 1] <- 1:mx 10 | transvec <- as.vector(trans) 11 | for (i in 1:mx) { 12 | idx <- which(transvec==i) 13 | res[i, 2:3] <- c((idx-1) %% S + 1, (idx-1) %/% S + 1) 14 | } 15 | res <- data.frame(res) 16 | names(res) <- c("transno", "from", "to") 17 | res$from[res$from==0] <- S 18 | statesfrom <- dimnames(trans)[[1]] 19 | if (is.null(statesfrom)) statesfrom <- 1:S 20 | statesto <- dimnames(trans)[[2]] 21 | if (is.null(statesto)) statesto <- 1:S 22 | res$fromname <- statesfrom[res$from] 23 | res$toname <- statesto[res$to] 24 | res$transname <- paste(res$fromname, res$toname, sep=" -> ") 25 | return(res) 26 | } 27 | 28 | #' @export 29 | `trans2Q` <- function(trans) 30 | { 31 | K <- nrow(trans) 32 | P <- trans 33 | P[!is.na(P)] <- 1 34 | P[is.na(P)] <- 0 35 | diag(P) <- 1 36 | k <- 1 37 | # deb(k, method="cat") 38 | Pk <- P 39 | diag(Pk) <- 0 40 | # deb(Pk) 41 | Pkprev <- Pk 42 | Q <- Pk 43 | for (k in 2:K) { 44 | # deb(k, method="cat") 45 | Pk <- Pk %*% P 46 | Pk[Pk > 1] <- 1 47 | # deb(Pk) 48 | # deb(Pk - Pkprev) 49 | Q <- Q + k * (Pk - Pkprev) 50 | # deb(Q) 51 | Pkprev <- Pk 52 | } 53 | Q 54 | } 55 | 56 | #' @export 57 | `absorbing` <- function(trans) 58 | { 59 | Q <- trans2Q(trans) 60 | wh <- which(apply(Q, 1, sum) == 0) 61 | wh 62 | } 63 | 64 | #' @export 65 | `is.circular` <- function(trans) 66 | { 67 | Q <- trans2Q(trans) 68 | return(any(diag(Q)>0)) 69 | } 70 | -------------------------------------------------------------------------------- /R/xsect.R: -------------------------------------------------------------------------------- 1 | #' Make a cross-section of multi-state data at a given time point 2 | #' 3 | #' Given a dataset in long format, for instance generated by 4 | #' \code{\link{msprep}}, this function takes a cross-section at a given time 5 | #' point, to list the subjects under observation (at risk) at that time point 6 | #' and the states currently occupied. 7 | #' 8 | #' It is possible that subjects have moved to one of the absorbing states prior 9 | #' to \code{xtime}; this is NOT taken into account. The function \code{xsect} 10 | #' only concerns subjects currently (at \code{time}) at risk. 11 | #' 12 | #' @param msdata An object of class \code{"msdata"}, such as output by 13 | #' \code{\link{msprep}} 14 | #' @param xtime The time point at which the intersection is to be made 15 | #' @return A list containing \code{idstate}, a data frame containing 16 | #' \code{id}'s and \code{state}, the number of the state currently occupied; 17 | #' \code{atrisk}, the number at risk, and \code{prop}, a table counting how 18 | #' many of those at risk occupy which state. 19 | #' @author Hein Putter \email{H.Putter@@lumc.nl} 20 | #' @keywords univar 21 | #' @examples 22 | #' 23 | #' tmat <- trans.illdeath(names=c("Tx","PR","RelDeath")) 24 | #' data(ebmt3) # data from Section 4 of Putter, Fiocco & Geskus (2007) 25 | #' msebmt <- msprep(time=c(NA,"prtime","rfstime"),status=c(NA,"prstat","rfsstat"), 26 | #' data=ebmt3,trans=tmat) 27 | #' # At the start everyone is in state 1 (default xtime=0 is used) 28 | #' xsect(msebmt) 29 | #' # At 5 years 30 | #' xsect(msebmt, xtime=1826) 31 | #' 32 | #' @export xsect 33 | xsect <- function(msdata, xtime=0) 34 | { 35 | msd <- msdata[msdata$Tstart<=xtime & msdata$Tstop>xtime,] 36 | msd <- msd[order(msd$id, msd$trans, msd$Tstart),] 37 | msd <- msd[!duplicated(msd$id),] 38 | idstate <- data.frame(id=msd$id, state=msd$from) 39 | tmat <- attr(msdata, "trans") 40 | K <- nrow(tmat) 41 | msd$from <- factor(msd$from, levels=1:K, labels=1:K) 42 | tbl <- table(msd$from) 43 | atrisk <- sum(tbl) 44 | prop <- tbl/atrisk 45 | res <- idstate 46 | attr(res, "atrisk") <- tbl 47 | attr(res, "prop") <- prop 48 | return(res) 49 | } 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mstate 2 | 3 | 4 | [![](https://www.r-pkg.org/badges/version/mstate?color=orange)](https://cran.r-project.org/package=mstate) 5 | [![](http://cranlogs.r-pkg.org/badges/last-month/mstate?color=gray)](https://cran.r-project.org/package=mstate) 6 | [![](http://cranlogs.r-pkg.org/badges/grand-total/mstate?color=blue)](https://cran.r-project.org/package=mstate) 7 | [![](https://img.shields.io/badge/doi-10.1002/sim.2712-yellow.svg)](https://doi.org/10.1002/sim.2712) 8 | 9 | 10 | ## Installation 11 | 12 | You can install the released version of mstate from [CRAN](https://CRAN.R-project.org) with: 13 | 14 | ``` r 15 | install.packages("mstate") 16 | ``` 17 | Alternatively, you can install the development version from GitHub: 18 | 19 | ``` r 20 | devtools::install_github("hputter/mstate") 21 | ``` 22 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://hputter.github.io/mstate/ 2 | template: 3 | bootstrap: 5 4 | -------------------------------------------------------------------------------- /data/aidssi.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/data/aidssi.RData -------------------------------------------------------------------------------- /data/aidssi2.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/data/aidssi2.RData -------------------------------------------------------------------------------- /data/bmt.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/data/bmt.RData -------------------------------------------------------------------------------- /data/ebmt1.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/data/ebmt1.RData -------------------------------------------------------------------------------- /data/ebmt2.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/data/ebmt2.RData -------------------------------------------------------------------------------- /data/ebmt3.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/data/ebmt3.RData -------------------------------------------------------------------------------- /data/ebmt4.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/data/ebmt4.RData -------------------------------------------------------------------------------- /data/prothr.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/data/prothr.RData -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page not found (404) • mstate 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Skip to contents 17 | 18 | 19 |
52 |
53 |
58 | 59 | Content not found. Please use links in the navbar. 60 | 61 |
62 |
63 | 64 | 65 |
68 | 69 | 72 | 73 |
74 |
75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | Articles • mstate 3 | Skip to contents 4 | 5 | 6 |
32 |
33 |
37 | 38 |
39 |

All vignettes

40 |
41 | 42 |
Visualising multi-state models using mstate
43 |
44 |
45 |
46 | 47 | 48 |
51 | 52 | 55 | 56 |
57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/anchor-sections-1.0/anchor-sections.css: -------------------------------------------------------------------------------- 1 | /* Styles for section anchors */ 2 | a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;} 3 | a.anchor-section::before {content: '#';} 4 | .hasAnchor:hover a.anchor-section {visibility: visible;} 5 | -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/anchor-sections-1.0/anchor-sections.js: -------------------------------------------------------------------------------- 1 | // Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020. 2 | document.addEventListener('DOMContentLoaded', function() { 3 | // Do nothing if AnchorJS is used 4 | if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) { 5 | return; 6 | } 7 | 8 | const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); 9 | 10 | // Do nothing if sections are already anchored 11 | if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) { 12 | return null; 13 | } 14 | 15 | // Use section id when pandoc runs with --section-divs 16 | const section_id = function(x) { 17 | return ((x.classList.contains('section') || (x.tagName === 'SECTION')) 18 | ? x.id : ''); 19 | }; 20 | 21 | // Add anchors 22 | h.forEach(function(x) { 23 | const id = x.id || section_id(x.parentElement); 24 | if (id === '') { 25 | return null; 26 | } 27 | let anchor = document.createElement('a'); 28 | anchor.href = '#' + id; 29 | anchor.classList = ['anchor-section']; 30 | x.classList.add('hasAnchor'); 31 | x.appendChild(anchor); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/mirror1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/mirror1-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/mirror2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/mirror2-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/msfitplot_base_1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/msfitplot_base_1-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/msfitplot_base_2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/msfitplot_base_2-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/msfitplot_confint1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/msfitplot_confint1-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/msfitplot_confint2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/msfitplot_confint2-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/msfitplot_customs-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/msfitplot_customs-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/msfitplot_customs-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/msfitplot_customs-2.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/msfitplot_ggplot2_1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/msfitplot_ggplot2_1-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/msfitplot_ggplot_2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/msfitplot_ggplot_2-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/msfitplot_ggplot_2-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/msfitplot_ggplot_2-2.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot.Cuminc1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot.Cuminc1-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot.cuminc_x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot.cuminc_x-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot.cuminc_x-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot.cuminc_x-2.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot_pt_filled1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot_pt_filled1-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot_pt_filled2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot_pt_filled2-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot_pt_filled3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot_pt_filled3-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot_pt_filled4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot_pt_filled4-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot_pt_separate1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot_pt_separate1-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot_pt_separate2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot_pt_separate2-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot_pt_single1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot_pt_single1-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot_pt_single2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot_pt_single2-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot_pt_single3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot_pt_single3-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/plot_pt_stacked-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/plot_pt_stacked-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/vis_multiple_plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/vis_multiple_plot-1.png -------------------------------------------------------------------------------- /docs/articles/visuals_demo_files/figure-html/vis_multiple_plot2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/articles/visuals_demo_files/figure-html/vis_multiple_plot2-1.png -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v1.0.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | !function(a){"use strict";window.Toc={helpers:{findOrFilter:function(e,t){var n=e.find(t);return e.filter(t).add(n).filter(":not([data-toc-skip])")},generateUniqueIdBase:function(e){return a(e).text().trim().replace(/\'/gi,"").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g,"-").replace(/-{2,}/g,"-").substring(0,64).replace(/^-+|-+$/gm,"").toLowerCase()||e.tagName.toLowerCase()},generateUniqueId:function(e){for(var t=this.generateUniqueIdBase(e),n=0;;n++){var r=t;if(0')},createChildNavList:function(e){var t=this.createNavList();return e.append(t),t},generateNavEl:function(e,t){var n=a('');n.attr("href","#"+e),n.text(t);var r=a("
  • ");return r.append(n),r},generateNavItem:function(e){var t=this.generateAnchor(e),n=a(e),r=n.data("toc-text")||n.text();return this.generateNavEl(t,r)},getTopLevel:function(e){for(var t=1;t<=6;t++){if(1 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2 -------------------------------------------------------------------------------- /docs/deps/headroom-0.11.0/headroom.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * headroom.js v0.11.0 - Give your page some headroom. Hide your header until you need it 3 | * Copyright (c) 2020 Nick Williams - http://wicky.nillia.ms/headroom.js 4 | * License: MIT 5 | */ 6 | 7 | !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).Headroom=n()}(this,function(){"use strict";function t(){return"undefined"!=typeof window}function d(t){return function(t){return t&&t.document&&function(t){return 9===t.nodeType}(t.document)}(t)?function(t){var n=t.document,o=n.body,s=n.documentElement;return{scrollHeight:function(){return Math.max(o.scrollHeight,s.scrollHeight,o.offsetHeight,s.offsetHeight,o.clientHeight,s.clientHeight)},height:function(){return t.innerHeight||s.clientHeight||o.clientHeight},scrollY:function(){return void 0!==t.pageYOffset?t.pageYOffset:(s||o.parentNode||o).scrollTop}}}(t):function(t){return{scrollHeight:function(){return Math.max(t.scrollHeight,t.offsetHeight,t.clientHeight)},height:function(){return Math.max(t.offsetHeight,t.clientHeight)},scrollY:function(){return t.scrollTop}}}(t)}function n(t,s,e){var n,o=function(){var n=!1;try{var t={get passive(){n=!0}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){n=!1}return n}(),i=!1,r=d(t),l=r.scrollY(),a={};function c(){var t=Math.round(r.scrollY()),n=r.height(),o=r.scrollHeight();a.scrollY=t,a.lastScrollY=l,a.direction=ls.tolerance[a.direction],e(a),l=t,i=!1}function h(){i||(i=!0,n=requestAnimationFrame(c))}var u=!!o&&{passive:!0,capture:!1};return t.addEventListener("scroll",h,u),c(),{destroy:function(){cancelAnimationFrame(n),t.removeEventListener("scroll",h,u)}}}function o(t,n){n=n||{},Object.assign(this,o.options,n),this.classes=Object.assign({},o.options.classes,n.classes),this.elem=t,this.tolerance=function(t){return t===Object(t)?t:{down:t,up:t}}(this.tolerance),this.initialised=!1,this.frozen=!1}return o.prototype={constructor:o,init:function(){return o.cutsTheMustard&&!this.initialised&&(this.addClass("initial"),this.initialised=!0,setTimeout(function(t){t.scrollTracker=n(t.scroller,{offset:t.offset,tolerance:t.tolerance},t.update.bind(t))},100,this)),this},destroy:function(){this.initialised=!1,Object.keys(this.classes).forEach(this.removeClass,this),this.scrollTracker.destroy()},unpin:function(){!this.hasClass("pinned")&&this.hasClass("unpinned")||(this.addClass("unpinned"),this.removeClass("pinned"),this.onUnpin&&this.onUnpin.call(this))},pin:function(){this.hasClass("unpinned")&&(this.addClass("pinned"),this.removeClass("unpinned"),this.onPin&&this.onPin.call(this))},freeze:function(){this.frozen=!0,this.addClass("frozen")},unfreeze:function(){this.frozen=!1,this.removeClass("frozen")},top:function(){this.hasClass("top")||(this.addClass("top"),this.removeClass("notTop"),this.onTop&&this.onTop.call(this))},notTop:function(){this.hasClass("notTop")||(this.addClass("notTop"),this.removeClass("top"),this.onNotTop&&this.onNotTop.call(this))},bottom:function(){this.hasClass("bottom")||(this.addClass("bottom"),this.removeClass("notBottom"),this.onBottom&&this.onBottom.call(this))},notBottom:function(){this.hasClass("notBottom")||(this.addClass("notBottom"),this.removeClass("bottom"),this.onNotBottom&&this.onNotBottom.call(this))},shouldUnpin:function(t){return"down"===t.direction&&!t.top&&t.toleranceExceeded},shouldPin:function(t){return"up"===t.direction&&t.toleranceExceeded||t.top},addClass:function(t){this.elem.classList.add.apply(this.elem.classList,this.classes[t].split(" "))},removeClass:function(t){this.elem.classList.remove.apply(this.elem.classList,this.classes[t].split(" "))},hasClass:function(t){return this.classes[t].split(" ").every(function(t){return this.classList.contains(t)},this.elem)},update:function(t){t.isOutOfBounds||!0!==this.frozen&&(t.top?this.top():this.notTop(),t.bottom?this.bottom():this.notBottom(),this.shouldUnpin(t)?this.unpin():this.shouldPin(t)&&this.pin())}},o.options={tolerance:{up:0,down:0},offset:0,scroller:t()?window:null,classes:{frozen:"headroom--frozen",pinned:"headroom--pinned",unpinned:"headroom--unpinned",top:"headroom--top",notTop:"headroom--not-top",bottom:"headroom--bottom",notBottom:"headroom--not-bottom",initial:"headroom"}},o.cutsTheMustard=!!(t()&&function(){}.bind&&"classList"in document.documentElement&&Object.assign&&Object.keys&&requestAnimationFrame),o}); -------------------------------------------------------------------------------- /docs/deps/headroom-0.11.0/jQuery.headroom.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * headroom.js v0.9.4 - Give your page some headroom. Hide your header until you need it 3 | * Copyright (c) 2017 Nick Williams - http://wicky.nillia.ms/headroom.js 4 | * License: MIT 5 | */ 6 | 7 | !function(a){a&&(a.fn.headroom=function(b){return this.each(function(){var c=a(this),d=c.data("headroom"),e="object"==typeof b&&b;e=a.extend(!0,{},Headroom.options,e),d||(d=new Headroom(this,e),d.init(),c.data("headroom",d)),"string"==typeof b&&(d[b](),"destroy"===b&&c.removeData("headroom"))})},a("[data-headroom]").each(function(){var b=a(this);b.headroom(b.data())}))}(window.Zepto||window.jQuery); -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /docs/katex-auto.js: -------------------------------------------------------------------------------- 1 | // https://github.com/jgm/pandoc/blob/29fa97ab96b8e2d62d48326e1b949a71dc41f47a/src/Text/Pandoc/Writers/HTML.hs#L332-L345 2 | document.addEventListener("DOMContentLoaded", function () { 3 | var mathElements = document.getElementsByClassName("math"); 4 | var macros = []; 5 | for (var i = 0; i < mathElements.length; i++) { 6 | var texText = mathElements[i].firstChild; 7 | if (mathElements[i].tagName == "SPAN") { 8 | katex.render(texText.data, mathElements[i], { 9 | displayMode: mathElements[i].classList.contains("display"), 10 | throwOnError: false, 11 | macros: macros, 12 | fleqn: false 13 | }); 14 | }}}); 15 | -------------------------------------------------------------------------------- /docs/lightswitch.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Color mode toggler for Bootstrap's docs (https://getbootstrap.com/) 4 | * Copyright 2011-2023 The Bootstrap Authors 5 | * Licensed under the Creative Commons Attribution 3.0 Unported License. 6 | * Updates for {pkgdown} by the {bslib} authors, also licensed under CC-BY-3.0. 7 | */ 8 | 9 | const getStoredTheme = () => localStorage.getItem('theme') 10 | const setStoredTheme = theme => localStorage.setItem('theme', theme) 11 | 12 | const getPreferredTheme = () => { 13 | const storedTheme = getStoredTheme() 14 | if (storedTheme) { 15 | return storedTheme 16 | } 17 | 18 | return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' 19 | } 20 | 21 | const setTheme = theme => { 22 | if (theme === 'auto') { 23 | document.documentElement.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) 24 | } else { 25 | document.documentElement.setAttribute('data-bs-theme', theme) 26 | } 27 | } 28 | 29 | function bsSetupThemeToggle () { 30 | 'use strict' 31 | 32 | const showActiveTheme = (theme, focus = false) => { 33 | var activeLabel, activeIcon; 34 | 35 | document.querySelectorAll('[data-bs-theme-value]').forEach(element => { 36 | const buttonTheme = element.getAttribute('data-bs-theme-value') 37 | const isActive = buttonTheme == theme 38 | 39 | element.classList.toggle('active', isActive) 40 | element.setAttribute('aria-pressed', isActive) 41 | 42 | if (isActive) { 43 | activeLabel = element.textContent; 44 | activeIcon = element.querySelector('span').classList.value; 45 | } 46 | }) 47 | 48 | const themeSwitcher = document.querySelector('#dropdown-lightswitch') 49 | if (!themeSwitcher) { 50 | return 51 | } 52 | 53 | themeSwitcher.setAttribute('aria-label', activeLabel) 54 | themeSwitcher.querySelector('span').classList.value = activeIcon; 55 | 56 | if (focus) { 57 | themeSwitcher.focus() 58 | } 59 | } 60 | 61 | window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => { 62 | const storedTheme = getStoredTheme() 63 | if (storedTheme !== 'light' && storedTheme !== 'dark') { 64 | setTheme(getPreferredTheme()) 65 | } 66 | }) 67 | 68 | window.addEventListener('DOMContentLoaded', () => { 69 | showActiveTheme(getPreferredTheme()) 70 | 71 | document 72 | .querySelectorAll('[data-bs-theme-value]') 73 | .forEach(toggle => { 74 | toggle.addEventListener('click', () => { 75 | const theme = toggle.getAttribute('data-bs-theme-value') 76 | setTheme(theme) 77 | setStoredTheme(theme) 78 | showActiveTheme(theme, true) 79 | }) 80 | }) 81 | }) 82 | } 83 | 84 | setTheme(getPreferredTheme()); 85 | bsSetupThemeToggle(); 86 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: '3.5' 2 | pkgdown: 2.1.1 3 | pkgdown_sha: ~ 4 | articles: 5 | visuals_demo: visuals_demo.html 6 | last_built: 2024-11-29T16:41Z 7 | urls: 8 | reference: https://hputter.github.io/mstate/reference 9 | article: https://hputter.github.io/mstate/articles 10 | -------------------------------------------------------------------------------- /docs/reference/LMAJ-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/LMAJ-1.png -------------------------------------------------------------------------------- /docs/reference/MarkovTest-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/MarkovTest-1.png -------------------------------------------------------------------------------- /docs/reference/MarkovTest-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/MarkovTest-2.png -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /docs/reference/Rplot002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/Rplot002.png -------------------------------------------------------------------------------- /docs/reference/Rplot003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/Rplot003.png -------------------------------------------------------------------------------- /docs/reference/Rplot004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/Rplot004.png -------------------------------------------------------------------------------- /docs/reference/absorbing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/aidssi2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/crprep.default-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/crprep.default-1.png -------------------------------------------------------------------------------- /docs/reference/crprep.default-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/crprep.default-2.png -------------------------------------------------------------------------------- /docs/reference/crprep.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ebmt1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ebmt2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ebmt3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ebmt4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/expand.covs.default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is.circular.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/mstate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/optimal_weights_matrix.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/optimal_weights_multiple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/plot.Cuminc-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/plot.Cuminc-1.png -------------------------------------------------------------------------------- /docs/reference/plot.Cuminc-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/plot.Cuminc-2.png -------------------------------------------------------------------------------- /docs/reference/plot.msfit-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/plot.msfit-1.png -------------------------------------------------------------------------------- /docs/reference/plot.msfit-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/plot.msfit-2.png -------------------------------------------------------------------------------- /docs/reference/plot.msfit-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/plot.msfit-3.png -------------------------------------------------------------------------------- /docs/reference/plot.msfit-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/plot.msfit-4.png -------------------------------------------------------------------------------- /docs/reference/plot.probtrans-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/plot.probtrans-1.png -------------------------------------------------------------------------------- /docs/reference/plot.probtrans-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/plot.probtrans-2.png -------------------------------------------------------------------------------- /docs/reference/plot.probtrans-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/plot.probtrans-3.png -------------------------------------------------------------------------------- /docs/reference/plot.probtrans-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/plot.probtrans-4.png -------------------------------------------------------------------------------- /docs/reference/print.Cuminc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/prothr.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/to.trans2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/tra2trans.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/trans.comprisk.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/trans.illdeath.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/trans2Q.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/vis.mirror.pt-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/vis.mirror.pt-1.png -------------------------------------------------------------------------------- /docs/reference/vis.multiple.pt-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/docs/reference/vis.multiple.pt-1.png -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | https://hputter.github.io/mstate/404.html 3 | https://hputter.github.io/mstate/articles/index.html 4 | https://hputter.github.io/mstate/articles/visuals_demo.html 5 | https://hputter.github.io/mstate/authors.html 6 | https://hputter.github.io/mstate/index.html 7 | https://hputter.github.io/mstate/news/index.html 8 | https://hputter.github.io/mstate/reference/EBMT-cause-of-death-data.html 9 | https://hputter.github.io/mstate/reference/EBMT-data.html 10 | https://hputter.github.io/mstate/reference/EBMT-platelet-recovery-data.html 11 | https://hputter.github.io/mstate/reference/EBMT-year-of-relapse-data.html 12 | https://hputter.github.io/mstate/reference/ELOS.html 13 | https://hputter.github.io/mstate/reference/LMAJ.html 14 | https://hputter.github.io/mstate/reference/Liver-cirrhosis-data.html 15 | https://hputter.github.io/mstate/reference/MarkovTest.html 16 | https://hputter.github.io/mstate/reference/aidssi.html 17 | https://hputter.github.io/mstate/reference/bmt.html 18 | https://hputter.github.io/mstate/reference/crprep.default.html 19 | https://hputter.github.io/mstate/reference/cuminc.html 20 | https://hputter.github.io/mstate/reference/cutLMms.html 21 | https://hputter.github.io/mstate/reference/etm2msdata.html 22 | https://hputter.github.io/mstate/reference/events.html 23 | https://hputter.github.io/mstate/reference/expand.covs.html 24 | https://hputter.github.io/mstate/reference/expand.covs.msdata.html 25 | https://hputter.github.io/mstate/reference/haz_function.html 26 | https://hputter.github.io/mstate/reference/index.html 27 | https://hputter.github.io/mstate/reference/modify_transMat.html 28 | https://hputter.github.io/mstate/reference/msboot.html 29 | https://hputter.github.io/mstate/reference/msboot.relsurv.boot.html 30 | https://hputter.github.io/mstate/reference/msboot.relsurv.html 31 | https://hputter.github.io/mstate/reference/msdata2etm.html 32 | https://hputter.github.io/mstate/reference/msfit.html 33 | https://hputter.github.io/mstate/reference/msfit.relsurv.html 34 | https://hputter.github.io/mstate/reference/msprep.html 35 | https://hputter.github.io/mstate/reference/mssample.html 36 | https://hputter.github.io/mstate/reference/mstate-package.html 37 | https://hputter.github.io/mstate/reference/paths.html 38 | https://hputter.github.io/mstate/reference/plot.Cuminc.html 39 | https://hputter.github.io/mstate/reference/plot.MarkovTest.html 40 | https://hputter.github.io/mstate/reference/plot.msfit.html 41 | https://hputter.github.io/mstate/reference/plot.probtrans.html 42 | https://hputter.github.io/mstate/reference/print.MarkovTest.html 43 | https://hputter.github.io/mstate/reference/print.msdata.html 44 | https://hputter.github.io/mstate/reference/print.summary.msfit.html 45 | https://hputter.github.io/mstate/reference/print.summary.probtrans.html 46 | https://hputter.github.io/mstate/reference/probtrans.html 47 | https://hputter.github.io/mstate/reference/redrank.html 48 | https://hputter.github.io/mstate/reference/summary.Cuminc.html 49 | https://hputter.github.io/mstate/reference/summary.msfit.html 50 | https://hputter.github.io/mstate/reference/summary.probtrans.html 51 | https://hputter.github.io/mstate/reference/trans2tra.html 52 | https://hputter.github.io/mstate/reference/transMat.html 53 | https://hputter.github.io/mstate/reference/transhelp.html 54 | https://hputter.github.io/mstate/reference/varHaz.fixed.html 55 | https://hputter.github.io/mstate/reference/vis.mirror.pt.html 56 | https://hputter.github.io/mstate/reference/vis.multiple.pt.html 57 | https://hputter.github.io/mstate/reference/xsect.html 58 | 59 | 60 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite mstate in publications use:") 2 | 3 | bibentry( 4 | bibtype = "Article", 5 | title = "{mstate}: An {R} Package for the Analysis of Competing Risks and Multi-State Models", 6 | author = c(person("Liesbeth C.", "de Wreede"), 7 | as.person("Marta Fiocco"), 8 | as.person("Hein Putter")), 9 | journal = "Journal of Statistical Software", 10 | year = "2011", 11 | volume = "38", 12 | number = "7", 13 | pages = "1--30", 14 | doi = "10.18637/jss.v038.i07", 15 | url = "https://www.jstatsoft.org/v38/i07/", 16 | key = "mstateJSS2011", 17 | textVersion = 18 | paste("Liesbeth C. de Wreede, Marta Fiocco, Hein Putter (2011).", 19 | "mstate: An R Package for the Analysis of Competing Risks and Multi-State Models.", 20 | "Journal of Statistical Software, 38(7), 1-30.", 21 | "URL https://www.jstatsoft.org/v38/i07/.") 22 | ) 23 | 24 | bibentry( 25 | bibtype = "Article", 26 | title = "The {mstate} Package for Estimation and Prediction in Non- and Semi-Parametric Multi-State and Competing Risks Models", 27 | author = c(person("Liesbeth C.", "de Wreede"), 28 | as.person("Marta Fiocco"), 29 | as.person("Hein Putter")), 30 | journal = "Computer Methods and Programs in Biomedicine", 31 | year = "2010", 32 | volume = "99", 33 | pages = "261--274", 34 | key = "mstateCompMethods2010", 35 | textVersion = 36 | paste("Liesbeth C. de Wreede, Marta Fiocco, Hein Putter (2010)", 37 | "The {mstate} Package for Estimation and Prediction in Non- and Semi-Parametric Multi-State and Competing Risks Models.", 38 | "Computer Methods and Programs in Biomedicine, 99, 261-274.") 39 | ) 40 | 41 | bibentry( 42 | bibtype = "Article", 43 | title = "Tutorial in Biostatistics: Competing Risks and Multi-State Models", 44 | author = c(as.person("Hein Putter"), 45 | person("Ronald B.", "Geskus"), 46 | as.person("Marta Fiocco")), 47 | journal = "Statistics in Medicine", 48 | year = "2007", 49 | number = "26", 50 | pages = "2389--2430", 51 | key = "mstateTutorial2007", 52 | textVersion = 53 | paste("Hein Putter, Marta Fiocco, and Ronald B. Geskus (2007)", 54 | "Tutorial in Biostatistics: Competing Risks and Multi-State Models.", 55 | "Statistics in Medicine, 26, 2389-2340.") 56 | ) -------------------------------------------------------------------------------- /man/Cuminc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Cuminc.R 3 | \name{Cuminc} 4 | \alias{Cuminc} 5 | \alias{print.Cuminc} 6 | \title{Calculate nonparametric cumulative incidence functions and associated 7 | standard errors} 8 | \usage{ 9 | Cuminc(time, status, data, group, na.status = c("remove", "extra"), ...) 10 | } 11 | \arguments{ 12 | \item{time}{Either 1) a numeric vector containing the failure times or 2) a 13 | string containing the column name indicating these failure times} 14 | 15 | \item{status}{Either 1) a numeric, factor or character vector containing the 16 | failure codes or 2) a string containing the column name indicating these 17 | failure codes} 18 | 19 | \item{data}{When appropriate, a data frame containing \code{time}, 20 | \code{status} and/or \code{group} variables} 21 | 22 | \item{group}{Optionally, name of column in data indicating a grouping 23 | variable; cumulative incidence functions are calculated for each value or 24 | level of \code{group}. If missing no groups are considered} 25 | 26 | \item{na.status}{One of \code{"remove"} (default) or \code{"extra"}, 27 | indicating whether subjects with missing cause of failure should be removed 28 | or whether missing cause of failure should be treated as a separate cause of 29 | failure} 30 | 31 | \item{...}{Allows extra arguments for future extensions, but for now just 32 | used for backwards compatibility (e.g. allowing use of defunct \code{failcodes} 33 | argument in reverse dependencies).} 34 | } 35 | \value{ 36 | An object of class \code{"Cuminc"}, which is a data frame containing 37 | the estimated failure-free probabilities and cumulative incidences and their 38 | standard errors. The names of the dataframe are \code{time}, \code{Surv}, 39 | \code{seSurv}, and \code{cuminc} and \code{secuminc} followed by the values 40 | or levels of the \code{failcodes}. If \code{group} was specified, a 41 | \code{group} variable is included with the same name and values/levels as 42 | the original grouping variable, and with estimated cumulative incidences 43 | (SE) for each value/level of \code{group}. 44 | 45 | Cuminc is now simply a wrapper around survfit of the survival package with 46 | type=\code{"mstate"}, only maintained for backward compatibility. The 47 | survfit object is kept as attribute (\code{attr("survfit")}), and the print, 48 | plot and summary functions are simply print, plot and summary applied to the 49 | survfit object. Subsetting the \code{"Cuminc"} object results in subsetting 50 | the data frame, not in subsetting the survfit object. 51 | } 52 | \description{ 53 | This function computes nonparametric cumulative incidence functions and 54 | associated standard errors for each value of a group variable. 55 | } 56 | \details{ 57 | The estimated cumulative incidences are as described in Putter, Fiocco & 58 | Geskus (2007); the standard errors are the square roots of the Greenwood 59 | variance estimators, see eg. Andersen, Borgan, Gill & Keiding (1993), de 60 | Wreede, Fiocco & Putter (2009), and they correspond to the variances in eg. 61 | Marubini & Valsecchi (1995). In case of no censoring, the estimated 62 | cumulative incidences and variances reduce to simple binomial frequencies 63 | and their variances. 64 | } 65 | \examples{ 66 | 67 | ### These data were used in Putter, Fiocco & Geskus (2007) 68 | data(aidssi) 69 | ci <- Cuminc(time=aidssi$time, status=aidssi$status) 70 | head(ci); tail(ci) 71 | ci <- Cuminc(time="time", status="status", data=aidssi, group="ccr5") 72 | head(ci); tail(ci) 73 | 74 | ### Some fake data 75 | fake <- data.frame(surv=c(seq(2,10,by=2),seq(1,13,by=3),seq(1,9,by=2),seq(1,13,by=3)), 76 | stat=rep(0:3,5),Tstage=c(1:4,rep(1:4,rep(4,4)))) 77 | fake$stat[fake$stat==0 & fake$Tstage==2] <- 3 78 | fake$stat[fake$stat==3 & fake$Tstage==1] <- 2 79 | fake 80 | Cuminc(time="surv", status="stat", data=fake) 81 | # If we remove all entries with status=0, 82 | # we should get binomial sample probabilities and corresponding SEs 83 | fake0 <- fake[fake$stat!=0,] 84 | Cuminc(time="surv", status="stat", data=fake0) 85 | 86 | } 87 | \references{ 88 | Andersen PK, Borgan O, Gill RD, Keiding N (1993). 89 | \emph{Statistical Models Based on Counting Processes}. Springer, New York. 90 | 91 | Marubini E, Valsecchi MG (1995). \emph{Analysing Survival Data from Clinical 92 | Trials and Observational Studies}. Wiley, New York. 93 | 94 | Putter H, Fiocco M, Geskus RB (2007). Tutorial in biostatistics: Competing 95 | risks and multi-state models. \emph{Statistics in Medicine} \bold{26}, 96 | 2389--2430. 97 | 98 | de Wreede L, Fiocco M, Putter H (2009). The mstate package for estimation 99 | and prediction in non- and semi-parametric multi-state models. Submitted. 100 | } 101 | \author{ 102 | Hein Putter \email{H.Putter@lumc.nl} 103 | } 104 | \keyword{survival} 105 | -------------------------------------------------------------------------------- /man/EBMT-cause-of-death-data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datasets.R 3 | \docType{data} 4 | \name{EBMT cause of death data} 5 | \alias{EBMT cause of death data} 6 | \alias{ebmt2} 7 | \title{Data from the European Society for Blood and Marrow Transplantation (EBMT)} 8 | \format{ 9 | A data frame, see \code{\link{data.frame}}. 10 | } 11 | \source{ 12 | We acknowledge the European Society for Blood and Marrow 13 | Transplantation (EBMT) for making available these data. Disclaimer: these 14 | data were simplified for the purpose of illustration of the analysis of 15 | competing risks and multi-state models and do not reflect any real life 16 | situation. No clinical conclusions should be drawn from these data. 17 | } 18 | \description{ 19 | A data frame of 8966 patients transplanted at the EBMT. The included 20 | variables are \describe{ \item{id}{Patient identification number} 21 | \item{time}{Time in months from transplantation to death or last follow-up} 22 | \item{status}{Survival status; 0 = censored; 1,...,6 = death due to the 23 | following causes: Relapse (1), GvHD (2), Bacterial infections (3), Viral 24 | infections (4), Fungal infections (5), Other causes (6)} \item{cod}{Cause of 25 | death as factor with levels "Alive", "Relapse", "GvHD", "Bacterial", 26 | "Viral", "Fungal", "Other"} \item{dissub}{Disease subclassification; factor 27 | with levels "AML", "ALL", "CML"} \item{match}{Donor-recipient gender match; 28 | factor with levels "No gender mismatch", "Gender mismatch"} 29 | \item{tcd}{T-cell depletion; factor with levels "No TCD", "TCD", "Unknown"} 30 | \item{year}{Year of transplantation; factor with levels "1985-1989", 31 | "1990-1994", "1995-1998"} \item{age}{Patient age at transplant; factor with 32 | levels "<=20", "20-40", ">40"} } 33 | } 34 | \references{ 35 | Fiocco M, Putter H, van Houwelingen JC (2005). Reduced rank 36 | proportional hazards model for competing risks. \emph{Biostatistics} 37 | \bold{6}, 465--478. 38 | } 39 | \keyword{datasets} 40 | -------------------------------------------------------------------------------- /man/EBMT-data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datasets.R 3 | \docType{data} 4 | \name{EBMT data} 5 | \alias{EBMT data} 6 | \alias{ebmt4} 7 | \title{Data from the European Society for Blood and Marrow Transplantation (EBMT)} 8 | \format{ 9 | A data frame, see \code{\link{data.frame}}. 10 | } 11 | \source{ 12 | We acknowledge the European Society for Blood and Marrow 13 | Transplantation (EBMT) for making available these data. Disclaimer: these 14 | data were simplified for the purpose of illustration of the analysis of 15 | competing risks and multi-state models and do not reflect any real life 16 | situation. No clinical conclusions should be drawn from these data. 17 | } 18 | \description{ 19 | A data frame of 2279 patients transplanted at the EBMT between 1985 and 20 | 1998. These data were used in Fiocco, Putter & van Houwelingen (2008), van 21 | Houwelingen & Putter (2008, 2012) and de Wreede, Fiocco & Putter (2011). The 22 | included variables are \describe{ \item{id}{Patient identification number} 23 | \item{rec}{Time in days from transplantation to recovery or last follow-up} 24 | \item{rec.s}{Recovery status; 1 = recovery, 0 = censored} \item{ae}{Time in 25 | days from transplantation to adverse event (AE) or last follow-up} 26 | \item{ae.s}{Adverse event status; 1 = adverse event, 0 = censored} 27 | \item{recae}{Time in days from transplantation to both recovery and AE or 28 | last follow-up} \item{recae.s}{Recovery and AE status; 1 = both recovery and 29 | AE, 0 = no recovery or no AE or censored} \item{rel}{Time in days from 30 | transplantation to relapse or last follow-up} \item{rel.s}{Relapse status; 1 31 | = relapse, 0 = censored} \item{srv}{Time in days from transplantation to 32 | death or last follow-up} \item{srv.s}{Relapse status; 1 = dead, 0 = 33 | censored} \item{year}{Year of transplantation; factor with levels 34 | "1985-1989", "1990-1994", "1995-1998"} \item{agecl}{Patient age at 35 | transplant; factor with levels "<=20", "20-40", ">40"} 36 | \item{proph}{Prophylaxis; factor with levels "no", "yes"} 37 | \item{match}{Donor-recipient gender match; factor with levels "no gender 38 | mismatch", "gender mismatch"} } 39 | } 40 | \references{ 41 | Fiocco M, Putter H, van Houwelingen HC (2008). Reduced-rank 42 | proportional hazards regression and simulation-based prediction for 43 | multi-state models. \emph{Statistics in Medicine} \bold{27}, 4340--4358. 44 | 45 | van Houwelingen HC, Putter H (2008). Dynamic predicting by landmarking as an 46 | alternative for multi-state modeling: an application to acute lymphoid 47 | leukemia data. \emph{Lifetime Data Anal} \bold{14}, 447--463. 48 | 49 | van Houwelingen HC, Putter H (2012). Dynamic Prediction in Clinical Survival 50 | Analaysis. Chapman & Hall/CRC Press, Boca Raton. 51 | 52 | de Wreede LC, Fiocco M, and Putter H (2011). mstate: An R Package for the 53 | Analysis of Competing Risks and Multi-State Models. \emph{Journal of 54 | Statistical Software}, Volume 38, Issue 7. 55 | } 56 | \keyword{datasets} 57 | -------------------------------------------------------------------------------- /man/EBMT-platelet-recovery-data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datasets.R 3 | \docType{data} 4 | \name{EBMT platelet recovery data} 5 | \alias{EBMT platelet recovery data} 6 | \alias{ebmt3} 7 | \title{Data from the European Society for Blood and Marrow Transplantation (EBMT)} 8 | \format{ 9 | A data frame, see \code{\link{data.frame}}. 10 | } 11 | \source{ 12 | We acknowledge the European Society for Blood and Marrow 13 | Transplantation (EBMT) for making available these data. Disclaimer: these 14 | data were simplified for the purpose of illustration of the analysis of 15 | competing risks and multi-state models and do not reflect any real life 16 | situation. No clinical conclusions should be drawn from these data. 17 | } 18 | \description{ 19 | A data frame of 2204 patients transplanted at the EBMT between 1995 and 20 | 1998. These data were used in Section 4 of the tutorial on competing risks 21 | and multi-state models (Putter, Fiocco & Geskus, 2007). The included 22 | variables are \describe{ \item{id}{Patient identification number} 23 | \item{prtime}{Time in days from transplantation to platelet recovery or last 24 | follow-up} \item{prstat}{Platelet recovery status; 1 = platelet recovery, 0 25 | = censored} \item{rfstime}{Time in days from transplantation to relapse or 26 | death or last follow-up (relapse-free survival time)} 27 | \item{rfsstat}{Relapse-free survival status; 1 = relapsed or dead, 0 = 28 | censored} \item{dissub}{Disease subclassification; factor with levels "AML", 29 | "ALL", "CML"} \item{age}{Patient age at transplant; factor with levels 30 | "<=20", "20-40", ">40"} \item{drmatch}{Donor-recipient gender match; factor 31 | with levels "No gender mismatch", "Gender mismatch"} \item{tcd}{T-cell 32 | depletion; factor with levels "No TCD", "TCD"} } 33 | } 34 | \references{ 35 | Putter H, Fiocco M, Geskus RB (2007). Tutorial in biostatistics: 36 | Competing risks and multi-state models. \emph{Statistics in Medicine} 37 | \bold{26}, 2389--2430. 38 | } 39 | \keyword{datasets} 40 | -------------------------------------------------------------------------------- /man/EBMT-year-of-relapse-data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datasets.R 3 | \docType{data} 4 | \name{EBMT year of relapse data} 5 | \alias{EBMT year of relapse data} 6 | \alias{ebmt1} 7 | \title{Data from the European Society for Blood and Marrow Transplantation (EBMT)} 8 | \format{ 9 | A data frame, see \code{\link{data.frame}}. 10 | } 11 | \source{ 12 | We acknowledge the European Society for Blood and Marrow 13 | Transplantation (EBMT) for making available these data. Disclaimer: these 14 | data were simplified for the purpose of illustration of the analysis of 15 | competing risks and multi-state models and do not reflect any real life 16 | situation. No clinical conclusions should be drawn from these data. 17 | } 18 | \description{ 19 | A data frame of 1977 patients transplanted for CML. The included variables 20 | are \describe{ \item{patid}{Patient identification number} \item{srv}{Time 21 | in days from transplantation to death or last follow-up} 22 | \item{srvstat}{Survival status; 1 = death; 0 = censored} \item{rel}{Time in 23 | days from transplantation to relapse or last follow-up} 24 | \item{relstat}{Relapse status; 1 = relapsed; 0 = censored} 25 | \item{yrel}{Calendar year of relapse; factor with levels "1993-1996"," 26 | 1997-1999", "2000-"} \item{age}{Patient age at transplant (years)} 27 | \item{score}{Gratwohl score; factor with levels "Low risk", "Medium risk", 28 | "High risk"} } 29 | } 30 | \keyword{datasets} 31 | -------------------------------------------------------------------------------- /man/ELOS.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ELOS.R 3 | \name{ELOS} 4 | \alias{ELOS} 5 | \title{Expected length of stay} 6 | \usage{ 7 | ELOS(pt, tau) 8 | } 9 | \arguments{ 10 | \item{pt}{An object of class \code{"probtrans"}} 11 | 12 | \item{tau}{The horizon until which ELOS is calculated; if missing, the 13 | maximum of the observed transition times is taken} 14 | } 15 | \value{ 16 | A K x K matrix (with K number of states), with the (g,h)'th element 17 | containing E_gh(s,tau). The starting time point s is inferred from \code{pt} 18 | (the smallest time point, should be equal to the \code{predt} value in the 19 | call to \code{\link{probtrans}}. The row- and column names of the matrix 20 | have been named "from1" until "fromK" and "in1" until "inK", respectively. 21 | } 22 | \description{ 23 | Given a \code{"probtrans"} object, ELOS calculates the (restricted) expected 24 | length of stay in each of the states of the multi-state model. 25 | } 26 | \details{ 27 | The object \code{pt} needs to be a \code{"probtrans"} object, obtained with 28 | forward prediction (the default, \code{direction}=\code{"forward"}, in the 29 | call to \code{\link{probtrans}}). The restriction to \code{tau} is there 30 | because, as in ordinary survival analysis, the probability of being in a 31 | state can be positive until infinity, resulting in infinite values. The 32 | (restricted, until tau) expected length of stay in state h, given in state g 33 | at time s, is given by the integral from s to tau of P_gh(s,t), see for 34 | instance Beyersmann and Putter (2014). 35 | } 36 | \examples{ 37 | 38 | # transition matrix for illness-death model 39 | tmat <- trans.illdeath() 40 | # data in wide format, for transition 1 this is dataset E1 of 41 | # Therneau & Grambsch (2000) 42 | tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), 43 | dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), 44 | x1=c(1,1,1,0,0,0),x2=c(6:1)) 45 | # data in long format using msprep 46 | tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"), 47 | data=tg,keep=c("x1","x2"),trans=tmat) 48 | # events 49 | events(tglong) 50 | table(tglong$status,tglong$to,tglong$from) 51 | # expanded covariates 52 | tglong <- expand.covs(tglong,c("x1","x2")) 53 | # Cox model with different covariate 54 | cx <- coxph(Surv(Tstart,Tstop,status)~x1.1+x2.2+strata(trans), 55 | data=tglong,method="breslow") 56 | summary(cx) 57 | # new data, to check whether results are the same for transition 1 as 58 | # those in appendix E.1 of Therneau & Grambsch (2000) 59 | newdata <- data.frame(trans=1:3,x1.1=c(0,0,0),x2.2=c(0,1,0),strata=1:3) 60 | HvH <- msfit(cx,newdata,trans=tmat) 61 | # probtrans 62 | pt <- probtrans(HvH,predt=0) 63 | # ELOS until last observed time point 64 | ELOS(pt) 65 | # Restricted ELOS until tau=10 66 | ELOS(pt, tau=10) 67 | 68 | } 69 | \author{ 70 | Hein Putter \email{H.Putter@lumc.nl} 71 | } 72 | \keyword{univar} 73 | -------------------------------------------------------------------------------- /man/LMAJ.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LMAJ.R 3 | \name{LMAJ} 4 | \alias{LMAJ} 5 | \title{Landmark Aalen-Johansen method} 6 | \usage{ 7 | LMAJ(msdata, s, from, method = c("aalen", "greenwood")) 8 | } 9 | \arguments{ 10 | \item{msdata}{An \code{"msdata"} object, as for instance prepared by 11 | \code{link{msprep}}} 12 | 13 | \item{s}{The prediction time point s from which transition probabilities are 14 | to be obtained} 15 | 16 | \item{from}{Either a single state or a set of states in the state space 17 | 1,...,S} 18 | 19 | \item{method}{The method for calculating variances, as in 20 | \code{\link{probtrans}}} 21 | } 22 | \value{ 23 | A data frame containing estimates and associated standard errors of 24 | the transition probabilities P(X(t)=k | X(s) in \code{from}) with \code{s} 25 | and \code{from} the arguments of the function. 26 | } 27 | \description{ 28 | This function implements the landmark Aalen-Johansen method of Putter & 29 | Spitoni (2016) for non-parametric estimation of transition probabilities in 30 | non-Markov models. 31 | } 32 | \examples{ 33 | 34 | data(prothr) 35 | tmat <- attr(prothr, "trans") 36 | pr0 <- subset(prothr, treat=="Placebo") 37 | attr(pr0, "trans") <- tmat 38 | pr1 <- subset(prothr, treat=="Prednisone") 39 | attr(pr1, "trans") <- tmat 40 | c0 <- coxph(Surv(Tstart, Tstop, status) ~ strata(trans), data=pr0) 41 | c1 <- coxph(Surv(Tstart, Tstop, status) ~ strata(trans), data=pr1) 42 | msf0 <- msfit(c0, trans=tmat) 43 | msf1 <- msfit(c1, trans=tmat) 44 | # Comparison as in Figure 2 of Titman (2015) 45 | # Aalen-Johansen 46 | pt0 <- probtrans(msf0, predt=1000)[[2]] 47 | pt1 <- probtrans(msf1, predt=1000)[[2]] 48 | par(mfrow=c(1,2)) 49 | plot(pt0$time, pt0$pstate1, type="s", lwd=2, xlim=c(1000,4000), ylim=c(0,0.61), 50 | xlab="Time since randomisation (days)", ylab="Probability") 51 | lines(pt1$time, pt1$pstate1, type="s", lwd=2, lty=3) 52 | legend("topright", c("Placebo", "Prednisone"), lwd=2, lty=1:2, bty="n") 53 | title(main="Aalen-Johansen") 54 | # Landmark Aalen-Johansen 55 | LMpt0 <- LMAJ(msdata=pr0, s=1000, from=2) 56 | LMpt1 <- LMAJ(msdata=pr1, s=1000, from=2) 57 | plot(LMpt0$time, LMpt0$pstate1, type="s", lwd=2, xlim=c(1000,4000), ylim=c(0,0.61), 58 | xlab="Time since randomisation (days)", ylab="Probability") 59 | lines(LMpt1$time, LMpt1$pstate1, type="s", lwd=2, lty=3) 60 | legend("topright", c("Placebo", "Prednisone"), lwd=2, lty=1:2, bty="n") 61 | title(main="Landmark Aalen-Johansen") 62 | 63 | } 64 | \references{ 65 | H. Putter and C. Spitoni (2016). Estimators of transition 66 | probabilities in non-Markov multi-state models. Submitted. 67 | } 68 | \author{ 69 | Hein Putter \email{H.Putter@lumc.nl} 70 | 71 | Edouard F. Bonneville \email{e.f.bonneville@lumc.nl} 72 | } 73 | \keyword{survival} 74 | -------------------------------------------------------------------------------- /man/Liver-cirrhosis-data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datasets.R 3 | \docType{data} 4 | \name{Liver cirrhosis data} 5 | \alias{Liver cirrhosis data} 6 | \alias{prothr} 7 | \title{Abnormal prothrombin levels in liver cirrhosis} 8 | \format{ 9 | A data frame, see \code{\link{data.frame}}. 10 | } 11 | \description{ 12 | A data frame of 488 liver cirrhosis patients from a randomized clinical 13 | trial concerning prednisone treatment in these patients. The dataset is in 14 | long format. The included variables are \describe{ \item{id}{Patient 15 | identification number} \item{from}{Starting state} \item{to}{Receiving 16 | state} \item{trans}{Transition number} \item{Tstart}{Starting time} 17 | \item{Tstop}{Transition time} \item{status}{Status variable; 1=transition, 18 | 0=censored} \item{treat}{Treatment; factor with levels "Placebo", 19 | "Prednisone"} } 20 | } 21 | \details{ 22 | This data was kindly provided by Per Kragh Andersen. It was introduced in 23 | Andersen, Borgan, Gill & Keiding (1993), Example 1.3.12, and used as 24 | illustration for computation of transition probabilities in multi-state 25 | models, see Sections IV.4 (Example IV.4.4) and VII.2 (Example VII.2.10). 26 | } 27 | \references{ 28 | Andersen PK, Borgan O, Gill RD, Keiding N (1993). 29 | \emph{Statistical Models Based on Counting Processes}. Springer, New York. 30 | } 31 | \keyword{datasets} 32 | -------------------------------------------------------------------------------- /man/aidssi.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datasets.R 3 | \docType{data} 4 | \name{aidssi} 5 | \alias{aidssi} 6 | \alias{aidssi2} 7 | \title{Data from the Amsterdam Cohort Studies on HIV infection and AIDS} 8 | \format{ 9 | aidssi \tabular{ll}{ patnr:\tab Patient identification number\cr 10 | time:\tab Time from HIV infection to first of SI appearance and AIDS, or 11 | last follow-up\cr status:\tab Event indicator; 0 = censored, 1 = AIDS, 2 = 12 | SI appearance\cr cause:\tab Failure cause; factor with levels "event-free", 13 | "AIDS", "SI"\cr ccr5:\tab CCR5 genotype; factor with levels "WW" (wild type 14 | allele on both chromosomes),\cr \tab "WM" (mutant allele on one 15 | chromosome)\cr } aidssi2 \tabular{ll}{ patnr:\tab Patient identification 16 | number\cr entry.time:\tab Time from HIV infection to cohort entry. Value is 17 | zero if HIV infection occurred while in follow-up.\cr aids.time:\tab Time 18 | from HIV infection to AIDS, or last follow-up if AIDS was not observed\cr 19 | aids.stat:\tab Event indicator with respect to AIDS, with values 0 20 | (censored) and 1 (AIDS)\cr si.time:\tab Time from HIV infection to SI 21 | switch, or last follow-up if SI switch was not observed\cr si.stat:\tab 22 | Event indicator with respect to SI switch, with values 0 (no switch) and 1 23 | (switch)\cr death.time:\tab Time from HIV infection to death, or last 24 | follow-up if death was not observed\cr death.stat:\tab Event indicator with 25 | respect to death; 0 = alive, 1 = dead\cr age.inf:\tab Age at HIV 26 | infection\cr ccr5:\tab CCR5 genotype; factor with levels "WW" (wild type 27 | allele on both chromosomes),\cr \tab "WM" (mutant allele on one 28 | chromosome)\cr } 29 | } 30 | \source{ 31 | Geskus RB (2000). On the inclusion of prevalent cases in HIV/AIDS 32 | natural history studies through a marker-based estimate of time since 33 | seroconversion. \emph{Statistics in Medicine} \bold{19}, 1753--1769. 34 | 35 | Geskus RB, Miedema FA, Goudsmit J, Reiss P, Schuitemaker H, Coutinho RA 36 | (2003). Prediction of residual time to AIDS and death based on markers and 37 | cofactors. \emph{Journal of AIDS} \bold{32}, 514--521. 38 | } 39 | \description{ 40 | These data sets give the times (in years) from HIV infection to AIDS, SI 41 | switch and death in 329 men who have sex with men (MSM). Data are from the 42 | period until combination anti-retroviral therapy became available (1996). 43 | For more background information on the cohort, ccr5 and SI, see Geskus 44 | \emph{et al.} (2000, 2003) 45 | } 46 | \details{ 47 | \code{aidssi} contains follow-up data until the first of AIDS and SI switch. 48 | It was used as example for the competing risks analyses in Putter, Fiocco, 49 | Geskus (2007) and in Geskus (2016). 50 | 51 | \code{aidssi2} extends the \code{aidssi} data set in three ways. First, it 52 | considers events after the initial one. Second, it includes the entry times 53 | of the individuals that entered the study after HIV infection. Third, age at 54 | HIV infection has been added as extra covariable. Numbers differ slightly 55 | from the \code{aidssi} data set. Some individuals were diagnosed with AIDS 56 | only when they died and others had their last follow-up at AIDS diagnosis. 57 | In order to prevent two transitions to happen at the same time, their time 58 | to AIDS was shortened by 0.25 years. This data set was used as example for 59 | the multi-state analyses in Geskus (2016). 60 | } 61 | \references{ 62 | Geskus, Ronald B. (2016). \emph{Data Analysis with Competing 63 | Risks and Intermediate States.} CRC Press, Boca Raton. 64 | 65 | Putter H, Fiocco M, Geskus RB (2007). Tutorial in biostatistics: Competing 66 | risks and multi-state models. \emph{Statistics in Medicine} \bold{26}, 67 | 2389--2430. 68 | } 69 | \keyword{datasets} 70 | -------------------------------------------------------------------------------- /man/bmt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datasets.R 3 | \name{bmt} 4 | \alias{bmt} 5 | \title{BMT data from Klein and Moeschberger} 6 | \format{ 7 | A data frame, see \code{\link{data.frame}}. 8 | } 9 | \description{ 10 | A data frame of 137 rows (patients) and 22 columns. The included variables 11 | are \describe{ \item{group}{ Disease group; 1 = ALL, 2 = AML Low Risk, 3 = 12 | AML High Risk } \item{t1}{ Time in days to death or last follow-up } 13 | \item{t2}{ Disease-free survival time in days (time to relapse, death or 14 | last follow-up) } \item{d1}{ Death indicator; 1 = dead, 0 = alive } 15 | \item{d2}{ Relapse indicator; 1 = relapsed, 0 = disease-free } \item{d3}{ 16 | Disease-free survival indicator; 1 = dead or relapsed, 0 = alive and 17 | disease-free) } \item{ta}{ Time in days to Acute Graft-versus-Host Disease 18 | (AGVHD) } \item{da}{ Acute GVHD indicator; 1 = Acute GVHD, 0 = No Acute GVHD 19 | } \item{tc}{ Time (days) to Chronic Graft-vrsus-Host Disease (CGVHD) } 20 | \item{dc}{ Chronic GVHD indicator; 1 = Chronic GVHD, 0 = No Chronic GVHD } 21 | \item{tp}{ Time (days) to platelet recovery } \item{dp}{ Platelet recovery 22 | indicator; 1 = platelets returned to normal, 0 = platelets never returned to 23 | normal } \item{z1}{ Patient age in years } \item{z2}{ Donor age in years } 24 | \item{z3}{ Patient sex; 1 = male, 0 = female } \item{z4}{ Donor sex; 1 = 25 | male, 0 = female } \item{z5}{ Patient CMV status; 1 = CMV positive, 0 = CMV 26 | negative } \item{z6}{ Donor CMV status; 1 = CMV positive, 0 = CMV negative } 27 | \item{z7}{ Waiting time to transplant in days } \item{z8}{ FAB; 1 = FAB 28 | grade 4 or 5 and AML, 0 = Otherwise } \item{z9}{ Hospital; 1 = The Ohio 29 | State University, 2 = Alferd , 3 = St. Vincent, 4 = Hahnemann } \item{z10}{ 30 | MTX used as a Graft-versus-Host prophylactic; 1 = yes, 0 = no } } 31 | } 32 | \references{ 33 | Klein and Moeschberger (1997). \emph{Survival Analysis 34 | Techniques for Censored and Truncated Data}, Springer, New York. 35 | } 36 | \keyword{datasets} 37 | -------------------------------------------------------------------------------- /man/cutLMms.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cutLMms.R 3 | \name{cutLMms} 4 | \alias{cutLMms} 5 | \title{Cut a multi-state data set at a landmark time point} 6 | \usage{ 7 | cutLMms(msdata, LM, cens) 8 | } 9 | \arguments{ 10 | \item{msdata}{An object of class \code{"msdata"}, such as output by 11 | \code{\link{msprep}}} 12 | 13 | \item{LM}{The landmark time point at which the cut is to be made} 14 | 15 | \item{cens}{The time point at which administrative censoring is to be 16 | applied; if missing, no administrative censoring will be applied} 17 | } 18 | \value{ 19 | An object of class \code{"msdata"} again, containing only follow-up 20 | data after LM. The data frame contains an extra column \code{Tentry} with 21 | the time of entry into the present state. 22 | } 23 | \description{ 24 | Given a dataset in long format, for instance generated by 25 | \code{\link{msprep}}, this function cuts a multi-state data frame (object of 26 | type "msdata") at a landmark time point LM. Administrative censoring can be 27 | applied at time \code{cens}, equal for all individuals. 28 | } 29 | \details{ 30 | The function has a similar purpose as the \code{cutLM} function in the 31 | \code{dynpred} package. Only follow-up after a landmark time point LM is 32 | considered, so all subjects who are no longer at risk are removed. Column 33 | \code{time} is updated based on the new Tstart and Tstop. 34 | } 35 | \examples{ 36 | 37 | tmat <- trans.illdeath(names=c("Tx","PR","RelDeath")) 38 | data(ebmt3) # data from Section 4 of Putter, Fiocco & Geskus (2007) 39 | msebmt <- msprep(time=c(NA,"prtime","rfstime"),status=c(NA,"prstat","rfsstat"), 40 | data=ebmt3,trans=tmat) 41 | # Cut at 5 years 42 | cutLMms(msebmt, LM=1826) 43 | events(cutLMms(msebmt, LM=1826)) 44 | 45 | } 46 | \references{ 47 | L. C. de Wreede, M. Fiocco, and H. Putter (2011). mstate: An R 48 | Package for the Analysis of Competing Risks and Multi-State Models. Journal 49 | of Statistical Software 38: 7. 50 | } 51 | \author{ 52 | Hein Putter \email{H.Putter@lumc.nl} 53 | } 54 | \keyword{univar} 55 | -------------------------------------------------------------------------------- /man/etm2msdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/etm2msdata.R 3 | \name{etm2msdata} 4 | \alias{etm2msdata} 5 | \alias{tra2trans} 6 | \title{Converts between etm and msdata format} 7 | \usage{ 8 | etm2msdata(etmdata, id, tra, covs) 9 | } 10 | \arguments{ 11 | \item{etmdata}{Multi-state data in \code{etm} format} 12 | 13 | \item{id}{Column name identifying the subject id} 14 | 15 | \item{tra}{Transition matrix in \code{etm} format} 16 | 17 | \item{covs}{Vector of column names containing covariates to be included} 18 | } 19 | \description{ 20 | Converts multi-state data back and forth between etm and msdata formats. 21 | Covariates have to be dealt with separately. 22 | } 23 | \details{ 24 | \code{msdata2etm} will convert from \code{msdata} format to \code{etm} 25 | format; \code{etm2msdata} will convert from \code{etm} format to 26 | \code{msdata} format. Both \code{msdata2etm} and \code{etm2msdata} work with 27 | basic time-fixed covariates. Time-dependent covariates are not supported. 28 | The function \code{msdata2etm} will work for transition-specific covariates, 29 | but the result does not really make much sense when used in etm. 30 | } 31 | \examples{ 32 | 33 | # Transition matrix for illness-death model 34 | tmat <- trans.illdeath() 35 | # Data in wide format, for transition 1 this is dataset E1 of 36 | # Therneau & Grambsch (T&G) 37 | tg <- data.frame(id=1:6,illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), 38 | dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), 39 | x1=c(1,1,1,0,0,0),x2=c(6:1)) 40 | # Data in long format using msprep 41 | tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"), 42 | data=tg,keep=c("x1","x2"),trans=tmat, id="id") 43 | # Same thing in etm format 44 | tra <- trans2tra(tmat) 45 | tgetm <- msdata2etm(tglong, id="id") 46 | tgetm <- msdata2etm(tglong, id="id", covs=c("x1", "x2")) # with covariates 47 | # And back 48 | etm2msdata(tgetm, id="id", tra=tra) 49 | etm2msdata(tgetm, id="id", tra=tra, covs=c("x1", "x2")) # with covariates 50 | } 51 | \author{ 52 | Hein Putter \email{H.Putter@lumc.nl} 53 | } 54 | \keyword{datagen} 55 | -------------------------------------------------------------------------------- /man/events.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/events.R 3 | \name{events} 4 | \alias{events} 5 | \title{Count number of observed transitions} 6 | \usage{ 7 | events(msdata) 8 | } 9 | \arguments{ 10 | \item{msdata}{An object of class \code{"msdata"}, such as output by 11 | \code{\link{msprep}}} 12 | } 13 | \value{ 14 | A list containing two tables, the first, called \code{Frequencies}, 15 | with the number of observed transitions in the multi-state model occurring 16 | in \code{msdata}, the second, called \code{Proportions}, with the 17 | corresponding proportions. 18 | } 19 | \description{ 20 | Given a dataset in long format, for instance generated by 21 | \code{\link{msprep}}, and a transition matrix for the multi-state model, 22 | this function counts the number of observed transitions in the multi-state 23 | model and gives their percentages. 24 | } 25 | \details{ 26 | Although \code{msdata} does not need to be the result of a call to 27 | \code{\link{msprep}}, it does need to be an object of class \code{"msdata"}, 28 | which is essentially a data frame in long format, with one row for each 29 | transition for which the subject is at risk. The columns \code{from}, 30 | \code{to}, and \code{status} need to be present, with appropriate meaning, 31 | see \code{\link{msprep}}. The \code{msdata} argument needs to have a 32 | \code{"trans"} attributes, which holds the transition matrix of the 33 | multi-state model. 34 | } 35 | \examples{ 36 | 37 | tmat <- trans.illdeath(names=c("Tx","PR","RelDeath")) 38 | data(ebmt3) # data from Section 4 of Putter, Fiocco & Geskus (2007) 39 | msebmt <- msprep(time=c(NA,"prtime","rfstime"),status=c(NA,"prstat","rfsstat"), 40 | data=ebmt3,trans=tmat) 41 | events(msebmt) # see Fig 13 of Putter, Fiocco & Geskus (2007) 42 | 43 | } 44 | \author{ 45 | Hein Putter \email{H.Putter@lumc.nl} 46 | } 47 | \keyword{univar} 48 | -------------------------------------------------------------------------------- /man/expand.covs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/expand.covs.R 3 | \name{expand.covs} 4 | \alias{expand.covs} 5 | \alias{expand.covs.default} 6 | \title{Expand covariates in competing risks dataset in stacked format} 7 | \usage{ 8 | expand.covs(data, ...) 9 | } 10 | \arguments{ 11 | \item{data}{An object of class \code{"msdata"}, such as output by 12 | \code{\link{msprep}}} 13 | 14 | \item{...}{Further arguments to be passed to or from other methods. They 15 | are ignored in this function.} 16 | } 17 | \value{ 18 | An data frame object of the same class as the data argument, 19 | containing the design matrix for the type-specific covariates, either on its 20 | own (\code{append}=\code{FALSE}) or appended to the data 21 | (\code{append}=\code{TRUE}). 22 | } 23 | \description{ 24 | Given a competing risks dataset in stacked format, and one or more 25 | covariates, this function adds type-specific covariates to the dataset. The 26 | original dataset with the type-specific covariates appended is returned. 27 | } 28 | \details{ 29 | Type-specific covariates can be used to analyse separate effects on all 30 | event types in a single analysis based on a stacked data set (Putter, Fiocco 31 | & Geskus (2007) and Geskus (2016)). It is only unambiguously defined for 32 | numeric covariates or for explicit codings. Rows that contain the data for 33 | that specific event type have the value copied from the original covariate 34 | in case it is numeric. In all other rows it has the value zero. If the 35 | covariate is a factor, it will be expanded on the design matrix given by 36 | \code{\link[stats:model.matrix]{model.matrix}}. For standard "treatment 37 | contrasts" this means that dummy variables are created. If the covariate is 38 | a factor, the column name combines the name of the covariate with the 39 | specific event type. If \code{longnames}=\code{TRUE}, both parts are 40 | intersected by the specific labels in the coding. Missing values in the 41 | basic covariates are allowed and result in missing values in the expanded 42 | covariates. 43 | } 44 | \examples{ 45 | 46 | # small data set in stacked format 47 | tg <- data.frame(time=c(5,5,1,1,9,9),status=c(1,0,2,2,0,1),failcode=rep(c("I","II"),3), 48 | x1=c(1,1,2,2,2,2),x2=c(3,3,2,2,1,1)) 49 | tg$x1 <- factor(tg$x1,labels=c("male","female")) 50 | # expanded covariates 51 | expand.covs(tg,covs=c("x1","x2")) 52 | expand.covs(tg,covs=c("x1","x2"),longnames=TRUE) 53 | expand.covs(tg,covs=c("x1","x2"),append=FALSE) 54 | 55 | } 56 | \references{ 57 | Putter H, Fiocco M, Geskus RB (2007). Tutorial in biostatistics: 58 | Competing risks and multi-state models. \emph{Statistics in Medicine} 59 | \bold{26}, 2389--2430. 60 | 61 | Geskus, Ronald B. (2016). \emph{Data Analysis with Competing Risks and 62 | Intermediate States.} CRC Press, Boca Raton. 63 | } 64 | \seealso{ 65 | \code{\link{expand.covs.msdata}}. 66 | } 67 | \author{ 68 | Ronald Geskus and Hein Putter \email{H.Putter@lumc.nl} 69 | } 70 | \keyword{datagen} 71 | -------------------------------------------------------------------------------- /man/expand.covs.msdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/expand.covs.R 3 | \name{expand.covs.msdata} 4 | \alias{expand.covs.msdata} 5 | \title{Expand covariates in multi-state dataset in long format} 6 | \usage{ 7 | \method{expand.covs}{msdata}(data, covs, append = TRUE, longnames = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{data}{An object of class \code{"msdata"}, such as output by 11 | \code{\link{msprep}}} 12 | 13 | \item{covs}{A character vector containing the names of the covariates in 14 | \code{data} to be expanded} 15 | 16 | \item{append}{Logical value indicating whether or not the design matrix for 17 | the expanded covariates should be appended to the data (default=\code{TRUE})} 18 | 19 | \item{longnames}{Logical value indicating whether or not the labels are to 20 | be used for the names of the expanded covariates that are categorical 21 | (default=\code{TRUE}); in case of \code{FALSE} numbers from 1 up to the 22 | number of contrasts are used} 23 | 24 | \item{\dots}{Further arguments to be passed to or from other methods. They 25 | are ignored in this function.} 26 | } 27 | \value{ 28 | An object of class 'msdata', containing the design matrix for the 29 | transition- specific covariates, either on its own 30 | (\code{append}=\code{FALSE}) or appended to the data 31 | (\code{append}=\code{TRUE}). 32 | } 33 | \description{ 34 | Given a multi-state dataset in long format, and one or more covariates, this 35 | function adds transition-specific covariates, expanding the original 36 | covariate(s), to the dataset. The original dataset with the 37 | transition-specific covariates appended is returned. 38 | } 39 | \details{ 40 | For a given basic covariate \code{Z}, the transition-specific covariate for 41 | transition \code{s} is called \code{Z.s}. The concept of transition-specific 42 | covariates in the context of multi-state models was introduced by Andersen, 43 | Hansen & Keiding (1991), see also Putter, Fiocco & Geskus (2007). It is only 44 | unambiguously defined for numeric covariates or for explicit codings. Then 45 | it will take the value 0 for all rows in the long format dataframe for which 46 | \code{trans} does not equal \code{s}. For the rows for which \code{trans} 47 | equals \code{s}, the original value of \code{Z} is copied. In 48 | \code{expand.covs}, when a given covariate is a factor, it will be expanded 49 | on the design matrix given by 50 | \code{\link[stats:model.matrix]{model.matrix}}. Missing values in the basic 51 | covariates are allowed and result in missing values in the expanded 52 | covariates. 53 | } 54 | \examples{ 55 | 56 | # transition matrix for illness-death model 57 | tmat <- trans.illdeath() 58 | # small data set in wide format 59 | tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), 60 | dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), 61 | x1=c(1,1,1,2,2,2),x2=c(6:1)) 62 | tg$x1 <- factor(tg$x1,labels=c("male","female")) 63 | # data in long format using msprep 64 | tglong <- msprep(time=c(NA,"illt","dt"), 65 | status=c(NA,"ills","ds"),data=tg, 66 | keep=c("x1","x2"),trans=tmat) 67 | # expanded covariates 68 | expand.covs(tglong,c("x1","x2"),append=FALSE) 69 | expand.covs(tglong,"x1") 70 | expand.covs(tglong,"x1",longnames=FALSE) 71 | 72 | } 73 | \references{ 74 | Andersen PK, Hansen LS, Keiding N (1991). Non- and 75 | semi-parametric estimation of transition probabilities from censored 76 | observation of a non-homogeneous Markov process. \emph{Scandinavian Journal 77 | of Statistics} \bold{18}, 153--167. 78 | 79 | Putter H, Fiocco M, Geskus RB (2007). Tutorial in biostatistics: Competing 80 | risks and multi-state models. \emph{Statistics in Medicine} \bold{26}, 81 | 2389--2430. 82 | } 83 | \author{ 84 | Hein Putter \email{H.Putter@lumc.nl} 85 | } 86 | \keyword{datagen} 87 | -------------------------------------------------------------------------------- /man/haz_function.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/relsurv.haz_function.R 3 | \name{haz_function} 4 | \alias{haz_function} 5 | \title{Helper function that calculates excess and population hazards for a given transition} 6 | \usage{ 7 | haz_function( 8 | formula = formula(data), 9 | data, 10 | ratetable = relsurv::slopop, 11 | na.action, 12 | add.times, 13 | rmap, 14 | include.all.times = FALSE 15 | ) 16 | } 17 | \arguments{ 18 | \item{formula}{A non-parametric Surv-based formula, e.g. Surv(times, status)~1} 19 | 20 | \item{data}{A subset of the msprep object (dataset) where there's 21 | only data for the chosen transition} 22 | 23 | \item{ratetable}{A table of event rates, organized as a ratetable object, such as slopop} 24 | 25 | \item{na.action}{A missing-data filter function, applied to the model.frame, after any subset argument has been used. Default is options()$na.action} 26 | 27 | \item{add.times}{Additional times at which the hazards should be evaluated} 28 | 29 | \item{rmap}{An optional list to be used if the variables are not organized and named in the same way as in the ratetable object} 30 | 31 | \item{include.all.times}{Should hazards be evaluated at all times in seq(minimum time, maximum time, by=1). Default is FALSE} 32 | } 33 | \value{ 34 | A list containing the needed hazards. 35 | } 36 | \description{ 37 | A function that calculates the excess and population hazards 38 | for a given transition. Code is based on function rs.surv from 39 | the relsurv package. 40 | } 41 | \seealso{ 42 | \code{\link{msfit.relsurv}} 43 | } 44 | \author{ 45 | Damjan Manevski \email{damjan.manevski@mf.uni-lj.si} 46 | } 47 | -------------------------------------------------------------------------------- /man/modify_transMat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/relsurv.transMat.R 3 | \name{modify_transMat} 4 | \alias{modify_transMat} 5 | \title{Upgrade the transMat object for the multi-state/relsurv setting.} 6 | \usage{ 7 | modify_transMat(trans, split.transitions) 8 | } 9 | \arguments{ 10 | \item{trans}{The original transition matrix (usually generated using function 11 | transMat from mstate). Also often present in the msfit object.} 12 | 13 | \item{split.transitions}{The transitions that should be split.} 14 | } 15 | \value{ 16 | An upgraded transition matrix that contains the population and 17 | excess transitions. 18 | } 19 | \description{ 20 | A function that upgrades the transMat object so that the population 21 | and excess-related transitions are included in the transition matrix. 22 | } 23 | \examples{ 24 | 25 | # transition matrix for illness-death model 26 | trans <- transMat(list(c(2,3),c(4), c(), c()), 27 | names = c("Alive", "Relapse","Non-relapse mortality", "Death after relapse")) 28 | split.transitions <- c(2,3) 29 | modify_transMat(trans, split.transitions) 30 | 31 | } 32 | \seealso{ 33 | \code{\link{transMat}} 34 | } 35 | \author{ 36 | Damjan Manevski \email{damjan.manevski@mf.uni-lj.si} 37 | } 38 | -------------------------------------------------------------------------------- /man/msboot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/msboot.R 3 | \name{msboot} 4 | \alias{msboot} 5 | \title{Bootstrap function in multi-state models} 6 | \usage{ 7 | msboot(theta, data, B = 5, id = "id", verbose = 0, ...) 8 | } 9 | \arguments{ 10 | \item{theta}{A function of \code{data} and perhaps other arguments, 11 | returning the value of the statistic to be bootstrapped; the output of theta 12 | should be a scalar or numeric vector} 13 | 14 | \item{data}{An object of class 'msdata', such as output from 15 | \code{\link{msprep}}} 16 | 17 | \item{B}{The number of bootstrap replications; the default is taken to be 18 | quite small (5) since bootstrapping can be time-consuming} 19 | 20 | \item{id}{Character string indicating which column identifies the subjects 21 | to be resampled} 22 | 23 | \item{verbose}{The level of output; default 0 = no output, 1 = print the 24 | replication} 25 | 26 | \item{...}{Any further arguments to the function \code{theta}} 27 | } 28 | \value{ 29 | Matrix of dimension (length of output of theta) x B, with b'th 30 | column being the value of theta for the b'th bootstrap dataset 31 | } 32 | \description{ 33 | A generic nonparametric bootstrapping function for multi-state models. 34 | } 35 | \details{ 36 | The function \code{msboot} samples randomly with replacement subjects from 37 | the original dataset \code{data}. The individuals are identified with 38 | \code{id}, and bootstrap datasets are produced by concatenating all selected 39 | rows. 40 | } 41 | \examples{ 42 | 43 | tmat <- trans.illdeath() 44 | data(ebmt1) 45 | covs <- c("score","yrel") 46 | msebmt <- msprep(time=c(NA,"rel","srv"),status=c(NA,"relstat","srvstat"), 47 | data=ebmt1,id="patid",keep=covs,trans=tmat) 48 | # define a function (this one returns vector of regression coef's) 49 | regcoefvec <- function(data) { 50 | cx <- coxph(Surv(Tstart,Tstop,status)~score+strata(trans), 51 | data=data,method="breslow") 52 | return(coef(cx)) 53 | } 54 | regcoefvec(msebmt) 55 | set.seed(1234) 56 | msboot(theta=regcoefvec,data=msebmt,id="patid") 57 | 58 | } 59 | \references{ 60 | Fiocco M, Putter H, van Houwelingen HC (2008). Reduced-rank 61 | proportional hazards regression and simulation-based prediction for 62 | multi-state models. \emph{Statistics in Medicine} \bold{27}, 4340--4358. 63 | } 64 | \author{ 65 | Marta Fiocco, Hein Putter 66 | } 67 | \keyword{datagen} 68 | -------------------------------------------------------------------------------- /man/msboot.relsurv.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/relsurv.msboot.relsurv.R 3 | \name{msboot.relsurv} 4 | \alias{msboot.relsurv} 5 | \title{Bootstrap function for upgraded multi-state models using relsurv} 6 | \usage{ 7 | msboot.relsurv( 8 | theta, 9 | data, 10 | B = 10, 11 | id = "id", 12 | verbose = 0, 13 | transmat, 14 | all_times, 15 | split.transitions, 16 | rmap, 17 | time.format, 18 | boot_orig_msfit, 19 | ratetable = relsurv::slopop, 20 | add.times, 21 | ... 22 | ) 23 | } 24 | \arguments{ 25 | \item{theta}{A function of data and perhaps other arguments, returning the value of the statistic to be bootstrapped} 26 | 27 | \item{data}{An object of class 'msdata', such as output from msprep} 28 | 29 | \item{B}{The number of bootstrap replications; the default is B=10} 30 | 31 | \item{id}{Character string indicating which column identifies the subjects to be resampled} 32 | 33 | \item{verbose}{The level of output; default 0 = no output, 1 = print the replication} 34 | 35 | \item{transmat}{The transition matrix of class transMat} 36 | 37 | \item{all_times}{All times at which the hazards have to be evaluated} 38 | 39 | \item{split.transitions}{An integer vector containing the numbered transitions that should be split. Use same numbering as in the given transition matrix} 40 | 41 | \item{rmap}{An optional list to be used if the variables in the dataset are not organized (and named) in the same way as in the ratetable object} 42 | 43 | \item{time.format}{Define the time format which is used in the dataset Possible options: c('days', 'years', 'months'). Default is 'days'} 44 | 45 | \item{boot_orig_msfit}{Logical, if true, do the bootstrap for the basic msfit model} 46 | 47 | \item{ratetable}{The population mortality table. A table of event rates, organized as a ratetable object, see for example relsurv::slopop. Default is slopop} 48 | 49 | \item{add.times}{Additional times at which hazards should be evaluated} 50 | 51 | \item{...}{Any further arguments to the function theta} 52 | } 53 | \value{ 54 | A list of size B containing the results for every bootstrap replication. 55 | } 56 | \description{ 57 | A helper nonparametric bootstrapping function for variances 58 | in extended multi-state models using relative survival. 59 | This implementation is written based on function mstate:::msboot. 60 | } 61 | \seealso{ 62 | \code{\link{msboot}} 63 | } 64 | \author{ 65 | Damjan Manevski \email{damjan.manevski@mf.uni-lj.si}, Marta Fiocco, Hein Putter \email{H.Putter@lumc.nl} 66 | } 67 | -------------------------------------------------------------------------------- /man/msboot.relsurv.boot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/relsurv.msboot.relsurv.boot.R 3 | \name{msboot.relsurv.boot} 4 | \alias{msboot.relsurv.boot} 5 | \title{Default theta function used for msboot.relsurv} 6 | \usage{ 7 | msboot.relsurv.boot( 8 | data, 9 | transmat, 10 | all_times, 11 | split.transitions, 12 | rmap, 13 | time.format, 14 | boot_orig_msfit = FALSE, 15 | ratetable = relsurv::slopop, 16 | add.times 17 | ) 18 | } 19 | \arguments{ 20 | \item{data}{An object of class 'msdata' containing a bootstrapped sample} 21 | 22 | \item{transmat}{The transition matrix of class transMat} 23 | 24 | \item{all_times}{All times at which the hazards have to be evaluated} 25 | 26 | \item{split.transitions}{An integer vector containing the numbered transitions that should be split. Use same numbering as in the given transition matrix} 27 | 28 | \item{rmap}{An optional list to be used if the variables in the dataset are not organized (and named) in the same way as in the ratetable object} 29 | 30 | \item{time.format}{Define the time format which is used in the dataset Possible options: c('days', 'years', 'months'). Default is 'days'} 31 | 32 | \item{boot_orig_msfit}{Logical, if true, do the bootstrap for the basic msfit model} 33 | 34 | \item{ratetable}{The population mortality table. A table of event rates, organized as a ratetable object, see for example relsurv::slopop. Default is slopop} 35 | 36 | \item{add.times}{Additional times at which hazards should be evaluated} 37 | } 38 | \value{ 39 | A list of calculated values for the given bootstrap sample. 40 | } 41 | \description{ 42 | Helper function used for calling inside msboot.relsurv 43 | (used for every bootstrap dataset). 44 | This function is used for calculating split hazards 45 | and evaluating them at all needed times. 46 | } 47 | \seealso{ 48 | \code{\link{msboot.relsurv}} 49 | } 50 | \author{ 51 | Damjan Manevski \email{damjan.manevski@mf.uni-lj.si} 52 | } 53 | -------------------------------------------------------------------------------- /man/msdata2etm.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/etm2msdata.R 3 | \name{msdata2etm} 4 | \alias{msdata2etm} 5 | \title{msdata to etm format} 6 | \usage{ 7 | msdata2etm(msdata, id, covs) 8 | } 9 | \arguments{ 10 | \item{msdata}{Multi-state data in \code{msdata} format, as used in 11 | \code{mstate}} 12 | 13 | \item{id}{Column name identifying the subject id} 14 | 15 | \item{covs}{Vector of column names containing covariates to be included} 16 | } 17 | \description{ 18 | msdata to etm format 19 | } 20 | -------------------------------------------------------------------------------- /man/msfit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/msfit.R 3 | \name{msfit} 4 | \alias{msfit} 5 | \title{Compute subject-specific transition hazards with (co-)variances} 6 | \usage{ 7 | msfit( 8 | object, 9 | newdata, 10 | variance = TRUE, 11 | vartype = c("aalen", "greenwood"), 12 | trans 13 | ) 14 | } 15 | \arguments{ 16 | \item{object}{A \code{\link[survival:coxph]{coxph}} object describing the 17 | fit of the multi-state model} 18 | 19 | \item{newdata}{A data frame with the same variable names as those that 20 | appear in the \code{coxph} formula. Its use is somewhat different from 21 | \code{\link[survival:survfit]{survfit}}. See Details. The argument 22 | \code{newdata} may be omitted only if the right hand side of the formula in 23 | the \code{coxph} object is \code{~strata(trans)}} 24 | 25 | \item{variance}{A logical value indicating whether the (co-)variances of the 26 | subject-specific transition hazards should be computed. Default is 27 | \code{TRUE}} 28 | 29 | \item{vartype}{A character string specifying the type of variances to be 30 | computed (so only needed if \code{variance}=\code{TRUE}). Possible values 31 | are \code{"aalen"} or \code{"greenwood"}} 32 | 33 | \item{trans}{Transition matrix describing the states and transitions in the 34 | multi-state model. See \code{trans} in \code{\link{msprep}} for more 35 | detailed information} 36 | } 37 | \value{ 38 | An object of class \code{"msfit"}, which is a list containing 39 | \item{Haz }{A data frame with \code{time}, \code{Haz}, \code{trans}, 40 | containing the estimated subject-specific hazards for each of the 41 | transitions in the multi-state model} \item{varHaz }{A data frame with 42 | \code{time}, \code{Haz}, \code{trans1}, \code{trans2} containing the 43 | variances (\code{trans1}=\code{trans2}) and covariances 44 | (\code{trans1}<\code{trans2}) of the estimated hazards. This element is only 45 | returned when \code{variance}=\code{TRUE}} \item{trans}{The transition 46 | matrix used} 47 | } 48 | \description{ 49 | This function computes subject-specific or overall cumulative transition 50 | hazards for each of the possible transitions in the multi-state model. If 51 | requested, also the variances and covariances of the estimated cumulative 52 | transition hazards are calculated. 53 | } 54 | \details{ 55 | The data frame needs to have one row for each transition in the multi-state 56 | model. An additional column \code{strata} (numeric) is needed to describe 57 | for each transition to which stratum it belongs. The name has to be 58 | \code{strata}, even if in the original \code{coxph} call another variable 59 | was used. For details refer to de Wreede, Fiocco & Putter (2010). So far, 60 | the results have been checked only for the \code{"breslow"} method of 61 | dealing with ties in \code{\link[survival:coxph]{coxph}}, so this is 62 | recommended. 63 | } 64 | \examples{ 65 | 66 | # transition matrix for illness-death model 67 | tmat <- trans.illdeath() 68 | # data in wide format, for transition 1 this is dataset E1 of 69 | # Therneau & Grambsch (2000) 70 | tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), 71 | dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), 72 | x1=c(1,1,1,0,0,0),x2=c(6:1)) 73 | # data in long format using msprep 74 | tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"), 75 | data=tg,keep=c("x1","x2"),trans=tmat) 76 | # events 77 | events(tglong) 78 | table(tglong$status,tglong$to,tglong$from) 79 | # expanded covariates 80 | tglong <- expand.covs(tglong,c("x1","x2")) 81 | # Cox model with different covariate 82 | cx <- coxph(Surv(Tstart,Tstop,status)~x1.1+x2.2+strata(trans), 83 | data=tglong,method="breslow") 84 | summary(cx) 85 | # new data, to check whether results are the same for transition 1 as 86 | # those in appendix E.1 of Therneau & Grambsch (2000) 87 | newdata <- data.frame(trans=1:3,x1.1=c(0,0,0),x2.2=c(0,1,0),strata=1:3) 88 | msfit(cx,newdata,trans=tmat) 89 | 90 | } 91 | \references{ 92 | Putter H, Fiocco M, Geskus RB (2007). Tutorial in biostatistics: 93 | Competing risks and multi-state models. \emph{Statistics in Medicine} 94 | \bold{26}, 2389--2430. 95 | 96 | Therneau TM, Grambsch PM (2000). \emph{Modeling Survival Data: Extending the 97 | Cox Model}. Springer, New York. 98 | 99 | de Wreede LC, Fiocco M, and Putter H (2010). The mstate package for 100 | estimation and prediction in non- and semi-parametric multi-state and 101 | competing risks models. \emph{Computer Methods and Programs in Biomedicine} 102 | \bold{99}, 261--274. 103 | 104 | de Wreede LC, Fiocco M, and Putter H (2011). mstate: An R Package for the 105 | Analysis of Competing Risks and Multi-State Models. \emph{Journal of 106 | Statistical Software}, Volume 38, Issue 7. 107 | } 108 | \seealso{ 109 | \code{\link{plot.msfit}} 110 | } 111 | \author{ 112 | Hein Putter \email{H.Putter@lumc.nl} 113 | } 114 | \keyword{survival} 115 | -------------------------------------------------------------------------------- /man/mstate-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datasets.R 3 | \docType{package} 4 | \name{mstate-package} 5 | \alias{mstate-package} 6 | \alias{mstate} 7 | \title{Data preparation, estimation and prediction in multi-state models} 8 | \description{ 9 | Functions for data preparation, descriptives, (hazard) estimation and 10 | prediction (Aalen-Johansen) in competing risks and multi-state models. 11 | } 12 | \details{ 13 | \tabular{ll}{ Package: \tab mstate\cr Type: \tab Package\cr Version: \tab 14 | 0.2.10\cr Date: \tab 2016-12-03\cr License: \tab GPL 2.0\cr } 15 | } 16 | \references{ 17 | Putter H, Fiocco M, Geskus RB (2007). Tutorial in biostatistics: 18 | Competing risks and multi-state models. \emph{Statistics in Medicine} 19 | \bold{26}, 2389--2430. 20 | 21 | de Wreede LC, Fiocco M, and Putter H (2010). The mstate package for 22 | estimation and prediction in non- and semi-parametric multi-state and 23 | competing risks models. \emph{Computer Methods and Programs in Biomedicine} 24 | \bold{99}, 261--274. 25 | 26 | de Wreede LC, Fiocco M, and Putter H (2011). mstate: An R Package for the 27 | Analysis of Competing Risks and Multi-State Models. \emph{Journal of 28 | Statistical Software}, Volume 38, Issue 7. 29 | } 30 | \author{ 31 | Liesbeth de Wreede, Marta Fiocco, Hein Putter. Maintainer: Hein 32 | Putter 33 | } 34 | \keyword{package} 35 | -------------------------------------------------------------------------------- /man/paths.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/paths.R 3 | \name{paths} 4 | \alias{paths} 5 | \title{Find all possible trajectories through a given multi-state model} 6 | \usage{ 7 | paths(trans, start = 1) 8 | } 9 | \arguments{ 10 | \item{trans}{The transition matrix describing the multi-state model, see 11 | \code{\link{msprep}}} 12 | 13 | \item{start}{The starting state for the trajectories} 14 | } 15 | \value{ 16 | A matrix, each row of which specifies a possible path through the 17 | multi-state model. 18 | } 19 | \description{ 20 | For a given multi-state model, specified through a transition matrix, 21 | \code{paths} recursively finds all the possible trajectories or paths 22 | through that multi-state starting from a specified state. DO NOT USE for 23 | reversible or cyclic multi-state models. 24 | } 25 | \details{ 26 | The function is recursive. It starts in \code{start}, looks at what states 27 | can be visited from \code{start}, and appends the results of the next call 28 | to the current value (matrix). If the transition matrix contains loops, the 29 | function will find infinitely many paths, so do not use \code{paths} for 30 | reversible or cyclic multi-state models. A warning is not yet incorporated! 31 | } 32 | \examples{ 33 | 34 | tmat <- matrix(NA,5,5) 35 | tmat[1,2:3] <- 1:2 36 | tmat[1,5] <- 3 37 | tmat[2,4:5] <- 4:5 38 | tmat[3,4:5] <- 6:7 39 | tmat[4,5] <- 8 40 | paths(tmat) 41 | paths(tmat, start=3) 42 | 43 | } 44 | \author{ 45 | Hein Putter 46 | } 47 | \keyword{array} 48 | -------------------------------------------------------------------------------- /man/plot.Cuminc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.Cuminc.R 3 | \name{plot.Cuminc} 4 | \alias{plot.Cuminc} 5 | \title{Plot method for Cuminc objects} 6 | \usage{ 7 | \method{plot}{Cuminc}( 8 | x, 9 | use.ggplot = FALSE, 10 | xlab = "Time", 11 | ylab = "Probability", 12 | xlim, 13 | ylim, 14 | lty, 15 | legend, 16 | cols, 17 | conf.type = c("log", "plain", "none"), 18 | conf.int = 0.95, 19 | legend.pos = "right", 20 | facet = FALSE, 21 | ... 22 | ) 23 | } 24 | \arguments{ 25 | \item{x}{Object of class \code{"Cuminc"} to be printed or plotted} 26 | 27 | \item{use.ggplot}{Default FALSE, set TRUE for ggplot version of plot} 28 | 29 | \item{xlab}{A title for the x-axis; default is \code{"Time"}} 30 | 31 | \item{ylab}{A title for the y-axis; default is \code{"Probability"}} 32 | 33 | \item{xlim}{The x limits of the plot(s), default is range of time} 34 | 35 | \item{ylim}{The y limits of the plot(s); if ylim is specified for 36 | type="separate", then all plots use the same ylim for y limits} 37 | 38 | \item{lty}{The line type, see \code{\link{par}}; default is 1} 39 | 40 | \item{legend}{Character vector corresponding to number of absorbing states. 41 | In case of a grouped \code{"Cuminc"} object, with facet = FALSE the 42 | length of the vector is number absorbing states * group levels. 43 | Only relevant when use.ggplot = TRUE} 44 | 45 | \item{cols}{Vector (numeric or character) specifying colours of the lines} 46 | 47 | \item{conf.type}{Type of confidence interval - either "log" or "plain" . See 48 | function details for details.} 49 | 50 | \item{conf.int}{Confidence level (\%) from 0-1 for probabilities, 51 | default is 0.95 (95\% CI). Setting to 0 removes the CIs.} 52 | 53 | \item{legend.pos}{The position of the legend, see \code{\link{legend}}; 54 | default is \code{"topleft"}} 55 | 56 | \item{facet}{Logical, in case of group used for \code{"Cuminc"}, facet by it - 57 | only relevant when use.ggplot = TRUE} 58 | 59 | \item{\dots}{Further arguments to plot or print method} 60 | } 61 | \value{ 62 | A ggplot object if use.ggplot = T used, otherwise NULL. 63 | } 64 | \description{ 65 | Plot the estimates of the non-parametric Aalen-Johansen estimate of the 66 | cumulative incidence functions (competing risks data). Note this is a method 67 | for \code{mstate::Cuminc} and not \code{cmprsk::cuminc}. Both return the same 68 | estimates, though the former does so in a dataframe, and the latter in the list. 69 | } 70 | \details{ 71 | Grouped cumulative incidences can be plotted either in the same plot or in facets, 72 | see the \code{facet} argument. 73 | } 74 | \examples{ 75 | library(ggplot2) 76 | 77 | data("aidssi") 78 | head(aidssi) 79 | si <- aidssi 80 | 81 | # No grouping 82 | cum_incid <- Cuminc( 83 | time = "time", 84 | status = "status", 85 | data = si 86 | ) 87 | 88 | plot( 89 | x = cum_incid, 90 | use.ggplot = TRUE, 91 | conf.type = "none", 92 | lty = 1:2, 93 | conf.int = 0.95 94 | ) 95 | 96 | # With grouping 97 | cum_incid_grp <- Cuminc( 98 | time = "time", 99 | status = "status", 100 | group = "ccr5", 101 | data = si 102 | ) 103 | 104 | plot( 105 | x = cum_incid_grp, 106 | use.ggplot = TRUE, 107 | conf.type = "none", 108 | lty = 1:4, 109 | facet = TRUE 110 | ) 111 | 112 | } 113 | \author{ 114 | Edouard F. Bonneville \email{e.f.bonneville@lumc.nl} 115 | } 116 | -------------------------------------------------------------------------------- /man/plot.MarkovTest.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.MarkovTest.R 3 | \name{plot.MarkovTest} 4 | \alias{plot.MarkovTest} 5 | \title{Plot method for a MarkovTest object} 6 | \usage{ 7 | \method{plot}{MarkovTest}( 8 | x, 9 | y, 10 | what = c("states", "overall"), 11 | idx = NULL, 12 | quantiles = TRUE, 13 | qsup, 14 | states, 15 | xlab, 16 | ylab, 17 | main, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{x}{Object of class 'MarkovTest'} 23 | 24 | \item{y}{The grid at which \code{MarkovTest} was calculated} 25 | 26 | \item{what}{Choose "states" for plotting state-specific traces, and 27 | "overall" for the overall chi-squared trace} 28 | 29 | \item{idx}{Vector of indices of wild bootstrap traces to plot} 30 | 31 | \item{quantiles}{Boolean whether or not to plot the 2.5 and 97.5 percent 32 | quantiles, default is \code{TRUE}} 33 | 34 | \item{qsup}{The index of the function in either \code{fn} (when plotting 35 | state-specific) or \code{fn2} (when plotting overall) to plot along with the 36 | traces; when missing this line is not included} 37 | 38 | \item{states}{Number of the qualifying state(s) to plot trace for} 39 | 40 | \item{xlab}{Text for x-axis label} 41 | 42 | \item{ylab}{Text for y-axis label} 43 | 44 | \item{main}{Text for title (main)} 45 | 46 | \item{\dots}{Further arguments to plot} 47 | } 48 | \value{ 49 | No return value 50 | } 51 | \description{ 52 | Plot method for an object of class 'MarkovTest'. It plots the trace of the 53 | log-rank statistics provided by \code{\link{MarkovTest}}. 54 | } 55 | \examples{ 56 | 57 | \dontrun{ 58 | # Example provided by the prothrombin data 59 | data("prothr") 60 | # Apply Markov test to grid of monthly time points over the first 7.5 years 61 | year <- 365.25 62 | month <- year / 12 63 | grid <- month * (1:90) 64 | # Markov test for transition 1 (wild bootstrap based on 100 replications) 65 | MT <- MarkovTest(prothr, id = "id", transition = 1, 66 | grid = grid, B = 100) 67 | 68 | plot(MT, grid, what="states", idx=1:50, states=rownames(attr(prothr, "trans")), 69 | xlab="Days since randomisation", ylab="Log-rank test statistic", 70 | main="Transition Normal -> Low") 71 | 72 | plot(MT, grid,what="overall", idx=1:50, 73 | xlab="Days since randomisation", ylab="Chi-square test statistic", 74 | main="Transition Normal -> Low") 75 | 76 | plot(MT, grid, what="states", quantiles=FALSE) # only trace 77 | plot(MT, grid, what="states") # trace plus quantiles (default) 78 | plot(MT, grid, what="states", idx=1:10) # trace plus quantiles, plus first 10 bootstrap traces 79 | 80 | plot(MT, grid, what="overall", quantiles=FALSE) # only trace 81 | plot(MT, grid, what="overall") # trace plus quantiles (default) 82 | plot(MT, grid, what="overall", idx=1:10) # trace plus quantiles, plus first 10 bootstrap traces 83 | 84 | } 85 | 86 | } 87 | \seealso{ 88 | \code{\link{MarkovTest}} 89 | } 90 | \author{ 91 | Hein Putter \email{H.Putter@lumc.nl} 92 | } 93 | \keyword{hplot} 94 | -------------------------------------------------------------------------------- /man/plot.msfit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.msfit.R 3 | \name{plot.msfit} 4 | \alias{plot.msfit} 5 | \title{Plot method for an msfit object} 6 | \usage{ 7 | \method{plot}{msfit}( 8 | x, 9 | type = c("single", "separate"), 10 | cols, 11 | xlab = "Time", 12 | ylab = "Cumulative hazard", 13 | ylim, 14 | lwd, 15 | lty, 16 | legend, 17 | legend.pos = "right", 18 | bty = "n", 19 | use.ggplot = FALSE, 20 | xlim, 21 | scale_type = "fixed", 22 | conf.int = 0.95, 23 | conf.type = "none", 24 | ... 25 | ) 26 | } 27 | \arguments{ 28 | \item{x}{Object of class \code{"msfit"}, containing estimated cumulative transition 29 | intensities for all transitions in a multi-state model} 30 | 31 | \item{type}{One of \code{"single"} (default) or \code{"separate"}; in case 32 | of \code{"single"}, all estimated cumulative hazards are drawn in a single 33 | plot, in case of \code{"separate"}, separate plots are shown for the 34 | estimated transition intensities} 35 | 36 | \item{cols}{A vector specifying colors for the different transitions; 37 | default is 1:K (K no of transitions), when type=\code{"single"}, and 1 38 | (black), when type=\code{"separate"}} 39 | 40 | \item{xlab}{A title for the x-axis; default is \code{"Time"}} 41 | 42 | \item{ylab}{A title for the y-axis; default is \code{"Cumulative hazard"}} 43 | 44 | \item{ylim}{The y limits of the plot(s); if ylim is specified for 45 | type="separate", then all plots use the same ylim for y limits} 46 | 47 | \item{lwd}{The line width, see \code{\link{par}}; default is 1} 48 | 49 | \item{lty}{The line type, see \code{\link{par}}; default is 1} 50 | 51 | \item{legend}{Character vector of length equal to the number of transitions, 52 | to be used in a legend; if missing, these will be taken from the row- and 53 | column-names of the transition matrix contained in \code{x$trans}. Also used 54 | as titles of plots for type=\code{"separate"}} 55 | 56 | \item{legend.pos}{The position of the legend, see \code{\link{legend}}; 57 | default is \code{"topleft"}} 58 | 59 | \item{bty}{The box type of the legend, see \code{\link{legend}}} 60 | 61 | \item{use.ggplot}{Default FALSE, set TRUE for ggplot version of plot} 62 | 63 | \item{xlim}{Limits of x axis, relevant if use_ggplot = T} 64 | 65 | \item{scale_type}{"fixed", "free", "free_x" or "free_y", see scales argument 66 | of facet_wrap(). Only relevant for use_ggplot = T.} 67 | 68 | \item{conf.int}{Confidence level (\%) from 0-1 for the cumulative hazard, 69 | default is 0.95. Only relevant for use_ggplot = T} 70 | 71 | \item{conf.type}{Type of confidence interval - either "log" or "plain" . See 72 | function details of \code{plot.probtrans} for details} 73 | 74 | \item{\dots}{Further arguments to plot} 75 | } 76 | \value{ 77 | No return value 78 | } 79 | \description{ 80 | Plot method for an object of class \code{"msfit"}. It plots the estimated 81 | cumulative transition intensities in the multi-state model. 82 | } 83 | \examples{ 84 | 85 | # transition matrix for illness-death model 86 | tmat <- trans.illdeath() 87 | # data in wide format, for transition 1 this is dataset E1 of 88 | # Therneau & Grambsch (2000) 89 | tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), 90 | dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), 91 | x1=c(1,1,1,0,0,0),x2=c(6:1)) 92 | # data in long format using msprep 93 | tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"), 94 | data=tg,keep=c("x1","x2"),trans=tmat) 95 | # events 96 | events(tglong) 97 | table(tglong$status,tglong$to,tglong$from) 98 | # expanded covariates 99 | tglong <- expand.covs(tglong,c("x1","x2")) 100 | # Cox model with different covariate 101 | cx <- coxph(Surv(Tstart,Tstop,status)~x1.1+x2.2+strata(trans), 102 | data=tglong,method="breslow") 103 | summary(cx) 104 | # new data, to check whether results are the same for transition 1 as 105 | # those in appendix E.1 of Therneau & Grambsch (2000) 106 | newdata <- data.frame(trans=1:3,x1.1=c(0,0,0),x2.2=c(0,1,0),strata=1:3) 107 | msf <- msfit(cx,newdata,trans=tmat) 108 | # standard plot 109 | plot(msf) 110 | # specifying line width, color, and legend 111 | plot(msf,lwd=2,col=c("darkgreen","darkblue","darkred"),legend=c("1->2","1->3","2->3")) 112 | # separate plots 113 | par(mfrow=c(2,2)) 114 | plot(msf,type="separate",lwd=2) 115 | par(mfrow=c(1,1)) 116 | 117 | # ggplot version - see vignette for details 118 | library(ggplot2) 119 | plot(msf, use.ggplot = TRUE) 120 | 121 | } 122 | \seealso{ 123 | \code{\link{msfit}} 124 | } 125 | \author{ 126 | Hein Putter \email{H.Putter@lumc.nl} 127 | 128 | Edouard F. Bonneville \email{e.f.bonneville@lumc.nl} 129 | } 130 | \keyword{hplot} 131 | -------------------------------------------------------------------------------- /man/print.MarkovTest.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/print.MarkovTest.R 3 | \name{print.MarkovTest} 4 | \alias{print.MarkovTest} 5 | \title{Print method for a MarkovTest object} 6 | \usage{ 7 | \method{print}{MarkovTest}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Object of class 'markovTest', as obtained by call to 11 | \code{\link{MarkovTest}}} 12 | 13 | \item{\dots}{Further arguments to print} 14 | } 15 | \value{ 16 | No return value 17 | } 18 | \description{ 19 | Print method for an object of class 'MarkovTest' 20 | } 21 | \examples{ 22 | 23 | \dontrun{ 24 | # Example provided by the prothrombin data 25 | data("prothr") 26 | # Apply Markov test to grid of monthly time points over the first 7.5 years 27 | year <- 365.25 28 | month <- year / 12 29 | grid <- month * (1:90) 30 | # Markov test for transition 1 (wild bootstrap based on 25 replications for brevity) 31 | MT <- MarkovTest(prothr, id = "id", transition = 1, 32 | grid = grid, B = 25) 33 | MT 34 | } 35 | 36 | } 37 | \seealso{ 38 | \code{\link{MarkovTest}} 39 | } 40 | \author{ 41 | Hein Putter \email{H.Putter@lumc.nl} 42 | } 43 | \keyword{hplot} 44 | -------------------------------------------------------------------------------- /man/print.msdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/print.msdata.R 3 | \name{print.msdata} 4 | \alias{print.msdata} 5 | \title{Print method for a msdata object} 6 | \usage{ 7 | \method{print}{msdata}(x, trans = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Object of class 'msdata', as prepared for instance by 11 | \code{\link{msprep}}} 12 | 13 | \item{trans}{Boolean specifying whether or not the transition matrix should 14 | be printed as well; default is \code{FALSE}} 15 | 16 | \item{\dots}{Further arguments to print} 17 | } 18 | \value{ 19 | No return value 20 | } 21 | \description{ 22 | Print method for an object of class 'msdata' 23 | } 24 | \examples{ 25 | 26 | # transition matrix for illness-death model 27 | tmat <- trans.illdeath() 28 | # some data in wide format 29 | tg <- data.frame(stt=rep(0,6),sts=rep(0,6), 30 | illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), 31 | dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), 32 | x1=c(1,1,1,2,2,2),x2=c(6:1)) 33 | tg$x1 <- factor(tg$x1,labels=c("male","female")) 34 | tg$patid <- factor(2:7,levels=1:8,labels=as.character(1:8)) 35 | # define time, status and covariates also as matrices 36 | tt <- matrix(c(rep(NA,6),tg$illt,tg$dt),6,3) 37 | st <- matrix(c(rep(NA,6),tg$ills,tg$ds),6,3) 38 | keepmat <- data.frame(gender=tg$x1,age=tg$x2) 39 | # data in long format using msprep 40 | msp <- msprep(time=tt,status=st,trans=tmat,keep=as.matrix(keepmat)) 41 | print(msp) 42 | print(msp, trans=TRUE) 43 | 44 | } 45 | \seealso{ 46 | \code{\link{probtrans}} 47 | } 48 | \author{ 49 | Hein Putter \email{H.Putter@lumc.nl} 50 | } 51 | \keyword{hplot} 52 | -------------------------------------------------------------------------------- /man/print.summary.msfit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.msfit.R 3 | \name{print.summary.msfit} 4 | \alias{print.summary.msfit} 5 | \title{Print method for summary.msfit object} 6 | \usage{ 7 | \method{print}{summary.msfit}(x, complete = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Object of class 'summary.msfit', to be printed} 11 | 12 | \item{complete}{Whether or not the complete estimated cumulative transition 13 | intensities should be printed (\code{TRUE}) or not (\code{FALSE}); default 14 | is \code{FALSE}, in which case the estimated cumulative transition hazards 15 | will be printed for the first and last 6 time points of each transition or 16 | of the selected times (or all when there are at most 12 of these time points} 17 | 18 | \item{\dots}{Further arguments to print} 19 | } 20 | \description{ 21 | Print method for summary.msfit object 22 | } 23 | \examples{ 24 | \dontrun{ 25 | # If all time points should be printed, specify complete=TRUE in the print statement 26 | print(x, complete=TRUE) 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /man/print.summary.probtrans.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.probtrans.R 3 | \name{print.summary.probtrans} 4 | \alias{print.summary.probtrans} 5 | \title{Print method for a summary.probtrans object} 6 | \usage{ 7 | \method{print}{summary.probtrans}(x, complete = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Object of class 'summary.probtrans', to be printed} 11 | 12 | \item{complete}{Whether or not the complete estimated transition 13 | probabilities should be printed (\code{TRUE}) or not (\code{FALSE}); default 14 | is \code{FALSE}, in which case the estimated transition probilities will be 15 | printed for the first and last 6 time points of each starting state or of 16 | the selected times (or all when there are at most 12 of these time points} 17 | 18 | \item{\dots}{Further arguments to print} 19 | } 20 | \description{ 21 | Print method for a summary.probtrans object 22 | } 23 | \examples{ 24 | 25 | \dontrun{ 26 | # If all time points should be printed, specify complete=TRUE in the print statement 27 | print(x, complete=TRUE) 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /man/summary.Cuminc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.Cuminc.R 3 | \name{summary.Cuminc} 4 | \alias{summary.Cuminc} 5 | \title{Summary method for a summary.Cuminc object} 6 | \usage{ 7 | \method{summary}{Cuminc}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{Object of class 'Cuminc', to be summarised} 11 | 12 | \item{\dots}{Further arguments to summarise} 13 | } 14 | \description{ 15 | Summary method for a summary.Cuminc object 16 | } 17 | -------------------------------------------------------------------------------- /man/summary.msfit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.msfit.R 3 | \name{summary.msfit} 4 | \alias{summary.msfit} 5 | \title{Summary method for an msfit object} 6 | \usage{ 7 | \method{summary}{msfit}( 8 | object, 9 | times, 10 | transitions, 11 | variance = TRUE, 12 | conf.int = 0.95, 13 | conf.type = c("log", "none", "plain"), 14 | extend = FALSE, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{object}{Object of class 'msfit', containing estimated cumulative 20 | transition intensities for all transitions in a multi-state model} 21 | 22 | \item{times}{Time points at which to evaluate the cumulative transition 23 | hazards} 24 | 25 | \item{transitions}{The transition for which to summarize the cumulative 26 | transition hazards} 27 | 28 | \item{variance}{Whether or not the standard errors of the estimated 29 | cumulative transition intensities should be printed; default is \code{TRUE}} 30 | 31 | \item{conf.int}{The proportion to be covered by the confidence intervals, 32 | default is 0.95} 33 | 34 | \item{conf.type}{The type of confidence interval, one of "log", "none", or 35 | "plain". Defaults to "log"} 36 | 37 | \item{extend}{logical value: if \code{TRUE}, prints information for all 38 | specified times, even if there are no subjects left at the end of the 39 | specified times. This is only valid if the times argument is present} 40 | 41 | \item{\dots}{Further arguments to summary} 42 | } 43 | \value{ 44 | Function \code{summary.msfit} returns an object of class 45 | "summary.msfit", which is a list (for each \code{from} state) of cumulative 46 | transition hazaards at the specified (or all) time points. The \code{print} 47 | method of a \code{summary.probtrans} doesn't return a value. 48 | } 49 | \description{ 50 | Summary method for an object of class 'msfit'. It prints a selection of the 51 | estimated cumulative transition intensities, and, if requested, also of the 52 | (co)variances. 53 | } 54 | \examples{ 55 | 56 | # Start with example from msfit 57 | tmat <- trans.illdeath() 58 | tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), 59 | dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), 60 | x1=c(1,1,1,0,0,0),x2=c(6:1)) 61 | tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"), 62 | data=tg,keep=c("x1","x2"),trans=tmat) 63 | tglong <- expand.covs(tglong,c("x1","x2")) 64 | cx <- coxph(Surv(Tstart,Tstop,status)~x1.1+x2.2+strata(trans), 65 | data=tglong,method="breslow") 66 | newdata <- data.frame(trans=1:3,x1.1=c(0,0,0),x2.2=c(0,1,0),strata=1:3) 67 | msf <- msfit(cx,newdata,trans=tmat) 68 | 69 | # Default, all transitions, with SE 70 | summary(msf) 71 | summary(msf, conf.type="plain") 72 | # Only transitions 1 and 3 73 | summary(msf, tra=c(1, 3)) 74 | # Default is 95\% confidence interval, change here to 90\% 75 | summary(msf, conf.int=0.90) 76 | # Do not show variances (nor confidence intervals) 77 | summary(msf, variance=FALSE) 78 | # Cumulative hazards only at specified time points 79 | summary(msf, times=seq(0, 15, by=3)) 80 | # Last specified time point is larger than last observed, not printed 81 | # Use extend=TRUE as in summary.survfit 82 | summary(msf, times=seq(0, 15, by=3), extend=TRUE) 83 | # Different types of confidence intervals, default is log 84 | summary(msf, times=seq(0, 15, by=3), conf.type="plain") 85 | summary(msf, times=seq(0, 15, by=3), conf.type="no") 86 | # When the number of time points specified is larger than 12, head and tail is shown 87 | x <- summary(msf, times=seq(5, 8, by=0.25)) 88 | x 89 | 90 | } 91 | \seealso{ 92 | \code{\link{msfit}} 93 | } 94 | \author{ 95 | Hein Putter \email{H.Putter@lumc.nl} 96 | } 97 | \keyword{print} 98 | -------------------------------------------------------------------------------- /man/summary.probtrans.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.probtrans.R 3 | \name{summary.probtrans} 4 | \alias{summary.probtrans} 5 | \title{Summary method for a probtrans object} 6 | \usage{ 7 | \method{summary}{probtrans}( 8 | object, 9 | times, 10 | from = 1, 11 | to = 0, 12 | variance = TRUE, 13 | conf.int = 0.95, 14 | conf.type = c("log", "none", "plain"), 15 | extend = FALSE, 16 | ... 17 | ) 18 | } 19 | \arguments{ 20 | \item{object}{Object of class 'probtrans', containing estimated transition 21 | probabilities from and to all states in a multi-state model} 22 | 23 | \item{times}{Time points at which to evaluate the transition probabilites} 24 | 25 | \item{from}{Specifies from which state the transition probabilities are to 26 | be printed. Should be subset of 1:S, with S the number of states in the 27 | multi-state model. Default is print from state 1 only. User can specify 28 | from=0 to print transition probabilities from all states} 29 | 30 | \item{to}{Specifies the transition probabilities to which state are to be 31 | printed. User can specify to=0 to print transition probabilities to all 32 | states. This is also the default} 33 | 34 | \item{variance}{Whether or not the standard errors of the estimated 35 | transition probabilities should be printed; default is \code{TRUE}} 36 | 37 | \item{conf.int}{The proportion to be covered by the confidence intervals, 38 | default is 0.95} 39 | 40 | \item{conf.type}{The type of confidence interval, one of "log", "none", or 41 | "plain". Defaults to "log"} 42 | 43 | \item{extend}{logical value: if \code{TRUE}, prints information for all 44 | specified times, even if there are no subjects left at the end of the 45 | specified times. This is only valid if the times argument is present} 46 | 47 | \item{\dots}{Further arguments to print} 48 | } 49 | \value{ 50 | Function \code{summary.probtrans} returns an object of class 51 | "summary.probtrans", which is a list (for each \code{from} state) of 52 | transition probabilities at the specified (or all) time points. The 53 | \code{print} method of a \code{summary.probtrans} doesn't return a value. 54 | } 55 | \description{ 56 | Summary method for an object of class 'probtrans'. It prints a selection of 57 | the estimated transition probabilities, and, if requested, also of the 58 | variances. 59 | } 60 | \examples{ 61 | 62 | # First run the example of probtrans 63 | tmat <- trans.illdeath() 64 | tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), 65 | dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), 66 | x1=c(1,1,1,0,0,0),x2=c(6:1)) 67 | tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"), 68 | data=tg,keep=c("x1","x2"),trans=tmat) 69 | tglong <- expand.covs(tglong,c("x1","x2")) 70 | cx <- coxph(Surv(Tstart,Tstop,status)~x1.1+x2.2+strata(trans), 71 | data=tglong,method="breslow") 72 | newdata <- data.frame(trans=1:3,x1.1=c(0,0,0),x2.2=c(0,1,0),strata=1:3) 73 | HvH <- msfit(cx,newdata,trans=tmat) 74 | pt <- probtrans(HvH,predt=0) 75 | 76 | # Default, prediction from state 1 77 | summary(pt) 78 | # Only from states 1 and 3 79 | summary(pt, from=c(1, 3)) 80 | # Use from=0 for prediction from all states 81 | summary(pt, from=0) 82 | # Only to states 1 and 2 83 | summary(pt, to=1:2) 84 | # Default is 95\% confidence interval, change here to 90\% 85 | summary(pt, to=1:2, conf.int=0.90) 86 | # Do not show variances (nor confidence intervals) 87 | summary(pt, to=1:2, variance=FALSE) 88 | # Transition probabilities only at specified time points 89 | summary(pt, times=seq(0, 15, by=3)) 90 | # Last specified time point is larger than last observed, not printed 91 | # Use extend=TRUE as in summary.survfit 92 | summary(pt, times=seq(0, 15, by=3), extend=TRUE) 93 | # Different types of confidence intervals, default is log 94 | summary(pt, times=seq(0, 15, by=3), conf.type="plain") 95 | summary(pt, times=seq(0, 15, by=3), conf.type="no") 96 | # When the number of time points specified is larger than 12, head and tail is shown 97 | x <- summary(pt, times=seq(5, 8, by=0.25)) 98 | x 99 | 100 | } 101 | \seealso{ 102 | \code{\link{probtrans}} 103 | } 104 | \author{ 105 | Hein Putter \email{H.Putter@lumc.nl} 106 | } 107 | \keyword{print} 108 | -------------------------------------------------------------------------------- /man/trans2tra.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/etm2msdata.R 3 | \name{trans2tra} 4 | \alias{trans2tra} 5 | \title{Convert transition matrix from mstate to etm format} 6 | \usage{ 7 | trans2tra(trans) 8 | } 9 | \arguments{ 10 | \item{trans}{Transition matrix in \code{mstate} format} 11 | } 12 | \description{ 13 | Convert transition matrix from mstate to etm format 14 | } 15 | -------------------------------------------------------------------------------- /man/transMat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/transMat.R 3 | \name{transMat} 4 | \alias{transMat} 5 | \alias{trans.illdeath} 6 | \alias{trans.comprisk} 7 | \title{Define transition matrix for multi-state model} 8 | \usage{ 9 | transMat(x, names) 10 | } 11 | \arguments{ 12 | \item{x}{List of possible transitions; x[[i]] consists of a vector of state 13 | numbers reachable from state i} 14 | 15 | \item{names}{A character vector containing the names of either the competing 16 | risks or the states in the multi-state model specified by the competing 17 | risks or illness-death model. \code{names} should have the same length as 18 | the list \code{x} (for \code{transMat}), or either \code{K} or \code{K}+1 19 | (for \code{trans.comprisk}), or 3 (for \code{trans.illdeath})} 20 | } 21 | \value{ 22 | A transition matrix describing the states and transitions in the 23 | multi-state model. 24 | } 25 | \description{ 26 | Define transition matrices for multi-state model. Specific functions for 27 | defining such transition matrices are pre-defined for common multi-state 28 | models like the competing risks model and the illness-death model. 29 | } 30 | \details{ 31 | If \code{names} is missing, the names \code{"eventfree"}, \code{"cause1"}, 32 | etcetera are assigned in \code{trans.comprisk}, or \code{"healthy"}, 33 | \code{"illness"}, \code{"death"} in \code{trans.illdeath}. 34 | } 35 | \examples{ 36 | 37 | transMat(list(c(2, 3), c(), c(1, 2)), 38 | names = c("Disease-free", "Death", "Relapsed")) 39 | tmat <- transMat(x = list( c(2, 3), c(1, 3), c() ), 40 | names = c("Normal", "Low", "Death")) 41 | tmat 42 | transListn <- list("Normal" = c(2, 3), "Low" = c(1, 3), "Death" = c()) 43 | transMat(transListn) 44 | trans.comprisk(3) 45 | trans.comprisk(3,c("c1","c2","c3")) 46 | trans.comprisk(3,c("nothing","c1","c2","c3")) 47 | trans.illdeath() 48 | trans.illdeath(c("nothing","ill","death")) 49 | 50 | } 51 | \author{ 52 | Steven McKinney ; Hein Putter 53 | 54 | } 55 | \keyword{array} 56 | -------------------------------------------------------------------------------- /man/transhelp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datasets.R 3 | \name{transhelp} 4 | \alias{transhelp} 5 | \alias{to.trans2} 6 | \alias{trans2Q} 7 | \alias{absorbing} 8 | \alias{is.circular} 9 | \title{Help functions for transition matrix} 10 | \arguments{ 11 | \item{trans}{Transition matrix, for instance produced by \code{transMat}), 12 | \code{trans.comprisk}, or \code{trans.illdeath}} 13 | } 14 | \value{ 15 | See details. 16 | } 17 | \description{ 18 | Help functions to get insight into the structure of a transition matrix. 19 | } 20 | \details{ 21 | Function \code{to.trans2} simply lists the transitions in \code{trans} in a 22 | data frame; function \code{trans2Q} converts \code{trans} to a \code{Q} 23 | matrix, the (j,k)th element of which contains the (shortest) number of 24 | transitions needed to travel from the jth to the kth state; function 25 | \code{absorbing} returns a vector (named if \code{trans} contains row or 26 | columnc names) with the state numbers that are absorbing; function 27 | \code{is.circular} returns (a Boolean) whether the transition matrix 28 | specified in \code{trans} is circular or not. 29 | } 30 | \examples{ 31 | 32 | # Irreversible illness-death model 33 | tmat <- trans.illdeath(c("Healthy", "Illness", "Death")) 34 | tmat 35 | to.trans2(tmat) 36 | trans2Q(tmat) 37 | absorbing(tmat) 38 | is.circular(tmat) 39 | # Reversible illness-death model 40 | tmat <- transMat(x = list( c(2, 3), c(1, 3), c() ), 41 | names = c("Healthy", "Illness", "Death")) 42 | tmat 43 | to.trans2(tmat) 44 | trans2Q(tmat) 45 | absorbing(tmat) 46 | is.circular(tmat) 47 | 48 | } 49 | \author{ 50 | Hein Putter 51 | } 52 | \keyword{univar} 53 | -------------------------------------------------------------------------------- /man/varHaz.fixed.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/relsurv.varHaz.fixed.R 3 | \name{varHaz.fixed} 4 | \alias{varHaz.fixed} 5 | \title{Upgrade the varHaz object} 6 | \usage{ 7 | varHaz.fixed(varHaz, link_trans, varHaz_original) 8 | } 9 | \arguments{ 10 | \item{varHaz}{The varHaz object (present in a msfit object).} 11 | 12 | \item{link_trans}{A list that gives the linkage between the original and upgraded 13 | transition matrix.} 14 | 15 | \item{varHaz_original}{The original varHaz object from msfit (without the eventual time conversion).} 16 | } 17 | \value{ 18 | Return the upgraded varHaz object containing variances for the split transitions. 19 | } 20 | \description{ 21 | A function that upgrades varHaz from the msfit object where the variances are 22 | estimated using the Greenwood estimator; it is further assumed that variances for the population 23 | hazards are equal to zero. 24 | } 25 | \author{ 26 | Damjan Manevski \email{damjan.manevski@mf.uni-lj.si} 27 | } 28 | -------------------------------------------------------------------------------- /man/vis.mirror.pt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/vis.mirror.pt.R 3 | \name{vis.mirror.pt} 4 | \alias{vis.mirror.pt} 5 | \title{Mirror plot comparing two probtrans objects} 6 | \usage{ 7 | vis.mirror.pt( 8 | x, 9 | titles, 10 | size_titles = 5, 11 | horizon = NULL, 12 | breaks_x_left, 13 | breaks_x_right, 14 | from = 1, 15 | cols, 16 | ord, 17 | xlab = "Time", 18 | ylab = "Probability", 19 | legend.pos = "right" 20 | ) 21 | } 22 | \arguments{ 23 | \item{x}{A list of two \code{"probtrans"} objects. 24 | The first element will be on the left of the mirror plot, 25 | and the second on the right} 26 | 27 | \item{titles}{A character vector c("Title for left", "Title for right")} 28 | 29 | \item{size_titles}{Numeric, size of the title text} 30 | 31 | \item{horizon}{Numeric, position denoting (in time) where to symmetrically 32 | mirror the plots. Default is maximum follow-up of from both plots.} 33 | 34 | \item{breaks_x_left}{Numeric vector specifying axis breaks on the left plot} 35 | 36 | \item{breaks_x_right}{Numeric vector specifying axis breaks on the right plot} 37 | 38 | \item{from}{The starting state from which the probabilities are used to plot} 39 | 40 | \item{cols}{A vector specifying colors for the different transitions; 41 | default is a palette from green to red, when type=\code{"filled"} (reordered 42 | according to \code{ord}, and 1 (black), otherwise} 43 | 44 | \item{ord}{A vector of length equal to the number of states, specifying the 45 | order of plotting in case type=\code{"stacked"} or \code{"filled"}} 46 | 47 | \item{xlab}{A title for the x-axis, default is "Time"} 48 | 49 | \item{ylab}{A title for the y-axis, default is "Probability"} 50 | 51 | \item{legend.pos}{Position of the legend, default is "right"} 52 | } 53 | \value{ 54 | A ggplot2 object. 55 | } 56 | \description{ 57 | A mirror plot for comparing two different \code{"probtrans"} objects. Useful 58 | for comparing predicted probabilities for different levels of a covariate, 59 | or for different subgroups at some prediction time horizon. 60 | } 61 | \examples{ 62 | 63 | library(ggplot2) 64 | 65 | data("aidssi") 66 | head(aidssi) 67 | si <- aidssi 68 | 69 | # Prepare transition matrix 70 | tmat <- trans.comprisk(2, names = c("event-free", "AIDS", "SI")) 71 | 72 | # Run msprep 73 | si$stat1 <- as.numeric(si$status == 1) 74 | si$stat2 <- as.numeric(si$status == 2) 75 | 76 | silong <- msprep( 77 | time = c(NA, "time", "time"), 78 | status = c(NA, "stat1", "stat2"), 79 | data = si, keep = "ccr5", trans = tmat 80 | ) 81 | 82 | # Run cox model 83 | silong <- expand.covs(silong, "ccr5") 84 | c1 <- coxph(Surv(time, status) ~ ccr5WM.1 + ccr5WM.2 + strata(trans), 85 | data = silong) 86 | 87 | # 1. Prepare reference patient data - both CCR5 genotypes 88 | WW <- data.frame( 89 | ccr5WM.1 = c(0, 0), 90 | ccr5WM.2 = c(0, 0), 91 | trans = c(1, 2), 92 | strata = c(1, 2) 93 | ) 94 | 95 | WM <- data.frame( 96 | ccr5WM.1 = c(1, 0), 97 | ccr5WM.2 = c(0, 1), 98 | trans = c(1, 2), 99 | strata = c(1, 2) 100 | ) 101 | 102 | # 2. Make msfit objects 103 | msf.WW <- msfit(c1, WW, trans = tmat) 104 | msf.WM <- msfit(c1, WM, trans = tmat) 105 | 106 | # 3. Make probtrans objects 107 | pt.WW <- probtrans(msf.WW, predt = 0) 108 | pt.WM <- probtrans(msf.WM, predt = 0) 109 | 110 | # Mirror plot split at 10 years - see vignette for more details 111 | vis.mirror.pt( 112 | x = list(pt.WW, pt.WM), 113 | titles = c("WW", "WM"), 114 | horizon = 10 115 | ) 116 | 117 | } 118 | \seealso{ 119 | \code{\link{plot.probtrans}} 120 | } 121 | \author{ 122 | Edouard F. Bonneville \email{e.f.bonneville@lumc.nl} 123 | } 124 | -------------------------------------------------------------------------------- /man/vis.multiple.pt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/vis.multiple.pt.R 3 | \name{vis.multiple.pt} 4 | \alias{vis.multiple.pt} 5 | \title{Visualise multiple probtrans objects} 6 | \usage{ 7 | vis.multiple.pt( 8 | x, 9 | from = 1, 10 | to, 11 | xlab = "Time", 12 | ylab = "Probability", 13 | xlim = NULL, 14 | ylim = NULL, 15 | cols, 16 | lwd, 17 | labels, 18 | conf.int = 0.95, 19 | conf.type = c("log", "plain", "none"), 20 | legend.title 21 | ) 22 | } 23 | \arguments{ 24 | \item{x}{A list of \code{"probtrans"} objects} 25 | 26 | \item{from}{The starting state from which the probabilities are used to plot 27 | Numeric, as in \code{plot.probtrans}} 28 | 29 | \item{to}{(Numeric) destination state} 30 | 31 | \item{xlab}{A title for the x-axis; default is \code{"Time"}} 32 | 33 | \item{ylab}{A title for the y-axis; default is \code{"Probability"}} 34 | 35 | \item{xlim}{The x limits of the plot(s), default is range of time} 36 | 37 | \item{ylim}{The y limits of the plot(s); if ylim is specified for 38 | type="separate", then all plots use the same ylim for y limits} 39 | 40 | \item{cols}{A vector specifying colors for the different transitions; 41 | default is a palette from green to red, when type=\code{"filled"} (reordered 42 | according to \code{ord}, and 1 (black), otherwise} 43 | 44 | \item{lwd}{The line width, see \code{\link{par}}; default is 1} 45 | 46 | \item{labels}{Character vector labelling each element of x (e.g. label 47 | for a reference patient) - so labels = c("Patient 1", "Patient 2")} 48 | 49 | \item{conf.int}{Confidence level (\%) from 0-1 for probabilities, 50 | default is 0.95 (95\% CI). Setting to 0 removes the CIs.} 51 | 52 | \item{conf.type}{Type of confidence interval - either "log" or "plain" . See 53 | function details for details.} 54 | 55 | \item{legend.title}{Character - title of legend} 56 | } 57 | \value{ 58 | A ggplot object. 59 | } 60 | \description{ 61 | Helper function allowing to visualise state probabilities for 62 | different reference patients/covariates. Multiple \code{"probtrans"} objects 63 | are thus needed. 64 | } 65 | \examples{ 66 | 67 | library(ggplot2) 68 | 69 | data("aidssi") 70 | head(aidssi) 71 | si <- aidssi 72 | 73 | # Prepare transition matrix 74 | tmat <- trans.comprisk(2, names = c("event-free", "AIDS", "SI")) 75 | 76 | # Run msprep 77 | si$stat1 <- as.numeric(si$status == 1) 78 | si$stat2 <- as.numeric(si$status == 2) 79 | 80 | silong <- msprep( 81 | time = c(NA, "time", "time"), 82 | status = c(NA, "stat1", "stat2"), 83 | data = si, keep = "ccr5", trans = tmat 84 | ) 85 | 86 | # Run cox model 87 | silong <- expand.covs(silong, "ccr5") 88 | c1 <- coxph(Surv(time, status) ~ ccr5WM.1 + ccr5WM.2 + strata(trans), 89 | data = silong) 90 | 91 | # 1. Prepare patient data - both CCR5 genotypes 92 | WW <- data.frame( 93 | ccr5WM.1 = c(0, 0), 94 | ccr5WM.2 = c(0, 0), 95 | trans = c(1, 2), 96 | strata = c(1, 2) 97 | ) 98 | 99 | WM <- data.frame( 100 | ccr5WM.1 = c(1, 0), 101 | ccr5WM.2 = c(0, 1), 102 | trans = c(1, 2), 103 | strata = c(1, 2) 104 | ) 105 | 106 | # 2. Make msfit objects 107 | msf.WW <- msfit(c1, WW, trans = tmat) 108 | msf.WM <- msfit(c1, WM, trans = tmat) 109 | 110 | # 3. Make probtrans objects 111 | pt.WW <- probtrans(msf.WW, predt = 0) 112 | pt.WM <- probtrans(msf.WM, predt = 0) 113 | 114 | # Plot - see vignette for more details 115 | vis.multiple.pt( 116 | x = list(pt.WW, pt.WM), 117 | from = 1, 118 | to = 2, 119 | conf.type = "log", 120 | cols = c(1, 2), 121 | labels = c("Pat WW", "Pat WM"), 122 | legend.title = "Ref patients" 123 | ) 124 | 125 | } 126 | \author{ 127 | Edouard F. Bonneville \email{e.f.bonneville@lumc.nl} 128 | } 129 | -------------------------------------------------------------------------------- /man/xsect.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/xsect.R 3 | \name{xsect} 4 | \alias{xsect} 5 | \title{Make a cross-section of multi-state data at a given time point} 6 | \usage{ 7 | xsect(msdata, xtime = 0) 8 | } 9 | \arguments{ 10 | \item{msdata}{An object of class \code{"msdata"}, such as output by 11 | \code{\link{msprep}}} 12 | 13 | \item{xtime}{The time point at which the intersection is to be made} 14 | } 15 | \value{ 16 | A list containing \code{idstate}, a data frame containing 17 | \code{id}'s and \code{state}, the number of the state currently occupied; 18 | \code{atrisk}, the number at risk, and \code{prop}, a table counting how 19 | many of those at risk occupy which state. 20 | } 21 | \description{ 22 | Given a dataset in long format, for instance generated by 23 | \code{\link{msprep}}, this function takes a cross-section at a given time 24 | point, to list the subjects under observation (at risk) at that time point 25 | and the states currently occupied. 26 | } 27 | \details{ 28 | It is possible that subjects have moved to one of the absorbing states prior 29 | to \code{xtime}; this is NOT taken into account. The function \code{xsect} 30 | only concerns subjects currently (at \code{time}) at risk. 31 | } 32 | \examples{ 33 | 34 | tmat <- trans.illdeath(names=c("Tx","PR","RelDeath")) 35 | data(ebmt3) # data from Section 4 of Putter, Fiocco & Geskus (2007) 36 | msebmt <- msprep(time=c(NA,"prtime","rfstime"),status=c(NA,"prstat","rfsstat"), 37 | data=ebmt3,trans=tmat) 38 | # At the start everyone is in state 1 (default xtime=0 is used) 39 | xsect(msebmt) 40 | # At 5 years 41 | xsect(msebmt, xtime=1826) 42 | 43 | } 44 | \author{ 45 | Hein Putter \email{H.Putter@lumc.nl} 46 | } 47 | \keyword{univar} 48 | -------------------------------------------------------------------------------- /mstate.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageCheckArgs: --as-cran 19 | -------------------------------------------------------------------------------- /src-i386/agmssurv.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/src-i386/agmssurv.o -------------------------------------------------------------------------------- /src-i386/mstate_init.c: -------------------------------------------------------------------------------- 1 | #include // for NULL 2 | #include 3 | 4 | /* FIXME: 5 | Check these declarations against the C/Fortran source code. 6 | */ 7 | 8 | /* .C calls */ 9 | extern void agmssurv(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); 10 | 11 | static const R_CMethodDef CEntries[] = { 12 | {"agmssurv", (DL_FUNC) &agmssurv, 20}, 13 | {NULL, NULL, 0} 14 | }; 15 | 16 | void R_init_mstate(DllInfo *dll) 17 | { 18 | R_registerRoutines(dll, CEntries, NULL, NULL, NULL); 19 | R_useDynamicSymbols(dll, FALSE); 20 | } 21 | -------------------------------------------------------------------------------- /src-i386/mstate_init.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hputter/mstate/e5152ca4a3b1db9d814ede307ffad68e666f5c4d/src-i386/mstate_init.o -------------------------------------------------------------------------------- /src/mstate_init.c: -------------------------------------------------------------------------------- 1 | #include // for NULL 2 | #include 3 | 4 | /* FIXME: 5 | Check these declarations against the C/Fortran source code. 6 | */ 7 | 8 | /* .C calls */ 9 | extern void agmssurv(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); 10 | 11 | static const R_CMethodDef CEntries[] = { 12 | {"agmssurv", (DL_FUNC) &agmssurv, 20}, 13 | {NULL, NULL, 0} 14 | }; 15 | 16 | void R_init_mstate(DllInfo *dll) 17 | { 18 | R_registerRoutines(dll, CEntries, NULL, NULL, NULL); 19 | R_useDynamicSymbols(dll, FALSE); 20 | } 21 | -------------------------------------------------------------------------------- /vignettes/Tutorial.bib: -------------------------------------------------------------------------------- 1 | @BOOK{ABGK, 2 | author = {P. K. Andersen and {\O}. Borgan and R. D. Gill and N. Keiding}, 3 | title = {Statistical Models Based on Counting Processes}, 4 | publisher = {Springer-Verlag}, 5 | year = 1993 6 | } 7 | 8 | @ARTICLE{FioccoPvH05, 9 | AUTHOR = {Fiocco, M. and Putter, H. and van Houwelingen, J. C.}, 10 | TITLE = {Reduced rank proportional hazards model for competing risks}, 11 | JOURNAL = {Biostatistics}, 12 | YEAR = {2005}, 13 | volume = {6}, 14 | pages = {465-478} 15 | } 16 | 17 | @ARTICLE{Tut, 18 | AUTHOR = "Putter, H. and Fiocco, M. and Geskus, R. B.", 19 | TITLE = "Tutorial in biostatistics: Competing risks and multi-state models", 20 | JOURNAL = "Statist Med", 21 | YEAR = "2007", 22 | volume = "26", 23 | pages = "2389-2430", 24 | } 25 | 26 | @ARTICLE{deW, 27 | AUTHOR = "de Wreede, L. and Fiocco, M. and Putter, H.", 28 | TITLE = "The mstate package for estimation and prediction in non- and semi-parametric multi-state models", 29 | YEAR = "2009", 30 | note = "Submitted" 31 | } 32 | 33 | @Book{ggplot, 34 | author = {Hadley Wickham}, 35 | title = {ggplot2: Elegant Graphics for Data Analysis}, 36 | publisher = {Springer-Verlag New York}, 37 | year = {2016}, 38 | isbn = {978-3-319-24277-4}, 39 | url = {https://ggplot2.tidyverse.org}, 40 | } 41 | --------------------------------------------------------------------------------