Learn R Programming

estimateW (version 0.1.0)

logdetAinvUpdate: Efficient update of the log-determinant and the matrix inverse

Description

While updating the elements of the spatial weight matrix in SAR and SDM type spatial models in a MCMC sampler, the log-determinant term has to be regularly updated, too. When the binary elements of the adjacency matrix are treated unknown, the Matrix Determinant Lemma and the Sherman-Morrison formula are used for computationally efficient updates.

Usage

logdetAinvUpdate(ch_ind, diff, AI, logdet)

Value

A list containing the updated \(n\) by \(n\) matrix \(A^{-1}\), as well as the updated log determinant of \(A\)

Arguments

ch_ind

vector of non-negative integers, between 1 and \(n\). Denotes which rows of \(A\) should be updated.

diff

a numeric length(ch_ind) by n matrix. This value will be added to the corresponding rows of \(A\).

AI

numeric \(n\) by \(n\) matrix that is the inverse of \(A = (I_n - \rho W)\). This inverse will be updated using the Sherman-Morrison formula.

logdet

single number that is the log-determinant of the matrix \(A\). This log-determinant will be updated through the Matrix Determinant Lemma.

Details

Let \(A = (I_n - \rho W)\) be an invertible \(n\) by \(n\) matrix. \(v\) is an \(n\) by \(1\) column vector of real numbers and \(u\) is a binary vector containing a single one and zeros otherwise. Then the Matrix Determinant Lemma states that:

$$A + uv' = (1 + v'A^{-1}u)det(A)$$.

This provides an update to the determinant, but the inverse of \(A\) has to be updated as well. The Sherman-Morrison formula proves useful:

$$(A + uv')^{-1} = A^{-1} \frac{A^{-1}uv'A^{-1}}{1 + v'A^{-1}u}$$.

Using these two formulas, an efficient update of the spatial projection matrix determinant can be achieved.

References

Sherman, J., and Morrison, W. J. (1950) Adjustment of an inverse matrix corresponding to a change in one element of a given matrix. The Annals of Mathematical Statistics, 21(1), 124-127.

Harville, D. A. (1998) Matrix algebra from a statistician's perspective. Taylor & Francis.