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 bayes.2S.

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 succ.min times (each time the acceptance rate is within acc.bounds.X), ensuring stability. Defaults to 3.

acc.bounds.X

A numeric vector of length two specifying the lower and upper bounds for the acceptable acceptance rate. Defaults to c(0.2, 0.25).

Details

Starting from an initial bayes.2S model object m, the function attempts to calibrate the standard deviation of the proposal distribution. Specifically, it:

  1. Runs an initial update of ndraws iterations and computes an acceptance rate.

  2. If the acceptance rate lies within acc.bounds.X, the number of MCMC draws ndraws is doubled, and the process repeats.

  3. Otherwise, the proposal standard deviation \sigma is adjusted based on whether the acceptance rate p is below the lower bound a or above the upper bound b of acc.bounds.X.

  4. 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)



[Package BayesPIM version 1.0.0 Index]