Skip to contents

A self-contained MCMC sampler (no external backend). Runs multiple seeded chains, supports explicit starting values and run continuation, assesses convergence with several checkers, and returns the posterior draws with diagnostics.

Usage

morie_bayes_lm(
  formula,
  data,
  prior_sd = 10,
  chains = 4L,
  iter = 2000L,
  warmup = 1000L,
  seed = 42L,
  starting_values = NULL,
  step = 0.1,
  check_convergence = TRUE,
  converge_threshold = 1.1,
  stop_on_convergence = FALSE,
  quiet = FALSE,
  verbose = FALSE
)

Arguments

formula

A model formula.

data

A data.frame.

prior_sd

Prior standard deviation on the regression coefficients (a single value, or a vector of length p). The meaning of this hyperparameter is the scale of the zero-mean Normal coefficient priors.

chains

Number of independent chains.

iter

Iterations per chain (post-warmup).

warmup

Warmup (burn-in) iterations.

seed

Base RNG seed; each chain uses seed + chain_index so chains differ by default.

starting_values

Optional numeric vector (length p + 1, the coefficients plus log-sigma) used as the starting state of every chain; or a list of such vectors, one per chain.

step

Metropolis proposal scale.

check_convergence

Whether to compute convergence diagnostics.

converge_threshold

R-hat threshold for declaring convergence.

stop_on_convergence

Stop early once converged.

quiet

Suppress warnings/progress.

verbose

Emit per-chain progress messages.

Value

A morie_bayes_fit object.

Examples

d <- data.frame(x = rnorm(50)); d$y <- 1 + 2 * d$x + rnorm(50)
fit <- morie_bayes_lm(y ~ x, d, chains = 2, iter = 500, warmup = 200)