代码拉取完成,页面将自动刷新
library(openxlsx)
library(ggplot2)
library(tidyverse)
library(MASS)#有序polr函数
library(nnet)#无序多分类multinom函数
library(brant)#检验有序logistic回归平行性
library(rms)#列线图
igadata1 <- read_xlsx("C:/Users/99405/Desktop/igar.xlsx")
igadata1$Lee氏分级合并<-factor(igadata1$Lee氏分级合并,levels=c(2,3,4))
igadata1$性别<-factor(igadata1$性别,levels=c(0,1))
igadata1$高血压<-factor(igadata1$高血压,levels=c(0,1))
igadata1$E内皮细胞<-factor(igadata1$E内皮细胞,levels=c(0,1))
igadata1$蛋白质<-factor(igadata1$蛋白质,levels=c(0,0.5,1,2,3))
igadata1$贫血四分类<-factor(igadata1$贫血四分类,levels=c(0,1,2,3))
igadata1$红细胞<-as.numeric(igadata1$红细胞)
igadata1$隐血<-factor(igadata1$隐血,levels=c(0,0.5,1,2,2.5,3))
#二分类logistic回归
model <- glm(E内皮细胞~ 贫血四分类+高血压+蛋白质+尿蛋白定量+肌酐+总蛋白+白蛋白, data = igadata1, family = "binomial")
#无序多分类logistic回归
model1 <- multinom(Lee氏分级合并~ 贫血四分类+高血压+蛋白质+尿蛋白定量+肌酐+总蛋白+白蛋白,data=igadata1)
model1
#有序多分类logistic回归
model <- polr(Lee氏分级合并~ 贫血四分类+高血压+蛋白质+尿蛋白定量+肌酐+总蛋白+白蛋白,data=igadata1)
brant(model)#平行性检验
#列线图
#二分类
dd<-datadist(igadata1)
options(datadist="dd")
formula1<-as.formula(E内皮细胞~ 贫血四分类+隐血+红细胞+尿蛋白定量+尿素+肌酐+总蛋白+白蛋白)
fit1<-lrm(formula1,data =igadata1,x=T,y=T)
fun1=function(x)1/(1+exp(-x))
g <- nomogram(fit1,fun=list('E内皮细胞增生'=fun1),fun.at = c(0.1,0.5,0.9),lp=F)
plot(g)
fit1
#有序
dd<-datadist(igadata1)
options(datadist="dd")
formula1<-as.formula(Lee氏分级合并~ 贫血四分类+性别+年龄+高血压+尿蛋白定量+肌酐+总蛋白+白蛋白)
fit1<-lrm(formula1,data =igadata1,x=T,y=T)
fun1 <- function(x) plogis(x-fit1$coef[1]+fit1$coef[1])
fun2 <- function(x) plogis(x-fit1$coef[1]+fit1$coef[2])
g <- nomogram(fit1,fun=list('Lee氏等级3'=fun1,'Lee氏等级4'=fun2),fun.at = c(0.1,0.5,0.9),lp=F)
plot(g)
fit1
dd<-datadist(igadata1)
options(datadist="dd")
formula1<-as.formula(T肾小管萎缩~ 贫血四分类+高血压+红细胞+尿蛋白定量+尿素+肌酐+总蛋白+白蛋白)
fit1<-lrm(formula1,data =igadata1,x=T,y=T)
fun1 <- function(x) plogis(x-fit1$coef[1]+fit1$coef[1])
fun2 <- function(x) plogis(x-fit1$coef[1]+fit1$coef[2])
g <- nomogram(fit1,fun=list('肾小管萎缩25%-50%'=fun1,'肾小管萎缩>75%'=fun2),fun.at = c(0.1,0.5,0.9),lp=F)
plot(g)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。