search.prop.sd {BayesPIM} | R Documentation |
Automated Heuristic Search of a Proposal Standard Deviation for bayes.2S
Description
The bayes.2S Gibbs sampler uses a Metropolis step for sampling the incidence model parameters and requires specifying a standard deviation for the normal proposal (jumping) distribution. This function uses a heuristic algorithm to find a proposal distribution standard deviation such that the Metropolis sampler accepts proposed draws at an acceptance rate within the user-defined interval (by default around 20–25%).
Usage
search.prop.sd(m, ndraws = 1000, succ.min = 3, acc.bounds.X = c(0.2, 0.25))
Arguments
m |
A model object of class |
ndraws |
Starting number of MCMC iterations after which the acceptance rate is first evaluated. Defaults to 1000. |
succ.min |
The algorithm doubles the number of MCMC draws |
acc.bounds.X |
A numeric vector of length two specifying the lower and upper
bounds for the acceptable acceptance rate. Defaults to |
Details
Starting from an initial bayes.2S
model object m
, the function
attempts to calibrate the standard deviation of the proposal distribution.
Specifically, it:
Runs an initial update of
ndraws
iterations and computes an acceptance rate.If the acceptance rate lies within
acc.bounds.X
, the number of MCMC drawsndraws
is doubled, and the process repeats.Otherwise, the proposal standard deviation
\sigma
is adjusted based on whether the acceptance ratep
is below the lower bounda
or above the upper boundb
ofacc.bounds.X
.The formula for adjustment is:
\sigma \leftarrow \sigma \times (1 - \frac{ (a-p)}{a}) \quad\text{if } p < a, \quad \sigma \leftarrow \sigma \times (1 + \frac{ (p-b)}{b}) \quad\text{if } p > b.
By default, if the acceptance rate falls within [0.2, 0.25]
, that \sigma
is considered acceptable, and the process continues until succ.min
consecutive
successes (doubles) are achieved.
Value
A list
with the following elements:
prop.sd.X
The final (adjusted) proposal standard deviation.
ac.X
The acceptance rate in the last iteration.
Examples
# Generate data according to Klausch et al. (2025) PIM
set.seed(2025)
dat = gen.dat(kappa = 0.7, n = 1e3, theta = 0.2,
p = 1, p.discrete = 1,
beta.X = c(0.2, 0.2), beta.W = c(0.2, 0.2),
v.min = 20, v.max = 30, mean.rc = 80,
sigma.X = 0.2, mu.X = 5, dist.X = "weibull",
prob.r = 1)
# An initial model fit with a moderate number of ndraws (e.g., 1e3)
mod = bayes.2S(
Vobs = dat$Vobs, Z.X = dat$Z, Z.W = dat$Z, r = dat$r,
kappa = 0.7, update.kappa = FALSE, ndraws = 1e3, chains = 2,
prop.sd.X = 0.005, parallel = TRUE, dist.X = "weibull"
)
# Running the automated search
search.sd <- search.prop.sd(m = mod)
print(search.sd)