Debian Codegraph @

man/ELOS.Rd

raw
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{[email protected]}
71 }
72 \keyword{univar}