SAGM {SAGM} | R Documentation |
SAGM
Description
This function applies the spatial autoregressive graphical model on a given dataset and array of spatial weight matrices. Different identifiability constraints can be imposed to estimate the \Psi_k
. The method allows for both normal and normal-gamma priors, where the values for the hyperparameters can be specified by the user. Returns posterior samples for \Theta_{E}
and the \Psi_k
.
Usage
SAGM(X, W, prior, constraint, triangular, idx_mat, zeta, kappa, b0, b1,
nBurnin, nIter, verbose)
Arguments
X |
A |
W |
A |
prior |
Prior choice on the spatial effects. Either normal ( |
constraint |
Identifiability constraint on the spatial effects. Either symmetric ( |
triangular |
Type of triangular restriction. Can be upper-triangular, or lower-triangular, or both, e.g. |
idx_mat |
A |
zeta |
Value of hyperparameter |
kappa |
Value of hyperparameter |
b0 |
Value of hyperparameter |
b1 |
Value of hyperparameter |
nBurnin |
Number of burnin samples. |
nIter |
Number of post-burnin Gibbs samples. |
verbose |
Return progress of parameter estimation ( |
Value
Theta |
A |
Psi |
A |
lambda_sq |
A |
tau_sq |
A vector of length |
accpt_rate |
Value of the acceptance rate of the Metropolis Hastings step. |
Author(s)
Sjoerd Hermes, Joost van Heerwaarden and Pariya Behrouzi
Maintainer: Sjoerd Hermes sjoerd.hermes@wur.nl
References
1. Hermes, S., van Heerwaarden, J., and Behrouzi, P. (2023). A Spatial Autoregressive Graphical Model with Applications in Intercropping. arXiv preprint, arXiv:2308.04325.
Examples
data(intercrop)
n <- nrow(intercrop)
W <- make_weights(n)
# Suppose we have 16 known effects. Here we assign informative normal
# priors to these effects
idx_mat <- matrix(NA, 16, 5)
idx_mat[1,] <- c(1,1,1,1, 0.1)
idx_mat[2,] <- c(1,2,1,1, 0.1)
idx_mat[3,] <- c(1,3,1,1, 0.1)
idx_mat[4,] <- c(1,1,2,1, 0.1)
idx_mat[5,] <- c(1,2,2,1, 0.1)
idx_mat[6,] <- c(1,3,2,1, 0.1)
idx_mat[7,] <- c(4,1,1,-1, 0.1)
idx_mat[8,] <- c(4,2,1,-1, 0.1)
idx_mat[9,] <- c(4,3,1,-1, 0.1)
idx_mat[10,] <- c(4,4,1,-1, 0.1)
idx_mat[11,] <- c(4,1,2,-1, 0.1)
idx_mat[12,] <- c(4,2,2,-1, 0.1)
idx_mat[13,] <- c(4,3,2,-1, 0.1)
idx_mat[14,] <- c(4,4,2,-1, 0.1)
idx_mat[15,] <- c(2,3,1,-1, 0.1)
idx_mat[16,] <- c(2,3,2,-1, 0.1)
W <- array(c(W$W_BA, W$W_AB), dim = c(n,n,2))
est <- SAGM(X = intercrop, W = W, prior = "normal", constraint = "informative",
triangular = c("upper","upper"), idx_mat = idx_mat, zeta = 0.1, kappa = 0.1,
b0 = 0.01, b1 = 0.01, nBurnin = 1000, nIter = 1000, verbose = TRUE)