remove_one_many_mat: Efficiently calculate the inverse of a sub-matrix

View source: R/RcppExports.R

remove_one_many_matR Documentation

Efficiently calculate the inverse of a sub-matrix

Description

Efficiently calculate the inverse of a sub-matrix

Usage

remove_one_many_mat(A, i)

Arguments

A

A square inverse matrix

i

Vector of integers specifying the rows/columns to remove from B, see details

Details

For a given matrix A = B^-1, this will calculate the inverse of a submatrix of B given only matrix A and requiring only vector multiplication. B typically represents a covariance matrix for observations 1,...,N and the function is used to calculate the inverse covariance matrix for a subset of those observations.

Value

The inverse of a submatrix of B

Examples

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

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