cobinreg | R Documentation |
Fit Bayesian cobin regression model under canonical link (cobit link) with Markov chain Monte Carlo (MCMC). It supports both fixed-effect only model
y_i \mid x_i \stackrel{ind}{\sim} cobin(x_i^T\beta, \lambda^{-1}),
for i=1,\dots,n
, and random intercept model (v 1.0.x only supports random intercept),
y_{ij} \mid x_{ij}, u_i \stackrel{ind}{\sim} cobin(x_{ij}^T\beta + u_i, \lambda^{-1}), \quad u_i\stackrel{iid}{\sim} N(0, \sigma_u^2)
for i=1,\dots,n
(group), and j=1,\dots,n_i
(observation within group). See dcobin for details on cobin distribution.
cobinreg(
formula,
data,
link = "cobit",
contrasts = NULL,
priors = list(beta_intercept_scale = 100, beta_scale = 100, beta_df = Inf),
nburn = 1000,
nsave = 1000,
nthin = 1,
MH = FALSE,
lambda_fixed = NULL
)
formula |
an object of class "formula" or a two-sided linear formula object describing both the fixed-effects and random-effects part of the model; see "lmer" |
data |
data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. |
link |
character, link function (default "cobit"). Only supports canonical link function "cobit" that is compatible with Kolmogorov-Gamma augmentation. |
contrasts |
an optional list. See the contrasts.arg of model.matrix.default. |
priors |
a list of prior hyperparameters. See Details |
nburn |
number of burn-in MCMC iterations. |
nsave |
number of posterior samples. Total MCMC iteration is nburn + nsave*nthin |
nthin |
thin-in rate. Total MCMC iteration is nburn + nsave*nthin |
MH |
logical, Metropolis-Hastings; experimental |
lambda_fixed |
logical, fixing lambda; experimental |
The prior setting can be controlled with "priors" argument. Prior for regression coefficients are independent normal or t prior centered at 0. "priors" is a named list of:
beta_intercept_scale, Default 100, the scale of the intercept prior
beta_scale, Default 100, the scale of nonintercept fixed-effect coefficients
beta_df, Default Inf, degree of freedom of t prior. If beta_df=Inf
, it corresponds to normal prior
lambda_grid, Default 1:70, candidate for lambda (integer)
lambda_logprior, Default p(\lambda)\propto \lambda \Gamma(\lambda+1)/\Gamma(\lambda+5)
, log-prior of lambda. Default choice arises from beta negative binomial distribution; (\lambda-1)\mid \psi \sim negbin(2,\psi), \psi\sim Beta(2,2)
.
if random intercept model, u ~ InvGamma(a_u,b_u) with
a_u, Default 1, first parameter of Inverse Gamma prior of u
b_u, Default 1, second parameter of Inverse Gamma prior of u
Returns list of
post_save |
a matrix of posterior samples (coda::mcmc) with nsave rows |
loglik_save |
a nsave x n matrix of pointwise log-likelihood values, can be used for WAIC calculation. |
priors |
list of hyperprior information |
nsave |
number of MCMC samples |
t_mcmc |
wall-clock time for running MCMC |
t_premcmc |
wall-clock time for preprocessing before MCMC |
y |
response vector |
X |
fixed effect design matrix |
if random effect model, also returns
post_u_save |
a matrix of posterior samples (coda::mcmc) of random effects |
Z |
random effect design matrix |
requireNamespace("betareg", quietly = TRUE)
library(betareg) # for dataset example
data("GasolineYield", package = "betareg")
# basic model
out1 = cobinreg(yield ~ temp, data = GasolineYield,
nsave = 2000, link = "cobit")
summary(out1$post_save)
plot(out1$post_save)
# random intercept model
out2 = cobinreg(yield ~ temp + (1 | batch), data = GasolineYield,
nsave = 2000, link = "cobit")
summary(out2$post_save)
plot(out2$post_save)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.