Closed albertocarm closed 3 months ago
Since you do not wish to follow guidelines for posting minimal working examples I don't know how to help.
I'm so sorry I did it wrong. I have reduced the code to the essentials, added a simulated database, and after the model I include the functions that I can't make work. Thank you very much for your time and valuable support, Professor Harrell.
library(rms)
library(Hmisc)
library(rmsb)
data<- data.frame(HE6=as.integer(cut2(sample(1:100, 200, replace = TRUE),g=10)), Age = sample(1:85, 200, replace = TRUE), EORTC = sample(1:100, 200, replace = TRUE), cir=rbinom(200, 1,.5))
head(data)
dd<-datadist(data)
options(datadist='dd')
bsx <- blrm(HE6 ~ cir*rcs(Age,3)+ pol(EORTC),
~ cir*rcs(Age,3)+ pol(EORTC), cppo=function(y) y, data=data)
summary (bsx)
plot(summary(bsx))
newdata <- data.frame(cir=c(0,1), Age=53, EORTC= 75)
predict(bsx, newdata, type='fitted') #
ggplot (Predict (bsx), abbrev =TRUE , ylab=NULL) # ci out of range
exprob <- ExProb (bsx)
fun5<-function(x) exprob (x, y=5)
fun6<-function(x) exprob (x, y=6)
fun9<-function(x) exprob (x, y=9)
M <- Mean (bsx)
qu <-Quantile (bsx)
med <- function (lp) qu(.5 , lp)
nom.ord<- nomogram(bsx, fun=list(Mean=M, "Prob y>=5"=fun5,"Prob y >=6"=fun6, "Prob y>=9"=fun9), lp=F)
plot(nom.ord)
I downloaded the new version of rms/rmsb. The plot for partial effects now works fine. The function 'summary' works for the previous example, but not if more variables are added. For example:
data<- data.frame(HE6=as.integer(cut2(sample(1:100, 200, replace = TRUE),g=10)),
Age = sample(1:85, 200, replace = TRUE), EORTC = sample(1:100, 200, replace = TRUE),
linf=rbinom(200, 1,.5),
cir=rbinom(200, 1,.5))
bsx <- blrm(HE6 ~ cir*rcs(Age,3)+ pol(EORTC)+linf,
~ cir*rcs(Age,3)+ pol(EORTC), cppo=function(y) y, data=data)
summary (bsx)
plot(summary(bsx))
plot(summary (bsx, ycut=5))
The nomogram doesn't work either.
exprob <- ExProb (bsx)
fun5<-function(x) exprob (x, y=5)
fun6<-function(x) exprob (x, y=6)
fun9<-function(x) exprob (x, y=9)
M <- Mean (bsx)
qu <-Quantile (bsx)
med <- function (lp) qu(.5 , lp)
nom.ord<- nomogram(bsx, fun=list(Mean=M, "Prob y>=5"=fun5,"Prob y >=6"=fun6, "Prob y>=9"=fun9), lp=F)
plot(nom.ord)
I found several possible bugs while using the functions of the new rmsb package. I report the first one, summary(fit) or plot(summary(fit) does not seem to work in this example. Please check and see what you can do. Thank you.