mssample's output is different in situations where it seems like it shouldn't be. The discrepency arises for any situation in which (a) gap vs. clock time are identical metrics (e.g., situations where the starting stage has exiting transitions, like basic Cox or competing risk stage structures) and (b) when mssample()'s specified starting time $\neq 0$.
Problem's Source
The discrepency's stemming from these lines in mssample1() (lines 37–45):
The first time a subject transitions represents the actual time at which that event occurs: a transition occurring at, e.g., $t = 7$ for clock is equivalent to a transition occurring at $t=7$ for gap (only possible if the start time's $<7$, of course). Tstop should therefore equal 7 for both metrics after the first transition in a basic Cox or CR setup.
At present, that's not what will happen. To continue the running example, Tstop will correctly = 7 after the subject's first transition for clock time. However, for gap time, Tstop will equal 7 + tcond.
Earlier, tcond is defined as (mssample1(), line 15):
tcond <- t0 <- Tstart <- history$time
history$time is the start time set by the user in the original mssample() call. If the start time is non-zero, the gap time's Tstop != 7 after the first transition.
Seems like we shouldn't be adding tcond for a subject's first transition for a gap-time duration. (We do still need to add tcond in gap time for any of the subject's subsequent transitions, though.)
Wanted to acknowledge: hadn't realized this was similar to #8 until now. Will still leave this issue open, just in case #8's problem has a different cause than the problem I describe here.
R: 4.1.3 64-bit, mstate: 0.3.2, survival: 3.5.0, Win11
Problem
mssample
's output is different in situations where it seems like it shouldn't be. The discrepency arises for any situation in which (a) gap vs. clock time are identical metrics (e.g., situations where the starting stage has exiting transitions, like basic Cox or competing risk stage structures) and (b) whenmssample()
's specified starting time $\neq 0$.Problem's Source
The discrepency's stemming from these lines in
mssample1()
(lines 37–45):The first time a subject transitions represents the actual time at which that event occurs: a transition occurring at, e.g., $t = 7$ for clock is equivalent to a transition occurring at $t=7$ for gap (only possible if the start time's $<7$, of course).
Tstop
should therefore equal 7 for both metrics after the first transition in a basic Cox or CR setup.At present, that's not what will happen. To continue the running example,
Tstop
will correctly= 7
after the subject's first transition for clock time. However, for gap time,Tstop
will equal7 + tcond
.Earlier,
tcond
is defined as (mssample1()
, line 15):history$time
is the start time set by the user in the originalmssample()
call. If the start time is non-zero, the gap time'sTstop != 7
after the first transition.Seems like we shouldn't be adding
tcond
for a subject's first transition for a gap-time duration. (We do still need to addtcond
in gap time for any of the subject's subsequent transitions, though.)MWE
fake_CR.csv