# [R] how to use confusionMatrix function in solving multi-classes problem

Boris Steipe boris.steipe at utoronto.ca
Sun Dec 13 21:18:05 CET 2015

```This looks like homework to me and this list has a No-Homework policy. Now, once you have done your homework (and that includes reading the documentation of the functions you are using), and you are still confused about details, you are welcome to ask again. Please keep the following in mind:

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
... and definitely read the posting guide for this list and don't post in HTML.

B.

On Dec 13, 2015, at 5:02 AM, Hamed Nofal <hamednofal85 at gmail.com> wrote:

> Dear Colleagues
> I need someone to kindly help me solving this problem.
> A sample of 89 patients was tested for 4 tumor types (T1, T2, T3, T4).
> The results of the operative predicted T stage and those of the pathology
> tests are tabulated in the following table:
>
>     .------------.-----------------------------------------------.
>     .            .     Operative predicted T stage  .
>     .            ------------------------------------------------.
>     . Pathology  .    T1   .   T2  .   T3      T4  .
>     .------------.----------------------------------------------.
>     .    T1      .        1   .      0  .     0  .     0 .
>     .------------.---------------------------------------------.
>     .    T2      .        0   .     24 .     2  .     0 .
>     .------------.--------------------------------------------.
>     .    T3      .        0   .     1  .     49       3 .
>     .------------.--------------------------------------------.
>     .    T4      .        0   .     0  .       0  .    9 .
>     .-----------------------------------------------------------
>
> I need to calculate the sensitivity, specificity,accuracy,positive and
> negative prediction values, p-value and kappa value of these tests.
> I tried to convert the tabulated results into a two-class (0,1) table and
> use the function (confusionMatrix) taking the pathology results as the
> (goldstandard), but unfortunately,I got unreasonable output. Most
> probably,I used the function wrongly.
>
> Thank you and regards
>
> Hamed
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help