Dear Dr. Putter,
I have been using the mstate package for years and am very glad for this great package. However, recently I had a problem when generating the output „data“ with the mssample function in a setting with a „clock reset“ approach and using history. To illustrate my problem, here is some code using a simple illness death model:
Haz <- data.frame(time = rep(seq(0, 9.9, 0.1), 3), Haz = rep(seq(0, 0.99, 0.01), 3), trans = rep(c(1,2,3), each = 100))
trans <- matrix(c(NA, 1, 2, NA, NA, 3, NA, NA, NA), ncol = 3, byrow = T)
alt <- mstate::mssample(Haz = Haz,
trans = trans,
history = list(time = 2, state = 1),
clock = "reset",
M = 100,
output = "data",
do.trace = 100)
table(alt$Tstop[alt$trans==1])
table(alt$duration[alt$trans==1])
It seems that the minimum simulated duration in the first state is the history time. As far as I understand the history setting, a history state 1 and time 2 means that the patient is still in state 1 at 2 time units after entering this state. Thus, it seems to me that there is no reason, why a patient should not enter another state earlier than time 4.
To tackle this problem, I had a look into the code and think I located the problem in the function mssample1. I replaced the line
tcond <- t0 <- Tstart <- history$time
by the lines
tcond <- 0
t0 <- Tstart <- history$time
and think this solved my problem. However, I am still not sure, if I understood anything completely wrong and have of course not tested, how this adjustment will influence other settings.
Thanks in advance and best regards,
Michael
Dear Dr. Putter,
I have been using the mstate package for years and am very glad for this great package. However, recently I had a problem when generating the output „data“ with the mssample function in a setting with a „clock reset“ approach and using history. To illustrate my problem, here is some code using a simple illness death model:
Haz <- data.frame(time = rep(seq(0, 9.9, 0.1), 3), Haz = rep(seq(0, 0.99, 0.01), 3), trans = rep(c(1,2,3), each = 100))
trans <- matrix(c(NA, 1, 2, NA, NA, 3, NA, NA, NA), ncol = 3, byrow = T)
alt <- mstate::mssample(Haz = Haz,
trans = trans,
history = list(time = 2, state = 1),
clock = "reset",
M = 100,
output = "data",
do.trace = 100)
table(alt$Tstop[alt$trans==1])
table(alt$duration[alt$trans==1])
It seems that the minimum simulated duration in the first state is the history time. As far as I understand the history setting, a history state 1 and time 2 means that the patient is still in state 1 at 2 time units after entering this state. Thus, it seems to me that there is no reason, why a patient should not enter another state earlier than time 4.
To tackle this problem, I had a look into the code and think I located the problem in the function mssample1. I replaced the line
tcond <- t0 <- Tstart <- history$time
by the lines
tcond <- 0
t0 <- Tstart <- history$time
and think this solved my problem. However, I am still not sure, if I understood anything completely wrong and have of course not tested, how this adjustment will influence other settings.
Thanks in advance and best regards,
Michael