pseudo: Pseudoinverse.

Description Usage Arguments Value Examples

Description

This function computes the Pseudoinverse of a design matrix. If a matrix of dependent variables is also supplied the betas will also be returned. Optionally the residuals may be returned as well.

Usage

1
pseudo(x,y=NULL,residuals=FALSE,keepMean=FALSE,includeIntercept=TRUE)

Arguments

x

x must be a numeric matrix.

y

y must be a numeric matrix.

residuals

residuals must be either TRUE or FALSE.

keepMean

keepMean must be either TRUE or FALSE. This argument specifies whether residuals should be zero centered or retain their mean.

includeIntercept

includeIntercept must be either TRUE or FALSE. This argument specifies whether a column of ones should be included in x.

Value

Returns a Matrix containing either the pseudoinverse, linear regression coefficients or residuals.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data(trees, package="datasets")

## with intercept
pinv<-pseudo(x=log(trees$Girth),includeIntercept=TRUE)
## without intercept
pinv<-pseudo(x=log(trees$Girth),includeIntercept=FALSE)
##coefficients
coef<-pseudo(x=log(trees$Girth),y=log(trees$Volume))
## residuals
res<-pseudo(x=log(trees$Girth),y=log(trees$Volume),residuals=TRUE)

## standard model
mod<-lm(log(trees$Volume)~log(trees$Girth))
coef2<-coefficients(mod)
res2<-residuals(mod)
## equality

cbind(coef,coef2) ## same but order reversed
cbind(res,res2)   ## same

FIACH documentation built on May 1, 2019, 8:02 p.m.

Related to pseudo in FIACH...