This internal function computes the Metropolis acceptance decision for a set of MCMC proposals, using either hierarchical or non-hierarchical posterior evaluation. It returns updated log-posterior and log-likelihood values, as well as a logical vector indicating accepted proposals.
call_log_posterior_m(
proposal_mat,
prev_prms_mat,
prev_pis,
prev_lls,
level,
re_eval,
...
)A list with three elements:
pisA numeric vector of updated log-posterior values.
llsA numeric vector of updated log-likelihood values.
acceptA logical vector of length equal to the number of chains, indicating which proposals were accepted.
a numeric matrix of proposed parameter values. Each column corresponds to one chain; rows represent parameters.
a numeric matrix of current (previous) parameter values.
Must have the same dimensions as proposal_mat.
a numeric vector of current log-posterior values for each chain.
a numeric vector of current log-likelihood values for each chain.
a character string specifying the sampling level, either
"lower", "hyper", or "none". Determines whether to call
log_posterior_lower() or log_posterior_hyper().
logical. If TRUE, the log-posterior and log-likelihood for
the current parameters are re-evaluated.
Additional arguments passed to log_posterior_lower() or
log_posterior_hyper(), depending on the level.
This function implements a vectorized Metropolis acceptance step for
multiple MCMC chains simultaneously. The posterior is calculated using
either log_posterior_lower() for subject-level parameters or
log_posterior_hyper() for group-level parameters.
Log-posterior and log-likelihood values are only updated where proposals
were accepted. In cases where proposals yield invalid posteriors (i.e.,
NA), they are automatically rejected.