i have following table want analyze using confusionmatrix
:
value<-cbind(c(rnorm(100,500,90),rnorm(100,800,120))) genotype<-cbind(c(rep("a",100),rep("b",100))) df<-cbind(value,genotype) df<-as.data.frame(df) colnames(df)<-c("value","genotype") df$value<-as.numeric(as.character(df$value)) table(value>600,genotype)
i want analyze output sensitivities , specificities confusionmatrix
not work:
confusionmatrix(table(value>600,genotype))
any thoughts if i'm doing wrong?
if @ table, you'll see it's not in right format. row , column labels should same, aren't in case.
tab = table(value>600,genotype) tab genotype b false 83 6 true 17 94
when run confusionmatrix
, therefore error due different row , column labels (that's error message telling you):
confusionmatrix(tab)
error in !all.equal(rownames(data), colnames(data)) : invalid argument type
normally, create confusion matrix, should have column of predicted labels , column of reference labels (the true values), i'm not sure table you've created meaningful confusion matrix. in case, show right formatting table, let's change row labels same column labels. function work:
dimnames(tab)[[1]] = c("a","b") tab genotype b 83 6 b 17 94 confusionmatrix(tab)
confusion matrix , statistics genotype b 83 6 b 17 94 accuracy : 0.885 95% ci : (0.8325, 0.9257) no information rate : 0.5 p-value [acc > nir] : < 2e-16 kappa : 0.77 mcnemar's test p-value : 0.03706 sensitivity : 0.8300 specificity : 0.9400 pos pred value : 0.9326 neg pred value : 0.8468 prevalence : 0.5000 detection rate : 0.4150 detection prevalence : 0.4450 balanced accuracy : 0.8850 'positive' class :
Comments
Post a Comment