Description Usage Arguments Value Examples
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.
1 |
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. |
Returns a Matrix containing either the pseudoinverse, linear regression coefficients or residuals.
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.