[R] sensitivity and specificity
MacQueen, Don
macqueen1 at llnl.gov
Fri Apr 25 20:26:23 CEST 2014
Try this:
> sens <- function(ct) { ct[2,2] / sum(ct[,2]) }
> spec <- function(ct) { ct[1,1] / sum(ct[,1]) }
>
>
> myt <- matrix( c(1427,271,110,166), ncol=2)
>
> sens(myt)
[1] 0.6014493
>
> spec(myt)
[1] 0.8404005
>
-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 4/25/14 10:58 AM, "Si Qi L." <liusiqi.nine at gmail.com> wrote:
>Hi guys,
>
>I will be very grateful if you guys can do me a little favor on R. I am
>calculating the sensitivity and specificity for a 2*2 matrix, such as
>
> t
> 0 1
> 0 1427 110
> 1 271 166
>
>
>
>My codes are: sens <- function(ct) { ct[2,2] / sum(ct[,2]) }
> spec <- function(ct) { ct[1,1] / sum(ct[,1]) }
>
>But it doesn't show any numerical results. Would you please help me to fix
>it? Mnay thanks for your help.:)
>
>Best regards,
>
>Siqi
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list