R/GOA.R

Defines functions GOA GOA.coMa print.GOA

Documented in GOA GOA.coMa

#' @export
GOA<- function(object, alpha){
  UseMethod("GOA",object)
}

#' @name GOA
#' @title Inference of the statistic Overall Accuraccy
#' @description General function that groups the inference of the statistic Overal Accuraccy. This function is made up of:
#' the statistic Overal Accuraccy for a particular classified image/map is then calculated by dividing the sum of the entries that form the major diagonal (i.e., the number of correct classifications) by the total number of samples taken,
#' the Overal Accuraccy variance and
#' the confidence interval for Overal Accuraccy statistic to confidence level 95 \% by default.
#' @usage GOA(object, alpha)
#' @param object a coMa object (confusion matrix object)
#' @param alpha Significance level
#' @details The method is to divide the sum of the major diagonal by the total number of the sample.
#' @return \code{GOA} returns a list with the following elements:
# #' \item{Statistic OA - the value of the statistic Overall Accuraccy.}
# #' \item{Overal Accuraccy variance}
# #' \item{Confidence intervals - the confidence interval for Overal Accuraccy statistic to confidence level 95% by default.}
#' @references
#' Story, M., & Congalton, R. G. (1986).
#' \emph{Accuracy assessment: A user's perspective.}
#' Photogrammetric Engineering and Remote Sensing, 52, 397-399.
#' @examples
#' #Let evaluate the inference of statistic Tau.
#' ## 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)))
#' ## Inference of statistic Overall Accuraccy
#' InfOA <- GOA(x, 0.02) # By default alpha = 0.05
#' @export

#Funcion general que agrupa la inferencia sobre el estadistico oa
GOA.coMa <- function(object, alpha = 0.05){

  if (!inherits(object,"coMa"))
    stop("object must be a coMa object")
  x<-object$data
  N <- sum(x)

  OA <- sum(diag(x))/N
  Var.OA <- OA*(1-OA)/N
  Ic1 <- OA - qnorm(1 - alpha/2)*sqrt(Var.OA)
  Ic2 <- OA + qnorm(1 - alpha/2)*sqrt(Var.OA)
  IC <- c(Ic1, Ic2)


  ans <- list(
    OAccuracy = OA,
    Variance.OAccuracy = Var.OA,
    Confidence.Interval = IC)
  class(ans)<-"GOA"
  return(ans)
}


#' @method print GOA
#' @export
print.GOA<-function(x, ...){
  function (x, ...){
    if (!inherits(x, "GOA")){
      stop("x not is a coMa object")
    }else{
      cat("Object class coMa\n")
      cat("GOA\n")
    }
  }
}
ujaen-statistics/ThemAAs documentation built on Nov. 5, 2019, 11:03 a.m.