Closed MetzgerSK closed 2 years ago
R: 4.1.3 64-bit, mstate: 0.3.2, survival: 3.3.1, Win11
For a Cox model with one transition, msfit throws the following error:
msfit
Error in hlp[, 1] : incorrect number of dimensions
Lines 300–303 are at fault. Those lines read:
varHaz <- data.frame(time = rep(untimes, n2 * (n2 + 1)/2), varHaz = varHaz, trans1 = rep(hlp[, 1], rep(nt, n2 * (n2 + 1)/2)), trans2 = rep(hlp[, 2], rep(nt, n2 * (n2 + 1)/2)))
trans1's code is the specific culprit, but trans2's code would throw the same error, if trans1 didn't exist:
trans1
trans2
Error in hlp[, 2] : incorrect number of dimensions
Turns out, hlp is a matrix when it's first created (lines 297–298):
hlp
Browse[2]> hlp [,1] [,2] [1,] 1 1 Browse[2]> str(hlp) int [1, 1:2] 1 1
If you run lines 300–303 at this point, they run fine.
The problem seems to be line 299. After you run this line, hlp becomes a vector:
Browse[2]> hlp [1] 1 1 Browse[2]> str(hlp) int [1:2] 1 1
If you run lines 300–303 after line 299, you now get Error in hlp[, 1]....
Error in hlp[, 1]...
See #15's MWE. The first msfit call in that example throws this error.
Solved by pull request #17 .
R: 4.1.3 64-bit, mstate: 0.3.2, survival: 3.3.1, Win11
Problem
For a Cox model with one transition,
msfit
throws the following error:Problem's Source
Lines 300–303 are at fault. Those lines read:
trans1
's code is the specific culprit, buttrans2
's code would throw the same error, iftrans1
didn't exist:Turns out,
hlp
is a matrix when it's first created (lines 297–298):If you run lines 300–303 at this point, they run fine.
The problem seems to be line 299. After you run this line,
hlp
becomes a vector:If you run lines 300–303 after line 299, you now get
Error in hlp[, 1]...
.MWE
See #15's MWE. The first
msfit
call in that example throws this error.