#' @export
GUPIs<- function(object){
UseMethod("GUPIs",object)
}
#' @name GUPIs
#' @title Global measures based on averages of indexes on the user and producer perspective
#' @description General function that groups global measures based on averages of indexes on the user and producer perspective. This function is made up of:
#' Average accuracy from producer's perspective, the average accuracy is an average of the accuracy of individual categories.
#' Average accuracy from user's perspective, the average accuracy is an average of the accuracy of individual categories. Because the individual categories can be the user's or the producer's accuracy, it can be computed in both ways accordingly.
#' Double average of user's and producer's perspective, is the average of the average accuracy from user's and producer's perspective.
#' Average of Hellden's mean accuracy index, is the arithmetic mean of Hellden's mean accuracy index.
#' Average of Short's mapping accuracy index, is the arithmetic mean of Short's mapping accuracy index.
#' Classification succes index, applies to all classes and gives an overall estimation of classification effectiveness.
#' Combined accuracy from producer's perspective, is the average of the overall accuracy and average accuracy.
#' Combined accuracy from user's perspective, is the average of the overall accuracy and average accuracy.
#' Combined accuracy from both user's and producer's perspectives, is the arithmetic mean of the overall accuracy and average of Hellden's mean accuracy index
#' @usage GUPIs(object)
#' @param object a coMa object (confusion matrix object)
#' @details Average accuracy from producer's perspective, is the sum of the diagonal values between its corresponding marginal (by colums) divided by the number of categories.
#' Average accuracy from user's perspective, is the sum of the diagonal values between its corresponding marginal (by rows) divided by the number of categories.
#' Double average of user's and producer's perspective, is the arithmetic mean of the average accuracy from user's and producer's perspective.
#' Classification succes index, is the sum of average accuracy from user's and producer's perspective less 1.
#' Combined accuracy from producer's perspective, is the arithmetic mean of the overall accuracy and Average accuracy from producer's perspective.
#' Combined accuracy from user's perspective, is the arithmetic mean of the overall accuracy and Average accuracy from user's perspective.
#' Combined accuracy from both user's and producer's perspectives,
#' @return \code{GUPIs} returns a list with the following elements:
# #' \item{Average accuracy from producer's perspective - the value of the average accuracy from
# #' producer's perspective.}
# #' \item{Average accuracy from user's perspective - the value of the average accuracy from
# #' user's perspective.}
# #' \item{Double average of user's and producer's perspective - the value of the double
# #' average of user's and producer's perspective}
# #' \item{Average of Hellden's mean accuracy index - the value of the average of Hellden's
# #' mean accuracy index}
# #' \item{Average of Short's mapping accuracy index - the value of the average of Short's
# #' mapping accuracy index}
# #' \item{Classification succes index - the value of the classification succes index}
# #' \item{Combined accuracy from producer's perspective - the value of the combined accuracy
# #' from producer's perspective}
# #' \item{Combined accuracy from user's perspective - the value of the combined accuracy from
# #' user's perspective}
# #' \item{Combined accuracy from both user's and producer's perspectives - the value of the
# #' combined accuracy from both user's and producer's perspectives}
#' @references
#' Fung, T., & LeDrew, E. (1988).
#' \emph{The determination of optimal threshold levels for change detection using various accuracy indices.}
#' Photogrammetric Engineering and Remote Sensing, 54, 1449-1454.
#' @references
#' Liu, Canran, Paul Frazier, y Lalit Kumar. (2007).
#' \emph{Comparative Assessment of the Measures of Thematic Classification Accuracy.}
#' Remote Sensing of Environment 107 (4): 606-616.
#' @references
#' Koukoulas, S., & Blackburn, G. A. (2001).
#' \emph{Introducing new indices for accuracy evaluation of classified images representing semi-natural woodland environments.}
#' Photogrammetric Engineering and Remote Sensing, 67, 499-510.
#' @examples
#' #Let evaluate averages of indexes on the user and producer perspective.
#' ## Confusion matrix included in Congalton and Green (2009), pg. 108.
#' x <- coMa(cbind(c(65,6,0,4),c(4,81,11,7),c(22,5,85,3),c(24,8,19,90)))
#' ## Averages of indexes on the user and producer perspective
#' Indexes <- GUPIs(x)
#' @export
#Funcion que agrupa el resto de medidas globales basadas en medias sobre ?ndices sobre la perspectiva de usuario y productor
GUPIs.coMa <- function(object){
if (!inherits(object,"coMa"))
stop("object must be a coMa object")
x<-object$data
Margcol <- colSums(x)
Margrow <- rowSums(x)
N = sum(x)
OA <- sum(diag(x))/N
aap = 1/sqrt(length(x)) * sum (diag(x)/Margcol)
aau = 1/sqrt(length(x)) * sum (diag(x)/Margrow)
daup = (aau + aap) / 2
amah = 1/sqrt(length(x)) * sum ((2*diag(x)) / (Margrow + Margcol))
ifelse (Margrow + Margcol - diag(x) == 0, stop ("/by 0"),"" )
amas = 1/sqrt(length(x)) * sum (diag(x) / (Margrow + Margcol - diag(x)))
CSI = aau + aap - 1
cap = (OA + aap) / 2
cau = (OA + aau) / 2
caup = (OA + amah) / 2
ans <- list(
Average.Accuracy.Producer = aap,
Average.Accuracy.User = aau,
DoubleAverage.User.Producer = daup,
Average.Hellden = amah,
Average.Short = amas,
Classification.Success.Index = CSI,
Combined.Accuracy.Producer = cap,
Combined.Accuracy.User = cau,
Combined.Accuracy.User.Producer = caup)
class(ans)<-"GUPIs"
return(ans)
}
#' @method print GKappa
#' @export
print.GUPIs<-function(x, ...){
function (x, ...){
if (!inherits(x, "GUPIs")){
stop("x not is a coMa object")
}else{
cat("Object class coMa\n")
cat("GKappa\n")
}
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.