This function checks the Markov Chain Monte Carlo (MCMC) convergence of spatial random effects
for either a RiskMap or RiskMap.pred.re object.
It plots the trace plot and autocorrelation function (ACF) for the MCMC chain
and calculates the effective sample size (ESS).
check_mcmc(object, check_mean = TRUE, component = NULL, ...)No return value, called for side effects (plots and warnings).
An object of class RiskMap or RiskMap.pred.re.
RiskMap is the output from glgpm function, and
RiskMap.pred.re is obtained from the pred_over_grid function.
Logical. If TRUE, checks the MCMC chain for the mean of the spatial random effects.
If FALSE, checks the chain for a specific component of the random effects vector.
Integer. The index of the spatial random effects component to check when check_mean = FALSE.
Must be a positive integer corresponding to a location in the data. Ignored if check_mean = TRUE.
Additional arguments passed to the acf function for customizing the ACF plot.
Emanuele Giorgi e.giorgi@lancaster.ac.uk
The function first checks that the input object is either of class RiskMap or RiskMap.pred.re.
Depending on the value of check_mean, it either calculates the mean of the spatial random effects
across all locations for each iteration or uses the specified component.
It then generates two plots:
- A trace plot of the selected spatial random effect over iterations.
- An autocorrelation plot (ACF) with the effective sample size (ESS) displayed in the title.
The ESS is computed using the ess function, which provides a measure of the effective number
of independent samples in the MCMC chain.
If check_mean = TRUE, the component argument is ignored, and a warning is issued.
To specify a particular component of the random effects vector, set check_mean = FALSE and provide
a valid component value.