harrelfe / rms

Regression Modeling Strategies
https://hbiostat.org/R/rms
Other
172 stars 48 forks source link

lrm() error: Error in X[, mmcolnames, drop = FALSE] : subscript out of bounds #103

Open IsadoraBM opened 3 years ago

IsadoraBM commented 3 years ago

A single variable in the model is triggering the error so that if I remove it lrm runs fine. The str for the troublesome variable looks fine, it is already a factor (so not modeled as.factor(var) like in #25). Any ideas for troubleshooting the cause? glm() runs the full model without issue.

harrelfe commented 3 years ago

This information is insufficient for me to understand the issue. You did not even include the code that triggers the error. I suspect you have an expression in the model formula in a context where rms wants a simple variable. Otherwise please include a minimal working example.

jchariker commented 2 years ago

Hi Professor,

I am getting the same error with cph. I have the code and error below. Survival status is coded as 0 for no event and 1 for event. I notice that a continuous predictor does not lead to the error.

merged2$BMI<-factor(c("Normal", "Overweight", "Obese")) levels(merged2$BMI) [1] "Normal" "Obese" "Overweight" S <- Surv(merged2$Overall.Survival.Months, merged2$Overall.Survival.Status) f <- cph(S ~ merged2$BMI, x=TRUE, y=TRUE) Error in X[, mmcolnames, drop = FALSE] : subscript out of bounds

These are the versions I am using:

packageVersion("rms") [1] ‘6.2.0’ packageVersion("Hmisc") [1] ‘4.6.0’

Thanks for your help. JC

Deleetdk commented 2 years ago

Is this a tibble vs. base R data frame issue?