hputter / mstate

https://hputter.github.io/mstate/
7 stars 5 forks source link

Msprep with one covariate #3

Closed hputter closed 3 years ago

hputter commented 4 years ago

E-mail dd Sep 24 2020 by Xuan Zhang,

Dear Prof. Putter,

I find your package “mstate” helpful. However, I noticed a possible issue about the function “msprep”: when only one variable was specified in argument keep, the resulting kept variable in the output data frame did not seem to be correct. Attached is a simple Rout file that illustrate the issue. In brief, the kept variable (e.g., group ID) does not match the corresponding subject ID. It would be great if you could have a look. Thanks!

Best, Xuan

Code: tg <- data.frame(id = 1:6, group_id = rep(1:3, 2), stt = rep(0, 6), sts = rep(0, 6), illt = c(1, 1, 6, 6, 8, 9), ills = c(1, 0, 1, 1, 0, 1), dt = c(5, 1, 9, 7, 8, 12), ds = c(1, 1, 1, 1, 1, 1)) tmat <- trans.illdeath()

issue occurs when only one variable was specified in keep

(keep should probably be sorted by ord1 in the source code)

msprep(time = c(NA, "illt", "dt"), status = c(NA, "ills", "ds"), data = tg, trans = tmat, keep = "group_id")

notice that the group_id of id 1 was not correct in row 3

similarly, the group_id of id 2 was incorrect in row 5 ...

hputter commented 3 years ago

Fixed in version 0.3.1

OdeHein commented 3 years ago

Dear Prof.,

As I can see, the issue is still present in the version 0.3.1.

Thanks.

edbonneville commented 3 years ago

Definitively fixed with pull request #12 .