Learn R Programming

strucchange (version 1.5-4)

solveCrossprod: Inversion of X'X

Description

Computes the inverse of the cross-product of a matrix X.

Usage

solveCrossprod(X, method = c("qr", "chol", "solve"))

Value

a matrix containing the inverse of crossprod(X).

Arguments

X

a matrix, typically a regressor matrix.

method

a string indicating whether the QR decomposition, the Cholesky decomposition or solve should be used.

Details

Using the Cholesky decomposition of X'X (as computed by crossprod(X)) is computationally faster and preferred to solve(crossprod(X)). Using the QR decomposition of X is slower but should be more accurate.

Examples

Run this code
X <- cbind(1, rnorm(100))
solveCrossprod(X)
solve(crossprod(X))

Run the code above in your browser using DataLab