% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_samples_array.R
\name{generate_sample_array}
\alias{generate_sample_array}
\alias{get_mle_array}
\alias{get_parameters_array}
\alias{get_param_idx}
\alias{gen_sample_array}
\alias{get_ESS_diag}
\alias{calc_ess}
\title{Generate samples from a fitted ensemble model to get MCMC effective sample size diagnostics}
\usage{
generate_sample_array(fit)

get_mle_array(ex.fit, transformed_data, time)

get_parameters_array(ex.fit)

get_param_idx(arr, stan_name)

gen_sample_array(ex.fit, transformed_data, time)

get_ESS_diag(fit, only_voi = TRUE)

calc_ess(sammy)
}
\arguments{
\item{fit}{An \code{EnsembleFit} object.}

\item{ex.fit}{A named \code{numeric}.}

\item{transformed_data}{A \code{list} of transformed input data.}

\item{time}{A \code{numeric} specifying the time for which the ensemble model was run.}

\item{arr}{A \verb{named numeric}}

\item{stan_name}{A \code{character} object}

\item{only_voi}{A \code{logical} indicating whether only the effective sample size of the variables of interest should be returned. Default value is \code{TRUE}.}

\item{sammy}{An \code{array} of size the number of parameters \eqn{\times} \code{num_samples} \eqn{\times} \code{nchains}.}
}
\value{
\code{generate_sample_array} gives an array of size  \code{time * (MM + M + 2)*N} \eqn{\times} \code{num_samples} \eqn{\times} \code{nchains} where \code{M} is the number of simulators, \code{MM} is the number of drivers (usually 1), \code{N} is the number of variables of interest \code{num_samples} is the number of samples from the ensemble model for each chain and \code{nchains} is the number of chains in the \code{EnsembleFit} object.

\code{get_parameters_array} gives a \code{list} of ensemble parameters from the requested sample.

\code{get_mle_array} gives an array of size \code{time * (MM + M + 2)*N} \eqn{\times} \code{num_samples} \eqn{\times} \code{nchains}.

\code{gen_sample_array} gives a \code{list} of two arrays of dimensions \code{time * (MM + M + 2)*N} \eqn{\times} \code{num_samples} \eqn{\times} \code{nchains}

\code{get_ESS_diag} and \code{calc_ess} gives a list of length two containing \code{ESS_bulk} and \code{ESS_tail} which has the bulk effective sample size and the tail effective sample size. Each list is of dimensions \code{time} \eqn{\times} \code{(MM + M + 2)*N}.
}
\description{
Methods to generates samples of the latent variables from a fitted ensemble model in the same order as the MCMC and to calculate diagnostics effective sample size for the MCMC.
}
\details{
Effective sample size is calculated from these samples, only for the quantity of interest if desired.
}
\examples{
\donttest{
fit <- fit_ensemble_model(observations = list(SSB_obs, Sigma_obs),
               simulators = list(list(SSB_ewe, Sigma_ewe, "EwE"),
                                 list(SSB_fs,  Sigma_fs, "FishSUMS"),
                                 list(SSB_lm,  Sigma_lm, "LeMans"),
                                 list(SSB_miz, Sigma_miz, "Mizer")),
               priors = EnsemblePrior(4,
               ind_st_params = IndSTPrior(parametrisation_form = "lkj",
               var_params= list(1,1), cor_params = 10, AR_params = c(2, 2))))
get_ESS_diag(fit)
}
}
\seealso{
See \code{\link[=generate_sample]{generate_sample()}} for information about the sampling and \code{\link[posterior]{ess_bulk}} and \code{\link[posterior]{ess_tail}} for information about the effective sample size calculations.
}
