用法如下
library(rms)
TotalPoints.rms(rd, fit, nom, kint = NULL)
首先载入rms包,rd为原始数据的data.frame,fit为构建列线图时候的函数,kint没录入过,示例如下
library(rms)
n <- 1000
set.seed(17)
d <- data.frame(age = rnorm(n, 50, 10),
blood.pressure = rnorm(n, 120, 15),
cholesterol = rnorm(n, 200, 25),
sex = factor(sample(c('female','male'), n,TRUE)))
d <- upData(d,
L = .4*(sex=='male') + .045*(age-50) +
(log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male')),
y = ifelse(runif(n) < plogis(L), 1, 0))
ddist <- datadist(d); options(datadist='ddist')
f <- lrm(y ~ lsp(age,50) + sex * rcs(cholesterol, 4) + blood.pressure,
data=d)
nom <- nomogram(f)
res<-TotalPoints.rms(rd = d,fit = f,nom = nom)
head(res)
结果
欢迎批评指正
网友评论