weixin_58354609
2022-04-09 21:11
采纳率: 0%
浏览 25

R语言Logstic回归分析制作nomogram

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

library(rms)
setwd("D:\202202Nomogram")
read.csv("vascular.csv")

vascular <- read.csv("vascular.csv")
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"))
Hypertension_Grade<-factor(vascular$HTN,levels = c(0,1,2,3),labels = c("No","Grade1","Grader2","Grade3"))
Diabetes<-factor(vascular$DM,levels = c(0,1),labels = c("No","Yes"))
Stage<-factor(vascular$STAGE,levels = c(1,2),labels = c("Early","Middle-Advanced"))
Neochemotherapy<-factor(vascular$NCT,levels = c(0,1),labels = c("No","Yes"))
Preoperative_radiation_therapy<-factor(vascular$PRT,levels = c(0,1),labels = c("No","Yes"))
Flap_type<-factor(vascular$FLAP.TYPE,levels = c(1,2,3),labels = c("ALT","RFAF","DIEAP"))

ddist <- datadist(vascular)
options(datadist='ddist')
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)

错误的图像

img

img

#谢谢!

1条回答 默认 最新

相关推荐 更多相似问题