Calculates sensitivity, specificity and precision for ternary data (with -1 for negative effect, 0 for no effect, 1 for positive effect).
Value
Returns a vector of length 3 (with names "sensitivity", "specificity" and "precision") or a matrix with 3 rows (with names "sensitivity", "specificity" and "precision") and \(n\) columns.
Examples
#--- vector ---
p <- 20
truth <- sample(x=c(-1,0,1),size=p,replace=TRUE)
estim <- sample(x=c(-1,0,1),size=p,replace=TRUE)
table(truth,estim)
#> estim
#> truth -1 0 1
#> -1 0 1 5
#> 0 3 4 0
#> 1 4 3 0
count_vector(truth,estim)
#> sensitivity specificity precision
#> 0.0000000 0.5714286 0.0000000
#--- matrix ---
p <- 20
n <- 5
truth <- matrix(sample(x=c(-1,0,1),size=n*p,replace=TRUE),nrow=p,ncol=n)
estim <- matrix(sample(x=c(-1,0,1),size=n*p,replace=TRUE),nrow=p,ncol=n)
count_matrix(truth,estim)
#> [,1] [,2] [,3] [,4] [,5]
#> sensitivity 0.3 0.3076923 0.5454545 0.625 0.5454545
#> specificity 0.5 0.5714286 0.0000000 0.250 0.4444444
#> precision 0.3 0.4000000 0.3529412 0.625 0.4615385