Check MCMC Convergence for Spatial Random Effects
check_mcmc.Rd
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).
Arguments
- object
An object of class
RiskMap
orRiskMap.pred.re
.RiskMap
is the output fromglgpm
function, andRiskMap.pred.re
is obtained from thepred_over_grid
function.- check_mean
Logical. If
TRUE
, checks the MCMC chain for the mean of the spatial random effects. IfFALSE
, checks the chain for a specific component of the random effects vector.- component
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 ifcheck_mean = TRUE
.- ...
Additional arguments passed to the
acf
function for customizing the ACF plot.
Details
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.
Author
Emanuele Giorgi e.giorgi@lancaster.ac.uk