"Error in 2:last_model_number_predictors : argument of length 0"

Hi everyone, I have been trying to use the "lrm command" from the "rms package" to do logistic regression with clustered robust standard errors and report the results in APA format using the apa.reg.table command. But I get this error message: "Error in 2:last_model_number_predictors : argument of length 0". Can someone help me with diagnosing it?

Code in R Markdown:

library(apaTables)
fit1 <- lrm(recall ~ Population+NoComplaintsReported+NoInjuryIncidentsReported+NoCrashesFiresReported+NoInjuriesReported,x=TRUE, y=TRUE, data=df_clean)

Model1 <- robcov(fit1, cluster=df_clean$label)

apa.reg.table(Model1,filename="NHTSA-HT-2022-datacleaning-v8.docx", table.number=2)

My code creates both the fit1 and Model1 objects, and I get the error when during the apa.reg.table command. I installed the library(apaTables) today.

Try giving apa.reg.table to lm object like fit1 and check

Thank you Glane, I have tried that. It generates the same error message. This version again generates the same error message:

library(apaTables)
fit1 <- lrm(recall ~ Population+NoComplaintsReported+NoInjuryIncidentsReported+NoCrashesFiresReported+NoInjuriesReported,x=TRUE, y=TRUE, data=df_clean)

Model1 <- robcov(fit1, cluster=df_clean$label)

apa.reg.table(fit1,filename="NHTSA-HT-2022-datacleaning-v8.docx", table.number=2)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.