W_sampler {estimateW}R Documentation

An R6 class for sampling the elements of WW

Description

An R6 class for sampling the elements of WW

An R6 class for sampling the elements of WW

Format

An R6Class generator object

Details

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).

Public fields

W_prior

The current W_priors

curr_w

numeric, non-negative nn by nn spatial weight matrix with zeros on the main diagonal. Depending on the W_priors settings can be symmetric and/or row-standardized.

curr_W

binary nn by nn spatial connectivity matrix Ω\Omega

curr_A

The current spatial projection matrix IρWI - \rho W.

curr_AI

The inverse of curr_A

curr_logdet

The current log-determinant of curr_A

curr_rho

single 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.

Methods

Public methods


Method new()

Usage
W_sampler$new(W_prior, curr_rho = NULL)
Arguments
W_prior

The list returned by W_priors

curr_rho

optional 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.


Method set_rho()

If the spatial autoregressive parameter ρ\rho is updated during the sampling procedure the log determinant, the spatial projection matrix IρWI - \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.

Usage
W_sampler$set_rho(new_rho, newLogdet = NULL, newA = NULL, newAI = NULL)
Arguments
new_rho

single, number; must be between -1 and 1.

newLogdet

An optional value for the log determinant corresponding to newW and curr_rho

newA

An optional value for the spatial projection matrix using newW and curr_rho

newAI

An optional value for the matrix inverse of newA


Method sample()

Usage
W_sampler$sample(Y, curr_sigma, mu, lag_mu = matrix(0, nrow(tY), ncol(tY)))
Arguments
Y

The nn by tttt matrix of responses

curr_sigma

The variance parameter σ2\sigma^2

mu

The nn by tttt matrix of means.

lag_mu

nn by tttt matrix of means that will be spatially lagged with the estimated WW. Defaults to a matrix with zero elements.

References

Krisztin, T., and Piribauer, P. (2022) A Bayesian approach for the estimation of weight matrices in spatial autoregressive models. Spatial Economic Analysis, 1-20.


[Package estimateW version 0.0.1 Index]