Thank you. Everything looks good but just as a matter of formatting, next time can you paste code between
```
```
It makes reading the code much easier.
I am not familiar with {rms} though I have been a fan of {Hmisc} for years.
Anyway I think* you have two issues.
The first is that {rms} has its own form of regression equation ols() rather than the base lm(). It looks like you need to do
model <- ols(VCD ~ VIB + Glucose + Lactate + NH4, data = dat1)
Second, I cannot see where
type = "terms"
comes from. I do not see it in the nomogram function (See ?nomogram)
This appears to work. Note, I changed your data.frame name to "dat1". data is a function name and occasionally using it as a variable name causes problems.
library(Hmisc)
library(rms)
set.seed(123)
dat1 <- data.frame(
VCD = runif(100, 0, 10),
VIB = runif(100, 0, 10),
Glucose = runif(100, 0, 10),
Lactate = runif(100, 0, 10),
NH4 = runif(100, 0, 10)
)
#Create a datadist object
dd <- datadist(dat1)
options(datadist = 'dd')
#Linear model without splines
model <- ols(VCD ~ VIB + Glucose + Lactate + NH4, data = dat1)
# print(summary(model))
# Create the nomogram, specifying 'type'
nom <- nomogram(model, fun = function(x)1/(1+exp(-x)),
lp = TRUE, funlabel = "Probability of High VCD")
plot(nom)