我正在尝试将 msSurv 用于多状态建模问题,该问题着眼于个体向不同阶段的过渡。其中一部分是创建一个树对象,这是我认为我犯了一个错误但我不明白它是什么的地方。我将在此处包括最低限度的可行示例。
Nodes <- c("1", "2", "3", "4", "5", "6")
Edges <- list("1" = list(edges = c("2", "3", "4", "5", "6")),
"2" = list(edges = c("1", "3", "4", "5", "6")),
"3" = list(edges = c("1", "2", "4", "5", "6")),
"4" = list(edges = c("1", "2", "3", "5", "6")),
"5" = list(edges = c("3", "4", "6")),
"6" = list(edges = NULL))
treeobj <- new("graphNEL", nodes = Nodes, edgeL = Edges, edgemode = "directed")
fit3 <- msSurv(df, treeobj, bs = TRUE, LT = TRUE)
我得到的错误如下。
No states eligible for exit distribution calculation.
Entry distributions calculated for states 6 .
Error in bs.IA[, , j, b] : subscript out of bounds
可以找到有问题的数据集here .
真诚感谢任何帮助。
最佳答案
我可能误会了,但是您的 6 组没有 1-6 作为边,因此程序返回错误,因为本质上您是在说 6 与计算无关。关于解决方案,我认为 6 应该有边,因为在这一行中可能需要有边:"6"= list(edges = NULL))
关于r - 在 R 中使用 msSurv 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55913410/