Skip to content

misclassification rate

3 messages · Doussa, Patrick Breheny

#
Hi users
I'm student who is struggling with basic R programming. Would you please
help me with this problem.

"My english is bad" I hope that my question is clear:

I have a matrix in wich there are two colmns( yp, yt)
Yp: predicted values from my model.
yt: true values ( my dependante variable y is a categorical;3 modalities
(0,1,2)
I don't know how to procede to calculate the misclassification rate and the
error Types.

Thank you for answring

Doussa

--
View this message in context: http://r.789695.n4.nabble.com/misclassification-rate-tp3787075p3787075.html
Sent from the R help mailing list archive at Nabble.com.
#
On 09/02/2011 05:29 PM, Doussa wrote:
Suppose your data looks like this:

 > yp <- sample(0:2,50,replace=TRUE)
 > yt <- sample(0:2,50,replace=TRUE)

You can create a cross-classification table with:

 > tab <- table(yp,yt)
 > tab
    yt
yp   0  1  2
   0  5  8  5
   1  2 11  9
   2  1  2  7

And the misclassification rate is

 > 1-sum(diag(tab))/sum(tab)
[1] 0.54