在 R 中使用 predictABEL 包中的 plotCalibration() 的问题 [英] Problems with using plotCalibration() from the predictABEL package in R

查看:159
本文介绍了在 R 中使用 predictABEL 包中的 plotCalibration() 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 plotCalibration() 函数时遇到了一些麻烦,我以前设法让它工作,但最近在使用另一个数据集时 (这里是 .Rda 数据文件的链接),我一直无法摆脱不断出现的错误消息:

I’ve been having some trouble with the plotCalibration() function, I have managed to get it to work before, but recently whilst working with another dataset (here is a link to the .Rda data file), I have been unable to shake off an error message which keeps cropping up:

> plotCalibration(data = data, cOutcome = 2, predRisk = data$sortmort)

Error in plotCalibration(data = data, cOutcome = 2, predRisk = data$sortmort) : The specified outcome is not a binary variable.`

当我尝试将 cOutcome 列设置为因子或逻辑时,它仍然不起作用.

When I’ve tried to set the cOutcome column to factors or to logical, it still doesn’t work.

我查看了函数的源代码,唯一一次出现错误消息是在第一个 if()else{} 语句中:

I’ve looked at the source of the function and the only time the error message comes up is in the first if()else{} statement:

if (length(unique(y))!=2) {stop(" The specified outcome is not a binary variable.\n")} 
else{

但是我检查了length(unique(y))确实是==2,所以不明白为什么错误信息仍然出现!

But I have checked that the length(unique(y)) is indeed ==2, and so don’t understand why the error message still crops up!

推荐答案

使用你之前发送的数据,我没有看到任何错误:

Using the data you sent earlier, I do not see any error though:

以下输出与校准图一起产生:

Following output were produced along with a calibration plot:

> library(PredictABEL)
> plotCalibration(data = data, cOutcome = 2, predRisk = data$sortmort)
$Table_HLtest
               total meanpred meanobs predicted observed
[0.000632,0.00129)   340    0.001   0.000      0.31        0
0.001287             198    0.001   0.000      0.25        0
[0.001374,0.00201)   283    0.002   0.004      0.53        1
0.002009             310    0.002   0.000      0.62        0
[0.002505,0.00409)   154    0.003   0.000      0.52        0
[0.004086,0.00793)   251    0.006   0.000      1.42        0
[0.007931,0.00998)   116    0.008   0.009      0.96        1
[0.009981,0.19545]   181    0.024   0.011      4.40        2

$Chi_square

[1] 4.906

$df

[1] 8

$p_value

[1] 0.7676

这篇关于在 R 中使用 predictABEL 包中的 plotCalibration() 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆