harrelfe / rms

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

"nomogram" function dosn't work #145

Closed jijitoutou closed 2 weeks ago

jijitoutou commented 2 months ago

I use the example provided by this pacakge: `n <- 1000 # define sample size set.seed(17) # so can reproduce the results d <- data.frame(age = rnorm(n, 50, 10), blood.pressure = rnorm(n, 120, 15), cholesterol = rnorm(n, 200, 25), sex = factor(sample(c('female','male'), n,TRUE)))

Specify population model for log odds that Y=1

Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)]

d <- upData(d, L = .4(sex=='male') + .045(age-50) + (log(cholesterol - 10)-5.2)(-2(sex=='female') + 2*(sex=='male')), y = ifelse(runif(n) < plogis(L), 1, 0))

ddist <- datadist(d); options(datadist='ddist')

f <- lrm(y ~ lsp(age,50) + sex * rcs(cholesterol, 4) + blood.pressure, data=d) nom <- nomogram(f, fun=function(x)1/(1+exp(-x)), # or fun=plogis fun.at=c(.001,.01,.05,seq(.1,.9,by=.1),.95,.99,.999), funlabel="Risk of Death")`

Error: Here is the translation:

Error in reformulate(attr(termobj, "term.labels")[-dropx], response = if (keep.response) termobj[[2L]], : 'termlabels' must be a byte vector of length at least one.

Could you update this package to solve this issue? Thank you!

jijitoutou commented 2 months ago

The same error occurs when using other models, such as "cph" (cox).

santsang commented 1 month ago

This paper mentioned that they got it through applying another package. http://dx.doi.org/10.21037/atm.2017.07.27. However, I do not know whether it is specifically applicable to competing events using Cox regression. It would be interesting to the results of other's attempt.

harrelfe commented 2 weeks ago

This is a version mismatch between rms and R; I should have required a newer version of R for the latest rms on CRAN. Please update R and make sure you have the latest rms.