我正在使用 Rstudio。我使用函数创建了列线图nomogram
从包装中rms
使用以下代码(从示例代码复制文档 http://www.inside-r.org/packages/cran/rms/docs/nomogram):
library(rms)
n <- 1000 # define sample size
set.seed(17) # so can reproduce the results
age <- rnorm(n, 50, 10)
blood.pressure <- rnorm(n, 120, 15)
cholesterol <- rnorm(n, 200, 25)
sex <- factor(sample(c('female','male'), n,TRUE))
# Specify population model for log odds that Y=1
L <- .4*(sex=='male') + .045*(age-50) +
(log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male'))
# Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)]
y <- ifelse(runif(n) < plogis(L), 1, 0)
ddist <- datadist(age, blood.pressure, cholesterol, sex)
options(datadist='ddist')
f <- lrm(y ~ lsp(age,50)+sex*rcs(cholesterol,4)+blood.pressure)
nom <- nomogram(f, fun=function(x)1/(1+exp(-x)), # or fun=plogis
fun.at=c(.001,.01,.05,seq(.1,.9,by=.1),.95,.99,.999),
funlabel="Risk of Death")
#Instead of fun.at, could have specified fun.lp.at=logit of
#sequence above - faster and slightly more accurate
plot(nom, xfrac=.45)
Result:
此代码生成列线图,但没有连接每个尺度(称为等值线)的线来帮助从图中预测所需的变量(“死亡风险”)。通常,列线图具有用于预测的等值线(维基百科的例子 https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Parallel_Scale_Nomogram.svg/400px-Parallel_Scale_Nomogram.svg.png)。但是在这里,我如何预测变量值呢?
EDIT:
从文档中:
列线图没有代表总和的线,但有
读取得分的参考线(默认范围 0--100)。一次
读者手动计算分数,预测值可以是
请阅读底部。
我不明白这一点。从点的比例来看,预测似乎应该在没有等值线的情况下完成。但如何呢?有人可以详细说明这个示例,说明如何读取列线图来预测所需的变量吗?多谢!
编辑2(仅供参考):
在赏金的描述中,我谈论的是等值线。当开始赏金时,我不知道nomogram
函数不提供等值线,而是提供点比例。