View source: R/fit_beta_nuts.R
| tulpa_nuts_beta | R Documentation |
Bayesian counterpart to tulpa_laplace_beta(). Routes the Beta GLM
through tulpa's full NUTS backend via the generic LikelihoodSpec
interface, sampling the precision phi jointly with the regression
coefficients on the log scale. NUTS performs exact marginalisation
over phi, replacing the Brent outer-opt in tulpa_laplace_beta()
and the deterministic nested-Laplace grid that would otherwise
integrate over the Beta dispersion.
Mean-precision parameterisation, default logit link:
y_i ~ Beta(mu_i * phi, (1 - mu_i) * phi) with
mu_i = 1 / (1 + exp(-eta_i)) and eta_i = X_i %*% beta.
tulpa_nuts_beta(
y,
X,
beta_prior = .tulpa_default_beta_prior("beta_nuts"),
log_phi_prior_sd = 3,
log_phi_init = 0,
control = list()
)
y |
Response vector, strictly in |
X |
Fixed-effects design matrix. |
beta_prior |
Fixed-effect prior as |
log_phi_prior_sd |
Prior SD on |
log_phi_init |
Starting value for |
control |
A named list of numerical / sampler knobs (statistical
arguments stay in the signature): |
A tulpa_fit object with:
draws – n_samples x (p + 1) matrix of post-warmup draws,
columns named from colnames(X) (falling back to beta[1] ... beta[p]) then log_phi.
means – posterior means.
phi_summary – posterior mean / median / quantiles of
phi = exp(log_phi).
accept_prob, divergent, treedepth, epsilon – NUTS
diagnostics from the underlying chain.
tulpa_laplace_beta() for the Laplace + Brent point
estimate; tulpa_laplace() for the underlying Laplace engine.
set.seed(1)
n <- 150L
X <- cbind(1, rnorm(n))
mu <- plogis(X %*% c(0.2, 0.7)); phi <- 8
y <- rbeta(n, mu * phi, (1 - mu) * phi)
fit <- tulpa_nuts_beta(y, X, control = list(n_iter = 500L, n_warmup = 250L))
colMeans(fit$draws)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.