Learn R Programming

cobin (version 1.0.1.3)

spmicobinreg: spatial micobin regression model

Description

Fit Bayesian spatial micobin regression model under canonical link (cobit link) with Markov chain Monte Carlo (MCMC). $$ y(s_{i}) \mid x(s_{i}), u(s_i) \stackrel{ind}{\sim} micobin(x(s_{i})^T\beta + u(s_i), \psi), \quad u(\cdot)\sim GP $$ for \(i=1,\dots,n\). See dmicobin for details on micobin distribution. It currently only supports mean zero GP with exponential covariance $$ cov(u(s_i), u(s_j)) = \sigma_u^2\exp(-\phi_u d(s_i,s_j)) $$ where \(\phi_u\) corresponds to inverse range parameter.

Usage

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
)

Value

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

Arguments

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

Details

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 \(\psi\) (length 2 vector).

  • logprior_sigma.sq, Default half-Cauchy on the sd(u) \(=\sigma_u\), log prior of var(u)\(=\sigma_u^2\)

  • phi_lb, lower bound of uniform prior of \(\phi_u\) (inverse range parameter of spatial random effect). Can be same as phi_ub

  • phi_ub, lower bound of uniform prior of \(\phi_u\) (inverse range parameter of spatial random effect). Can be same as phi_lb

Examples

Run this code
# \donttest{
 # Please see https://github.com/changwoo-lee/cobin-reproduce
# }

Run the code above in your browser using DataLab