xfit {rchemo} | R Documentation |
Matrix fitting from a PCA or PLS model
Description
Function xfit
calculates an approximate of matrix X
(X_fit
) from a PCA or PLS fitted on X
.
Function xresid
calculates the residual matrix E = X - X_fit
.
Usage
xfit(object, X, ...)
## S3 method for class 'Pca'
xfit(object, X, ..., nlv = NULL)
## S3 method for class 'Plsr'
xfit(object, X, ..., nlv = NULL)
xresid(object, X, ..., nlv = NULL)
Arguments
object |
A fitted model, output of a call to a fitting function. |
X |
The X-data that was used to fit the model |
nlv |
Number of components (PCs or LVs) to consider. |
... |
Optional arguments. |
Value
For xfit
:matrix of fitted values.
For xresid
:matrix of residuals.
Examples
n <- 6 ; p <- 4
X <- matrix(rnorm(n * p), ncol = p)
y <- rnorm(n)
nlv <- 3
fm <- pcasvd(X, nlv = nlv)
xfit(fm, X)
xfit(fm, X, nlv = 1)
xfit(fm, X, nlv = 0)
X - xfit(fm, X)
xresid(fm, X)
X - xfit(fm, X, nlv = 1)
xresid(fm, X, nlv = 1)
[Package rchemo version 0.1-2 Index]