R/stat_array.R

#' Format the summary statistics of a parameter
#'
#' Extracts and organizes calculated statistics for a given parameter, 
#' including parameters that are vectors and arrays.
#' 
#' @param output An object of class \code{jagsUI}.
#' @param parameter A parameter that was saved in the output samples.
#' @param stat One of the statistics calculated on \code{jagsUI} output 
#'  (e.g. "mean", "sd").
#'
#' @return An array with the same dimensions as the input parameter.
#' For example, if the chosen parameter was a 2x3 matrix, the result will
#' be a 2x3 array of mean values for the parameter elements.
#'
#' @export

stat_array <- function(output, parameter, stat){
  
  #Check input validity
  check_class(output)
  check_parameter(parameter, output$samples)
  check_stat(stat, output$summary)
  
  get_stat_array(parameter, stat, output$summary)
}
kenkellner/jagsUI2 documentation built on July 5, 2019, 9:38 a.m.