Learn R Programming

estimateW (version 0.1.0)

rho_sampler: An R6 class for sampling the spatial autoregressive parameter \(\rho\)

Description

An R6 class for sampling the spatial autoregressive parameter \(\rho\)

An R6 class for sampling the spatial autoregressive parameter \(\rho\)

Arguments

Format

An R6Class generator object

Public fields

rho_prior

The current rho_priors

curr_rho

The current value of \(\rho\)

curr_W

The current spatial weight matrix \(W\); an \(n\) by \(n\) matrix.

curr_A

The current spatial filter matrix \(I - \rho W\).

curr_AI

The inverse of curr_A

curr_logdet

The current log-determinant of curr_A

curr_logdets

A set of log-determinants for various values of \(\rho\). See the rho_priors function for settings of step site and other parameters of the grid.

Methods


Method new()

Usage

rho_sampler$new(rho_prior, W = NULL)

Arguments

rho_prior

The list returned by rho_priors

W

An optional starting value for the spatial weight matrix \(W\)


Method stopMHtune()

Function to stop the tuning of the Metropolis-Hastings step. The tuning of the Metropolis-Hastings step is usually carried out until half of the burn-in phase. Call this function to turn it off.

Usage

rho_sampler$stopMHtune()


Method setW()

Usage

rho_sampler$setW(newW, newLogdet = NULL, newA = NULL, newAI = NULL)

Arguments

newW

The updated spatial weight matrix \(W\).

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

rho_sampler$sample(Y, mu, sigma)

Arguments

Y

The \(n\) by \(T\) matrix of responses.

mu

The \(n\) by \(T\) matrix of means.

sigma

The variance parameter \(\sigma^2\).


Method sample_Griddy()

Usage

rho_sampler$sample_Griddy(Y, mu, sigma)

Arguments

Y

The \(n\) by \(T\) matrix of responses.

mu

The \(n\) by \(T\) matrix of means.

sigma

The variance parameter \(\sigma^2\).


Method sample_MH()

Usage

rho_sampler$sample_MH(Y, mu, sigma)

Arguments

Y

The \(n\) by \(T\) matrix of responses.

mu

The \(n\) by \(T\) matrix of means.

sigma

The variance parameter \(\sigma^2\).

Details

This class samples the spatial autoregressive parameter using either a tuned random-walk Metropolis-Hastings or a griddy Gibbs step. Use the rho_priors class for setup.

For the griddy Gibbs algorithm see Ritter and Tanner (1992).

References

Ritter, C., and Tanner, M. A. (1992). Facilitating the Gibbs sampler: The Gibbs stopper and the griddy-Gibbs sampler. Journal of the American Statistical Association, 87(419), 861-868.