You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a formula like "surv ~ factor(x)" produces the error X[, mmcolnames, drop = FALSE] : subscript out of bounds.
set.seed(10)
n <- 500
ds <- data.frame(
ftime = rexp(n),
fstatus = sample(0:1, size = n, replace = TRUE),
x = sample(LETTERS[1:4], size = n, replace = TRUE) )
library(rms)
dd <<- datadist(ds)
options(datadist="dd")
fit <- cph(Surv(ftime, fstatus) ~ factor(x), data=ds)
Passing an already-factored x works as expected. Not sure if this is the intended behavior, and/or the error message may be made more explicit. The debug argument clarified the problem.
> fit <- cph(Surv(ftime, fstatus == 1) ~ factor(x), data=ds,debug=T)
sformula
Surv(ftime, fstatus == 1) ~ factor(x)
colnames(X) mmcolnames Design colnames
[1,] "factor(x)B" "xB" "x=B"
[2,] "factor(x)C" "xC" "x=C"
[3,] "factor(x)D" "xD" "x=D"
Error in X[, mmcolnames, drop = FALSE] : subscript out of bounds
As described in issue 29, factor() was never supposed to work with rms. It only worked in the past by accident. Now it always fails. Make the variable a factor when constructing the dataset or use the scored() function in the model formula if the variable is ordered and might possibly have a linear effect.
Using a formula like "surv ~ factor(x)" produces the error
X[, mmcolnames, drop = FALSE] : subscript out of bounds
.Passing an already-factored
x
works as expected. Not sure if this is the intended behavior, and/or the error message may be made more explicit. Thedebug
argument clarified the problem.This may be analogous to #15 .
Thanks!
The text was updated successfully, but these errors were encountered: