| Title: | Cobin and Micobin Regression Models for Continuous Proportional Data |
|---|---|
| Description: | Provides functions for cobin and micobin regression models, a new family of generalized linear models for continuous proportional data (Y in the closed unit interval [0, 1]). It also includes an exact, efficient sampler for the Kolmogorov-Gamma random variable. For details, see Lee et al. (2026) <doi:10.1080/01621459.2026.2626081>. |
| Authors: | Changwoo Lee [aut, cre], Benjamin Dahl [aut], Otso Ovaskainen [aut], David Dunson [aut] |
| Maintainer: | Changwoo Lee <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.1.4 |
| Built: | 2026-05-13 09:06:28 UTC |
| Source: | https://github.com/changwoo-lee/cobin |
bft(x)bft(x)
x |
input vector |
.
When is canonical link of cobin, this is same as
bftprime(x) cobitlinkinv(x)bftprime(x) cobitlinkinv(x)
x |
input vector |
.
Calculates using numerical inversion (Newton-Raphson),
where .
This is the cobit link function g, the canonical link function of cobin.
bftprimeinv(y, x0 = 0, tol = 1e-08, maxiter = 100) cobitlink(y, x0 = 0, tol = 1e-08, maxiter = 100)bftprimeinv(y, x0 = 0, tol = 1e-08, maxiter = 100) cobitlink(y, x0 = 0, tol = 1e-08, maxiter = 100)
y |
input vector |
x0 |
Defult 0, initial value |
tol |
tolerance, stopping criterion for Newton-Raphson |
maxiter |
max iteration of Newton-Raphson |
used Taylor series expansion for x near 0 for stability
bftprimeprime(x)bftprimeprime(x)
x |
input vector |
used Taylor series expansion for x near 0 for stability
bftprimeprimeprime(x)bftprimeprimeprime(x)
x |
input vector |
Specifies the information required to fit a cobin generalized linear model with known lambda parameter, using glm().
cobinfamily(lambda = stop("'lambda' must be specified"), link = "cobit")cobinfamily(lambda = stop("'lambda' must be specified"), link = "cobit")
lambda |
The known value of lambda, must be integer |
link |
The link function to be used. Options are "cobit" (canonical link for cobin regression), "logit", "probit", "cauchit", "cloglog" |
An object of class "family", a list of functions and expressions needed by glm() to fit a cobin generalized linear model.
Fit Bayesian cobin regression model under canonical link (cobit link) with Markov chain Monte Carlo (MCMC). It supports both fixed-effect only model
for , and random intercept model (v 1.0.x only supports random intercept),
for (group), and (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 )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 , log-prior of lambda. Default choice arises from beta negative binomial distribution; .
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)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)
Continuous binomial distribution with natural parameter and dispersion parameter , in short , has density
where and .
When , it becomes continuous Bernoulli distribution.
dcobin(x, theta, lambda, log = FALSE)dcobin(x, theta, lambda, log = FALSE)
x |
num (length n), between 0 and 1, evaluation point |
theta |
scalar or length n vector, num (length 1 or n), natural parameter |
lambda |
scalar or length n vector, integer, inverse of dispersion parameter |
log |
logical (Default FALSE), if TRUE, return log density |
For the evaluation of , see ?cobin::dIH.
density of
xgrid = seq(0, 1, length = 500) plot(xgrid, dcobin(xgrid, 0, 1), type="l", ylim = c(0,3)) # uniform lines(xgrid, dcobin(xgrid, 0, 3)) plot(xgrid, dcobin(xgrid, 2, 3), type="l") lines(xgrid, dcobin(xgrid, -2, 3))xgrid = seq(0, 1, length = 500) plot(xgrid, dcobin(xgrid, 0, 1), type="l", ylim = c(0,3)) # uniform lines(xgrid, dcobin(xgrid, 0, 3)) plot(xgrid, dcobin(xgrid, 2, 3), type="l") lines(xgrid, dcobin(xgrid, -2, 3))
Irwin-Hall distribution is defined as a sum of m uniform (0,1) distribution. Its density is given as
The density of Bates distribution, defined as an average of m uniform (0,1) distribution, can be obtained from change-of-variable (y = x/m),
dIH(x, m, log = FALSE)dIH(x, m, log = FALSE)
x |
vector of quantities, between 0 and m |
m |
integer, parameter |
log |
logical, return log density if TRUE |
Due to alternating series representation, m > 80 may yield numerical issues
(log) density evaluated at x
m = 8 xgrid= seq(0, m, length = 500) hist(colSums(matrix(runif(m*1000), nrow = m, ncol = 1000)), freq = FALSE) lines(xgrid, dIH(xgrid, m, log = FALSE)) # Bates distribution xgrid= seq(0, 1, length = 500) hist(colMeans(matrix(runif(m*1000), nrow = m, ncol = 1000)), freq = FALSE) lines(xgrid, m*dIH(xgrid*m, m, log = FALSE))m = 8 xgrid= seq(0, m, length = 500) hist(colSums(matrix(runif(m*1000), nrow = m, ncol = 1000)), freq = FALSE) lines(xgrid, dIH(xgrid, m, log = FALSE)) # Bates distribution xgrid= seq(0, 1, length = 500) hist(colMeans(matrix(runif(m*1000), nrow = m, ncol = 1000)), freq = FALSE) lines(xgrid, m*dIH(xgrid*m, m, log = FALSE))
Micobin distribution with natural parameter and dispersion , denoted as , is defined as a dispersion mixture of cobin:
so that micobin density is a weighted sum of cobin density with negative binomial weights.
dmicobin(x, theta, psi, r = 2, log = FALSE, l_max = 70)dmicobin(x, theta, psi, r = 2, log = FALSE, l_max = 70)
x |
num (length n), between 0 and 1, evaluation point |
theta |
scalar or length n vector, natural parameter |
psi |
scalar or length n vector, between 0 and 1, dispersion parameter |
r |
(Default 2) This should be always 2 to maintain interpretaton of psi. It is kept for future experiment purposes. |
log |
logical (Default FALSE), if TRUE, return log density |
l_max |
integer (Default 70), upper bound of lambda. |
density of
hist(rcobin(1000, 2, 3), freq = FALSE) xgrid = seq(0, 1, length = 500) lines(xgrid, dcobin(xgrid, 2, 3))hist(rcobin(1000, 2, 3), freq = FALSE) xgrid = seq(0, 1, length = 500) lines(xgrid, dcobin(xgrid, 2, 3))
Find the maximum likelihood estimate of a cobin generalized linear model with unknown dispersion.
This is a modification of stats::glm to include estimation of the additional parameter,
lambda, for a cobin generalized linear model, in a similar manner to the MASS::glm.nb.
Note that MLE of regression coefficient does not depends on lambda.
glm.cobin( formula, data, weights, subset, na.action, start = NULL, etastart, mustart, control = glm.control(...), method = "glm.fit", model = TRUE, x = FALSE, y = TRUE, contrasts = NULL, ..., lambda_list = 1:70, link = "cobit", verbose = TRUE )glm.cobin( formula, data, weights, subset, na.action, start = NULL, etastart, mustart, control = glm.control(...), method = "glm.fit", model = TRUE, x = FALSE, y = TRUE, contrasts = NULL, ..., lambda_list = 1:70, link = "cobit", verbose = TRUE )
formula, data, weights, subset, na.action, start, etastart, mustart, control, method, model, x, y, contrasts, ...
|
arguments for the |
lambda_list |
(Default 1:70) an integer vector of candidate lambda values. Note that MLE of coefficient does not depends on lambda |
link |
character, link function. Default cobit. Must be one of "cobit", "logit", "probit", "cloglog", "cauchit". |
verbose |
logical, if TRUE, print the MLE of lambda. |
Since dispersion parameter lambda is discrete, it does not provide standard error of lambda. With cobit link, we strongly encourage Bayesian approaches, using cobin::cobinreg() function.
The object is like the output of glm but contains additional components, the ML estimate of lambda and the log-likelihood values for each lambda in the lambda_list.
requireNamespace("betareg", quietly = TRUE) library(betareg)# for dataset example data(GasolineYield, package = "betareg") # cobin regression, frequentist out_freq = glm.cobin(yield ~ temp, data = GasolineYield, link = "cobit") summary(out_freq) # cobin regression, Bayesian out = cobinreg(yield ~ temp, data = GasolineYield, nsave = 10000, link = "cobit") summary(out$post_save) plot(out$post_save)requireNamespace("betareg", quietly = TRUE) library(betareg)# for dataset example data(GasolineYield, package = "betareg") # cobin regression, frequentist out_freq = glm.cobin(yield ~ temp, data = GasolineYield, link = "cobit") summary(out_freq) # cobin regression, Bayesian out = cobinreg(yield ~ temp, data = GasolineYield, nsave = 10000, link = "cobit") summary(out$post_save) plot(out$post_save)
Fit Bayesian micobin regression model under canonical link (cobit link) with Markov chain Monte Carlo (MCMC). It supports both fixed-effect only model
for , and random intercept model (v 1.0.x only supports random intercept),
for (group), and (observation within group). See dmicobin for details on micobin distribution.
micobinreg( formula, data, link = "cobit", contrasts = NULL, priors = list(beta_intercept_scale = 100, beta_scale = 100, beta_df = Inf), nburn = 1000, nsave = 1000, nthin = 1, psi_fixed = NULL )micobinreg( formula, data, link = "cobit", contrasts = NULL, priors = list(beta_intercept_scale = 100, beta_scale = 100, beta_df = Inf), nburn = 1000, nsave = 1000, nthin = 1, psi_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 |
psi_fixed |
logical, fixing psi; 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_max, Default 70, upper bound for lambda (integer)
psi_ab, Default c(2,2), beta shape parameters for (length 2 vector).
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 = micobinreg(yield ~ temp, data = GasolineYield, nsave = 2000, link = "cobit") summary(out1$post_save) plot(out1$post_save) # random intercept model out2 = micobinreg(yield ~ temp + (1 | batch), data = GasolineYield, nsave = 2000, link = "cobit") summary(out2$post_save) plot(out2$post_save)requireNamespace("betareg", quietly = TRUE) library(betareg)# for dataset example data("GasolineYield", package = "betareg") # basic model out1 = micobinreg(yield ~ temp, data = GasolineYield, nsave = 2000, link = "cobit") summary(out1$post_save) plot(out1$post_save) # random intercept model out2 = micobinreg(yield ~ temp + (1 | batch), data = GasolineYield, nsave = 2000, link = "cobit") summary(out2$post_save) plot(out2$post_save)
Continuous binomial distribution with natural parameter and dispersion parameter , in short , has density
where and .
When , it becomes continuous Bernoulli distribution.
pcobin(q, theta, lambda)pcobin(q, theta, lambda)
q |
num (length n), between 0 and 1, evaluation point |
theta |
scalar, natural parameter |
lambda |
integer, inverse of dispersion parameter |
c.d.f. of
xgrid = seq(0, 1, length = 500) out = pcobin(xgrid, 1, 2) plot(ecdf(rcobin(10000, 1, 2))) lines(xgrid, out, col = 2)xgrid = seq(0, 1, length = 500) out = pcobin(xgrid, 1, 2) plot(ecdf(rcobin(10000, 1, 2))) lines(xgrid, out, col = 2)
Micobin distribution with natural parameter and dispersion , denoted as , is defined as a dispersion mixture of cobin:
so that micobin cdf is a weighted sum of cobin cdf with negative binomial weights.
pmicobin(q, theta, psi, r = 2, l_max = 70)pmicobin(q, theta, psi, r = 2, l_max = 70)
q |
num (length n), between 0 and 1, evaluation point |
theta |
scalar, natural parameter |
psi |
scalar, dispersion parameter |
r |
(Default 2) This should be always 2 to maintain interpretaton of psi. It is kept for future experiment purposes. |
l_max |
integer (Default 70), upper bound of lambda. |
c.d.f. of
xgrid = seq(0, 1, length = 500) out = pmicobin(xgrid, 1, 1/2) plot(ecdf(rmicobin(10000, 1, 1/2))) lines(xgrid, out, col = 2)xgrid = seq(0, 1, length = 500) out = pmicobin(xgrid, 1, 1/2) plot(ecdf(rmicobin(10000, 1, 1/2))) lines(xgrid, out, col = 2)
Continuous binomial distribution with natural parameter and dispersion parameter , in short , has density
where and .
When , it becomes continuous Bernoulli distribution.
rcobin(n, theta, lambda)rcobin(n, theta, lambda)
n |
integer, number of samples |
theta |
scalar or length n vector, natural parameter. |
lambda |
scalar or length n vector, inverse of dispersion parameter. Must be integer, length should be same as theta |
The random variate generation is based on the fact that is equal in distribution to the sum of random variables, scaled by .
Random variate generation for continuous Bernoulli is done by inverse cdf transform method.
random samples from .
hist(rcobin(1000, 2, 3), freq = FALSE) xgrid = seq(0, 1, length = 500) lines(xgrid, dcobin(xgrid, 2, 3))hist(rcobin(1000, 2, 3), freq = FALSE) xgrid = seq(0, 1, length = 500) lines(xgrid, dcobin(xgrid, 2, 3))
A random variable follows Kolmogorov-Gamma(b,c) distribution, in short KG(b,c), if
where denotes equality in distribution.
The random variate generation is based on alternating series method, a fast and exact method (without infinite sum truncation) implemented in cpp.
This function only supports integer b, which is sufficient for cobin and micobin regression models.
rkgcpp(n, b, c)rkgcpp(n, b, c)
n |
The number of samples. |
b |
First parameter, positive integer (1,2,...). Length must be 1 or n. |
c |
Second parameter, real, associated with tilting. Length must be 1 or n. |
It returns n independent Kolmogorov-Gamma(b[i],c[i]) samples. If input b or c is scalar, it is assumed to be length n vector with same entries.
rkgcpp(100, 1, 2) rkgcpp(100, 1, rnorm(100)) rkgcpp(100, rep(c(1,2),50), rnorm(100))rkgcpp(100, 1, 2) rkgcpp(100, 1, rnorm(100)) rkgcpp(100, rep(c(1,2),50), rnorm(100))
Micobin distribution with natural parameter and dispersion , denoted as , is defined as a dispersion mixture of cobin:
rmicobin(n, theta, psi, r = 2)rmicobin(n, theta, psi, r = 2)
n |
integer, number of samples |
theta |
scalar or length n vector, natural parameter |
psi |
scalar or length n vector, between 0 and 1, dispersion parameter |
r |
(Default 2) This should be always 2 to maintain interpretaton of psi. It is kept for future experiment purposes. |
random samples from .
hist(rmicobin(1000, 2, 1/3), freq = FALSE) xgrid = seq(0, 1, length = 500) lines(xgrid, dmicobin(xgrid, 2, 1/3))hist(rmicobin(1000, 2, 1/3), freq = FALSE) xgrid = seq(0, 1, length = 500) lines(xgrid, dmicobin(xgrid, 2, 1/3))
Fit Bayesian spatial cobin regression model under canonical link (cobit link) with Markov chain Monte Carlo (MCMC).
for . See dcobin for details on cobin distribution. It currently only supports mean zero GP with exponential covariance
where corresponds to inverse range parameter.
spcobinreg( formula, data, link = "cobit", coords, NNGP = FALSE, contrasts = NULL, priors = list(beta_intercept_scale = 10, beta_scale = 2.5, beta_df = Inf), nngp.control = list(n.neighbors = 15, ord = order(coords[, 1])), nburn = 1000, nsave = 1000, nthin = 1 )spcobinreg( formula, data, link = "cobit", coords, NNGP = FALSE, contrasts = NULL, priors = list(beta_intercept_scale = 10, beta_scale = 2.5, beta_df = Inf), nngp.control = list(n.neighbors = 15, ord = order(coords[, 1])), nburn = 1000, nsave = 1000, nthin = 1 )
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. |
coords |
a n x 2 matrix of Euclidean coordinates |
NNGP |
logical, if TRUE, use NNGP prior for the spatial random effects; see spNNGP |
contrasts |
an optional list. See the contrasts.arg of model.matrix.default. |
priors |
a list of prior hyperparameters. See Details |
nngp.control |
a list of control parameters for NNGP prior (only when NNGP = TRUE). This should be a named list of n.neighbors and ord, with default of 15 and first coordiate-based ordering. See spNNGP for 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 |
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 , log-prior of lambda. Default choice arises from beta negative binomial distribution; .
logprior_sigma.sq, Default half-Cauchy on the sd(u) , log prior of var(u)
phi_lb, lower bound of uniform prior of (inverse range parameter of spatial random effect). Can be same as phi_ub
phi_ub, lower bound of uniform prior of (inverse range parameter of spatial random effect). Can be same as phi_lb
Returns list of
post_save |
a matrix of posterior samples (coda::mcmc) with nsave rows |
post_u_save |
a matrix of posterior samples (coda::mcmc) of random effects, 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 |
coords |
a n x 2 matrix of Euclidean coordinates |
if NNGP = TRUE, also returns
nngp.control |
a list of control parameters for NNGP prior |
spNNGPfit |
an "NNGP" class with empty samples, placeholder for prediction |
# Please see https://github.com/changwoo-lee/cobin-reproduce# Please see https://github.com/changwoo-lee/cobin-reproduce
Fit Bayesian spatial micobin regression model under canonical link (cobit link) with Markov chain Monte Carlo (MCMC).
for . See dmicobin for details on micobin distribution. It currently only supports mean zero GP with exponential covariance
where corresponds to inverse range parameter.
spmicobinreg( formula, data, link = "cobit", coords, NNGP = FALSE, contrasts = NULL, priors = list(beta_intercept_scale = 10, beta_scale = 2.5, beta_df = Inf), nngp.control = list(n.neighbors = 15, ord = order(coords[, 1])), nburn = 1000, nsave = 1000, nthin = 1 )spmicobinreg( formula, data, link = "cobit", coords, NNGP = FALSE, contrasts = NULL, priors = list(beta_intercept_scale = 10, beta_scale = 2.5, beta_df = Inf), nngp.control = list(n.neighbors = 15, ord = order(coords[, 1])), nburn = 1000, nsave = 1000, nthin = 1 )
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. |
coords |
a n x 2 matrix of Euclidean coordinates |
NNGP |
logical, if TRUE, use NNGP prior for the spatial random effects; see spNNGP |
contrasts |
an optional list. See the contrasts.arg of model.matrix.default. |
priors |
a list of prior hyperparameters. See Details |
nngp.control |
a list of control parameters for NNGP prior (only when NNGP = TRUE). This should be a named list of n.neighbors and ord, with default of 15 and first coordiate-based ordering.. See spNNGP for 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 |
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_max, Default 70, upper bound for lambda (integer)
psi_ab, Default c(2,2), beta shape parameters for (length 2 vector).
logprior_sigma.sq, Default half-Cauchy on the sd(u) , log prior of var(u)
phi_lb, lower bound of uniform prior of (inverse range parameter of spatial random effect). Can be same as phi_ub
phi_ub, lower bound of uniform prior of (inverse range parameter of spatial random effect). Can be same as phi_lb
Returns list of
post_save |
a matrix of posterior samples (coda::mcmc) with nsave rows |
post_u_save |
a matrix of posterior samples (coda::mcmc) of random effects, 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 |
coords |
a n x 2 matrix of Euclidean coordinates |
if NNGP = TRUE, also returns
nngp.control |
a list of control parameters for NNGP prior |
spNNGPfit |
an "NNGP" class with empty samples, placeholder for prediction |
# Please see https://github.com/changwoo-lee/cobin-reproduce# Please see https://github.com/changwoo-lee/cobin-reproduce