r - In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL' -
i trying use auc package
in r specificity. not work. got warning messages:
1: in is.na(x) : is.na() applied non-(list or vector) of type 'null' 2: in is.na(e2) : is.na() applied non-(list or vector) of type 'null' 3: in is.na(e2) : is.na() applied non-(list or vector) of type 'null'
this command used
specificity(p_hat0[,3], dnew$outcome[dnew$visitmse==0]) $cutoffs [1] 1.00000000 1.00000000 0.97727273 0.95454545 0.93181818 0.90909091 [7] 0.88636364 0.86363636 0.84090909 0.81818182 0.79545455 0.77272727 [13] 0.75000000 0.72727273 0.70454545 0.68181818 0.65909091 0.63636364 [19] 0.61363636 0.59090909 0.56818182 0.54545455 0.52272727 0.50000000 [25] 0.47727273 0.45454545 0.43181818 0.40909091 0.38636364 0.36363636 [31] 0.34090909 0.31818182 0.29545455 0.27272727 0.25000000 0.22727273 [37] 0.20454545 0.18181818 0.15909091 0.13636364 0.11363636 0.09090909 [43] 0.06818182 0.04545455 0.02272727 0.00000000 $measure [1] nan na na na na na na na na na na na na na na na na na na [20] na na na na na na na na na na na na na na na na na na na [39] na na na na na na na 0 attr(,"class") [1] "auc" "specificity" warning messages: 1: in is.na(x) : is.na() applied non-(list or vector) of type 'null' 2: in is.na(e2) : is.na() applied non-(list or vector) of type 'null' 3: in is.na(e2) : is.na() applied non-(list or vector) of type 'null'
the predictions , labels are:
dnew$outcome [1] 1 1 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 [38] 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0 [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 [112] 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 > p_hat0[,3] [1] 0.1676221 0.5666334 0.5520391 0.3845506 0.5369669 0.4210906 0.6804216 [8] 0.6000813 0.4258318 0.5299374 0.5847862 0.6261463 0.6789501 0.5840120 [15] 0.5413866 0.6426050 0.2822611 0.6945680 0.5959189 0.5231346 0.7052698 [22] 0.5514049 0.7207629 0.6405132 0.1620128 0.7349927 0.5567275 0.6423642 [29] 0.6075940 0.8023867 0.5030725 0.5373831 0.5846428 0.6648525 0.5833133 [36] 0.4888089 0.6430406 0.5713645 0.5366524 0.6193379 0.6407926 0.6624230 [43] 0.6429118 0.6719707
could please tell me why measures nan or na
? thanks
based on description ?specificity
, labels
factor
class.
labels: factor of observed class labels (responses) allowed values {0,1}.
using 'churn' data auc
having factor
'labels', specificity
doesn't return warnings.
library(auc) data(churn) res1 <- specificity(churn$predictions,churn$labels)
if change 'labels' numeric
class
res2 <- specificity(churn$predictions,as.numeric(churn$labels)) #warning messages: #1: in is.na(x) : is.na() applied non-(list or vector) of type 'null' #2: in is.na(e2) : is.na() applied non-(list or vector) of type 'null' #3: in is.na(e2) : is.na() applied non-(list or vector) of type 'null'
so, probably, changing op's 'outcome' column 'factor' may work (assuming lengths same)
specificity(p_hat0[,3], factor(dnew$outcome[dnew$visitmse==0]))
Comments
Post a Comment