Debian Codegraph @

man/msfit.relsurv.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/relsurv.msfit.relsurv.R
3 \name{msfit.relsurv}
4 \alias{msfit.relsurv}
5 \title{Extend a multi-state model using relative survival}
6 \usage{
7 msfit.relsurv(
8 msfit.obj,
9 data,
10 split.transitions,
11 ratetable = relsurv::slopop,
12 rmap,
13 time.format = "days",
14 var.pop.haz = c("fixed", "bootstrap", "both"),
15 B = 10,
16 seed = NULL,
17 add.times,
18 substitution = TRUE,
19 link_trans_ind = FALSE
20 )
21 }
22 \arguments{
23 \item{msfit.obj}{The msfit object which has to be upgraded}
24
25 \item{data}{The data used for fitting the msfit model}
26
27 \item{split.transitions}{An integer vector containing the numbered transitions that should be split. Use same numbering as in the given transition matrix}
28
29 \item{ratetable}{The population mortality table. A table of event rates, organized as a ratetable object, see for example relsurv::slopop. Default is slopop}
30
31 \item{rmap}{An optional list to be used if the variables in the data are not organized (and named) in the same way as in the ratetable object}
32
33 \item{time.format}{Define the time format which is used in the data. Possible options: c('days', 'years', 'months'). Default is 'days'}
34
35 \item{var.pop.haz}{If 'fixed' (default), the Greenwood estimator for the variances is used, where it is assumed that the variance of the population hazards is zero. If 'bootstrap', one gets boostrap estimates for all all transitions. Option 'both' gives both variance estimates}
36
37 \item{B}{Number of bootstrap replications. Relevant only if var.pop.haz == 'bootstrap' or 'both'. Default is B=10.}
38
39 \item{seed}{Set seed}
40
41 \item{add.times}{Additional times at which hazards should be evaluated}
42
43 \item{substitution}{Whether function substitute should be used for rmap argument. Default is TRUE}
44
45 \item{link_trans_ind}{Choose whether the linkage between the old and new transition matrix should be saved. Default is FALSE.}
46 }
47 \value{
48 Returns a msfit object that contains estimates for the extended model
49 with split (population and excess) transitions.
50 }
51 \description{
52 A function that takes a fitted msfit object and upgrades
53 it using relative survival, where chosen transitions are
54 split in population and excess transitions. This upgraded
55 msfit object contains the split hazards based on the transition
56 matrix (transMat). The (co)variance matrix is also upgraded, if provided.
57 }
58 \examples{
59
60 \dontrun{
61 library(mstate)
62 # Load dataset:
63 data("ebmt1")
64 # Transition matrix:
65 tmat <- transMat(list(c(2,3),c(4), c(), c()),
66 names = c("Alive relapse-free", "Relapse","NRM", "DaR"))
67 # Data in long format using msprep
68 df <- msprep(time=c(NA,"rel","srv","srv"), status=c(NA,"relstat","srvstat","srvstat"),
69 data=ebmt1, trans=tmat)
70 # Generate demographic covariates (which are usually present in datasets)
71 # and based on them estimate the population hazard.
72 set.seed(510)
73 df$age <- runif(nrow(df), 45, 65)
74 df$sex <- sample(c("male", "female"), size = nrow(df), replace = TRUE)
75 df$dateHCT <- sample(seq(as.Date('1990/01/01'),
76 as.Date('2000/01/01'), by="day"), nrow(df), replace = TRUE) # generate years
77 # Cox object:
78 cx <- coxph(Surv(Tstart,Tstop,status)~strata(trans),
79 data=df,method="breslow")
80 # Basic multi-state model:
81 mod <- msfit(cx,trans=tmat)
82 # Extended multi-state model, where the two transition
83 # reaching death are split in excess and population parts.
84 # We assume patients live like in the Slovene population,
85 # thus we use Slovene mortality tables in this example.
86 # Variances estimated using 25 bootstrap replications.
87 mod.relsurv <- msfit.relsurv(msfit.obj = mod, data=df, split.transitions = c(2,3),
88 ratetable = relsurv::slopop,
89 rmap = list(age=age*365.241, year=dateHCT),
90 time.format = "days",
91 var.pop.haz = "bootstrap",
92 B = 25)
93 # Estimate transition probabilities:
94 pt <- probtrans(mod.relsurv, predt=0, method='greenwood')
95 # Estimated cumulative hazards with the corresponding
96 # bootstrap standard errors at 300, 600, 900 days:
97 summary(object = mod.relsurv, times = c(300, 600, 900), conf.type = 'log')
98 # Estimated transition probabilities together with the corresponding
99 # bootstrap standard errors and log.boot confidence intervals
100 # at 300, 600, 900 days:
101 summary(object = pt, times = c(300, 600, 900), conf.type = 'log')
102 # Plot the measures:
103 plot(mod.relsurv, use.ggplot = TRUE)
104 plot(pt, use.ggplot = TRUE)
105 }
106 }
107 \references{
108 Manevski D, Putter H, Pohar Perme M, Bonneville EF, Schetelig J, de Wreede LC (2021).
109 Integrating relative survival in multi-state models -- a non-parametric approach.
110 https://arxiv.org/abs/2106.12399
111 }
112 \seealso{
113 \code{\link{msfit}}
114 }
115 \author{
116 Damjan Manevski \email{[email protected]}
117 }