An R6 class for sampling the elements of \(W\)
An R6 class for sampling the elements of \(W\)
An R6Class generator object
W_priorThe current W_priors
curr_wnumeric, non-negative \(n\) by \(n\) spatial weight matrix with zeros
on the main diagonal. Depending on the W_priors settings can be symmetric and/or
row-standardized.
curr_Wbinary \(n\) by \(n\) spatial connectivity matrix \(\Omega\)
curr_AThe current spatial projection matrix \(I - \rho W\).
curr_AIThe inverse of curr_A
curr_logdetThe current log-determinant of curr_A
curr_rhosingle number between -1 and 1 or NULL, depending on whether the sampler updates
the spatial autoregressive parameter \(\rho\). Set while invoking initialize
or using the function set_rho.
spatial_errorShould a spatial error model be constructed? Defaults to FALSE.
new()W_sampler$new(W_prior, curr_rho = NULL, spatial_error = FALSE)W_priorThe list returned by W_priors
curr_rhoOptional single number between -1 and 1. Value of the spatial autoregressive parameter \(\rho\). Defaults to NULL, in which case no updates of the log-determinant, the spatial projection matrix, and its inverse are carried out.
spatial_errorOptional binary, specifying whether the sampler is for a spatial
error model (TRUE) or for a spatial autoregressive specification (FALSE).
Defaults to FALSE. If spatial_error = TRUE then a value curr_rho has to be supplied
at initialization.
set_rho()If the spatial autoregressive parameter \(\rho\) is updated during the sampling procedure the log determinant, the spatial projection matrix \(I - \rho W\) and it's inverse must be updated. This function should be used for a consistent update. At least the new scalar value for \(\rho\) must be supplied.
W_sampler$set_rho(new_rho, newLogdet = NULL, newA = NULL, newAI = NULL)new_rhosingle, number; must be between -1 and 1.
newLogdetAn optional value for the log determinant corresponding to newW and curr_rho
newAAn optional value for the spatial projection matrix using newW and curr_rho
newAIAn optional value for the matrix inverse of newA
sample()W_sampler$sample(Y, curr_sigma, mu, lag_mu = matrix(0, nrow(tY), ncol(tY)))YThe \(n\) by \(tt\) matrix of responses
curr_sigmaThe variance parameter \(\sigma^2\)
muThe \(n\) by \(tt\) matrix of means.
lag_mu\(n\) by \(tt\) matrix of means that will be spatially lagged with the estimated \(W\). Defaults to a matrix with zero elements.
This class samples the spatial weight matrix. Use the function W_priors class for setup.
The sampling procedure relies on conditional Bernoulli posteriors outlined in Krisztin and Piribauer (2022).
Krisztin, T., and Piribauer, P. (2022) A Bayesian approach for the estimation of weight matrices in spatial autoregressive models. Spatial Economic Analysis, 1-20.