I have a logistic model, and I want to plot a nomogram using the rms
package. But when a use the same formula with the lrm
function it throws an error:
Error in if (x) { : argument is not interpretable as logical In addition: Warning message: In if (x) { : the condition has length > 1 and only the first element will be used
The code I used is
library(rms)
tardata=final_data[,c(“delirium”,“brain_artery_dis”,“hbp”,“ageL60”,“firstMVtime”,“OPTIME”,“hb100”,“ne”,“heartFunc”,“varMBP”)]
tardata=na.omit(tardata)
dd<-datadist(tardata)
options(datadist=‘dd’)
summary(glm(delirium~ageL60+firstMVtime+OPTIME+hb100+ne+heartFunc+varMBP,data = tardata,family = binomial()))
fit1<-lrm(delirium~ageL60+firstMVtime+OPTIME+hb100+ne+heartFunc+varMBP,data = tardata,x=T,y=T)
tardata
is a dataframe with no NA values.
The str(tardata) is
‘data.frame’: 3397 obs. of 10 variables:
delirium : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
brain_artery_dis: logi TRUE TRUE TRUE FALSE TRUE TRUE …
hbp : logi FALSE TRUE TRUE FALSE TRUE TRUE ...
ageL60 : logi TRUE TRUE FALSE TRUE TRUE FALSE …
firstMVtime : num 1200 370 730 990 890 490 320 570 545 590 ...
OPTIME : num 5.5 3.08 3.33 4.67 4.92 …
hb100 : logi FALSE FALSE TRUE FALSE FALSE TRUE ...
ne : logi TRUE FALSE FALSE FALSE TRUE FALSE …
heartFunc : num 3 3 3 3 3 3 3 2 3 3 ...
varMBP : num 740.9 41.8 283.3 194.3 76.3 …
Any comments will be appreciated. Thanks.