Title: | Spatial Autoregressive Graphical Model |
---|---|
Description: | Implements the methodological developments found in Hermes, van Heerwaarden, and Behrouzi (2023) <doi:10.48550/arXiv.2308.04325>, and allows for the statistical modeling of asymmetric between-location effects, as well as within-location effects using spatial autoregressive graphical models. The package allows for the generation of spatial weight matrices to capture asymmetric effects for strip-type intercropping designs, although it can handle any type of spatial data commonly found in other sciences. |
Authors: | Sjoerd Hermes [aut, cre], Joost van Heerwaarden [ctb], Pariya Behrouzi [ctb] |
Maintainer: | Sjoerd Hermes <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-12-03 06:29:35 UTC |
Source: | CRAN |
This is a generated dataset containing of 4 different variables, measured across 40 plots on a strip-type intercropping design consisting of 2 crops.
data("intercrop")
data("intercrop")
The format is: 40 by 4 matrix
Contains generated data similar to the data used in the Hermes et al. (2023) paper, except that this data consists of a a single row of alternating crops.
Generated
1. Hermes, S., van Heerwaarden, J., and Behrouzi, P. (2023). A Spatial Autoregressive Graphical Model with Applications in Intercropping. arXiv preprint, arXiv:2308.04325.
data(intercrop)
data(intercrop)
Create 2 weight matrices to capture asymmetric spatial effects for strip-type intercropping designs.
make_weights(n)
make_weights(n)
n |
Number of observations. |
W_BA |
A |
W_AB |
A |
Sjoerd Hermes, Joost van Heerwaarden and Pariya Behrouzi
Maintainer: Sjoerd Hermes [email protected]
1. Hermes, S., van Heerwaarden, J., and Behrouzi, P. (2023). A Spatial Autoregressive Graphical Model with Applications in Intercropping. arXiv preprint, arXiv:2308.04325.
make_weights(20)
make_weights(20)
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 . 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
and the
.
SAGM(X, W, prior, constraint, triangular, idx_mat, zeta, kappa, b0, b1, nBurnin, nIter, verbose)
SAGM(X, W, prior, constraint, triangular, idx_mat, zeta, kappa, b0, b1, nBurnin, nIter, verbose)
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 ( |
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. |
Sjoerd Hermes, Joost van Heerwaarden and Pariya Behrouzi
Maintainer: Sjoerd Hermes [email protected]
1. Hermes, S., van Heerwaarden, J., and Behrouzi, P. (2023). A Spatial Autoregressive Graphical Model with Applications in Intercropping. arXiv preprint, arXiv:2308.04325.
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)
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)