Teach you how to analyze NRI in R language

NRI (Net reclassification index) refers to the net reclassification index, which is used to compare the performance of the new and old models in the clinic. For example, we usually use ECG to evaluate myocardial infarction. Now there is a new index troponin, we want to know creatinine Protein combined with ECG is better for evaluating myocardial infarction or ECG alone. We know that after a model is established, a cut point can be generated to divide a population into positive and negative groups. After the establishment of the new model, the positive and negative groups must be different from the original model, and false positives and false negatives are also different. NRI is mainly compared It is the redistribution of true positives and true negatives of this type of population. I will not say the principle. No one else has said it well. See the picture below for explanation (picture from public account:
Insert picture description here
Unscrew ) NRI is currently in SCI papers Chinese applications are becoming more and more widely used. Today we mainly talk about how to use R language to make NRI, or use the breast cancer data that comes with our SPSS.
To make NRI in R language, nricens package and survival package need to be used, which need to be downloaded first. We first import the data and view the variables. The data is explained as follows:
age means age, pathsize means pathological tumor size (cm), lnpos means positive axillary lymph nodes, histgrad means histopathological grade, er means estrogen receptor status, pr means progesterone receptor status, status outcome event For death, pathscat represents the pathological tumor size category (grouping variable), ln_yesno represents whether there is lymph node enlargement, time is the survival time, and the following agec is set by ourselves, don't care about it.

library(nricens)
library(survival)
library(foreign)
bc <- read.spss("E:/r/test/Breast cancer survival agec.sav",
                use.value.labels=F, to.data.frame=T)
bc <- na.omit(bc)#删除缺失值

Insert picture description here
Insert picture description here
If we want to know the deaths in 48 months, that is, 4 years, we can perform COX regression analysis

names(bc)
time<-bc$time#生成时间变量
status<-bc$status#生成结局变量
j1<-as.matrix(subset(bc,select = c(age,pathsize,pr,er)))#旧模型变量,要以矩阵形式,不能有缺失值,不然会报错
j2<-as.matrix(subset(bc,select = c(age,pathsize,pr,er,ln_yesno))) #新模型变量,要以矩阵形式,不能有缺失值,不然会报错
mod.std<-coxph(Surv(time,status)~ .,data.frame(time, status,j1),x=TRUE)#生成旧模型COX回归函数
mod.new<-coxph(Surv(time,status)~ .,data.frame(time, status,j2),x=TRUE) #生成新模型COX回归函数
p.std = get.risk.coxph(mod.std, t0=48)#生成预测函数
p.new = get.risk.coxph(mod.new, t0=48)#生成预测函数
nricens(mdl.std = mod.std, mdl.new = mod.new, t0 = 48, cut = c(0.2, 0.4),
        niter = 100,alpha = 0.05,updown = 'category')#cut分临床切点,分为高中低风险,niter为重抽样次数,category为分类的意思,alpha为置信区间

Insert picture description here
Insert picture description here
Insert picture description here
We need to pay attention to the value of NRI+. It is a positive value. The new model is better than the old model. Finally, the generated chart
Insert picture description here
can also be processed according to categorical variables and generalized linear models. You must first set the time variable, and the outcome variable, and the others are basically the same

bc= bc[ bc$time > 48| (bc$time < 48 & bc$status == 1), ]#重新定义一下数据
status1= ifelse(bc$time < 48 & bc$status == 1, 1, 0)#重新定义下结局变量
j3<-as.matrix(subset(bc,select = c(age,pathsize,pr,er)))
j4<-as.matrix(subset(bc,select = c(age,pathsize,pr,er,ln_yesno)))
mstd1= glm(status1 ~ ., binomial(logit), data.frame(status1, j3), x=TRUE)
mnew1= glm(status1 ~ ., binomial(logit), data.frame(status1, j4), x=TRUE)
nribin(mdl.std=mstd1, mdl.new = mnew1, cut = c(0.2, 0.4),
       niter = 1000, updown = 'category')

Insert picture description here
Insert picture description here
Insert picture description here
For more exciting articles, please pay attention to the public number: zero-based research
Insert picture description here

Guess you like

Origin blog.csdn.net/dege857/article/details/113107587