Inverse {brainGraph}R Documentation

Calculate the inverse of the cross product of a design matrix

Description

inv is a S3 generic that calculates the inverse of the cross product of a design matrix, also referred to as the “unscaled covariance matrix”.

pinv calculates M^{+} = (M^T M)^{-1} M^T for full (column) rank matrices. However, it does not verify the matrix's rank.

Usage

inv(x, ...)

## S3 method for class 'matrix'
inv(x, y = NULL, transpose = FALSE, ...)

## S3 method for class 'array'
inv(x, y = NULL, transpose = FALSE, ...)

## S3 method for class 'qr'
inv(x, p = x$rank, ...)

## S3 method for class 'list'
inv(x, p = x[[1L]]$rank, r = length(x),
  vnames = dimnames(x[[1L]]$qr)[[2L]], nms = names(x), ...)

pinv(x)

Arguments

x

A numeric matrix or array, a qr object, or a list of qr objects

...

Unused

y

A numeric matrix or vector (for the matrix and array methods). If supplied, this will be multiplied by x before the inverse is calculated. Default: NULL

transpose

Logical. If FALSE (the default), take the cross product of the arguments. If TRUE, use tcrossprod

p

The rank of the original matrix

r

The number of design matrices; i.e., the length of the input list

vnames

Character vector of the design matrix's variable names

nms

The region names; i.e., the names of the input list

Details

If x is a matrix, the Cholesky decomposition of the cross product is calculated (or using tcrossprod if transpose=TRUE), and the inverse is calculated from that result. That is,

inv(X) = (X^T X)^{-1}

inv(X, transpose=TRUE) = (X X^T)^{-1}

inv(X, y) = (X^T y)^{-1}

If x is a 3-dimensional array, then the inverse will be calculated for each matrix along the 3rd dimension, with the same input arguments for each.

Finally, there is a method for objects with class qr, and lists of QR decomposition objects.

Value

A numeric matrix or array

pinv returns the input matrix's pseudoinverse

Note

These methods should only be used on full-rank matrices, as there is no error checking being performed.


[Package brainGraph version 3.1.0 Index]