2022-04-09 21:11

# R语言Logstic回归分析制作nomogram

#本人在利用R语言作图，根据社区博客的指引写了代码，但是最终获得的图像有问题，且在制作校准曲线的地方报错了，想问一下是怎么回事？

library(rms)
setwd("D:\202202Nomogram")

vascular_crisis<-factor(vascular\$VC,levels = c(0,1),labels = c("No","Yes"))
Age_group<-factor(vascular\$AGE.GROUP,levels = c(1,2,3),labels = c("Youth","Middle","Elder"))
Age<-vascular\$AGE
Gender<-factor(vascular\$GENDER,levels = c(1,2),labels = c("Male","Female"))
Diabetes<-factor(vascular\$DM,levels = c(0,1),labels = c("No","Yes"))
Neochemotherapy<-factor(vascular\$NCT,levels = c(0,1),labels = c("No","Yes"))
Flap_type<-factor(vascular\$FLAP.TYPE,levels = c(1,2,3),labels = c("ALT","RFAF","DIEAP"))

f <- lrm(Vascular_crisis~.,data=vascular)
summary(f)

par(mgp=c(1.6,0.6,0),mar=c(2,2,2,2))
nomogram <- nomogram(f,fun=function(x)1/(1+exp(-x)),
fun.at = c(0.001,0.01,0.05,seq(0.1,0.9,by=0.1),0.95,0.99,0.999),
funlabel = "Risk",
lp=F,
conf.int = F,
abbrev = F)
plot(nomogram)

f.glm <- glm(Vascular_crisis~.,data=vascular,family = binomial(link = "logit"))
P1 <- predict(f.glm,type = 'response')
val.prob(P1,Vascular_crisis)

#谢谢！