[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

calculating correctly predicted



Did this with Raminta today, and did not want to forget, so I post
(and it gets remembered by the web page).

Suppse you calculate predictions--0 or 1, and compare against observations, 0 or 1.

THen you can make a cross classification table

mymat <- table( pred, observed)

For an example, I made up some phony data
> mymat
       pred
     [,1] [,2]
[1,]    1    3
[2,]    2    9

The percent correctly predicted can be calculated as the the ratio of the correctly predicted observations (the diagonal) to the entire sample:

sum(diag(mymat))/sum(mymat)


--
Paul E. Johnson                       email: pauljohn_AT_ku.edu
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
1541 Lilac Lane, Rm 504
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66044-3177           FAX: (785) 864-5700