# generate X
set.seed(0)
X <- matrix(rnorm(100), 20, 5)
X <- cbind(X, rowSums(X))
# pseudo-inverse of X (dim = 6 by 20)
Xinv <- psolve(X)
# pseudo-inverse of crossprod(X) (dim = 6 by 6)
XtXinv <- psolve(crossprod(X))
Run the code above in your browser using DataLab