add_one_mat: Efficiently calculates the inverse of a super-matrix

View source: R/RcppExports.R

add_one_matR Documentation

Efficiently calculates the inverse of a super-matrix

Description

Efficiently calculates the inverse of a super-matrix by adding an observation

Usage

add_one_mat(A, sigma_jj, f)

Arguments

A

Inverse matrix of dimensions 'n'

sigma_jj

The element of C corresponding to the element [j,j] in matrix C where j is the index of the row/column we want to add, see Details

f

A vector of dimension n x 1, corresponding to the elements [b,j] in C where b is the indexes that make up submatrix B

Details

Given matrix A = B^-1 where B is a submatrix of a matrix C, this function efficiently calculates the inverse the matrix B+, which is B adding another row/column from C. For example, if C is the covariance matrix of observations 1,...,N, and B the covariance matrix of observations 1,...,n where n<N, then this function will calculate the inverse of the covariance matrix of the observations 1,...,n+1.

Value

A matrix of size dim(A)+1

Examples

B <- matrix(runif(16),nrow=4,ncol=4)
diag(B) <- diag(B)+1
A <- solve(B[2:4,2:4])
add_one_mat(A,B[1,1],B[2:4,1])
#equal to
solve(B)

samuel-watson/glmmr documentation built on July 27, 2022, 10:30 p.m.