xfit | R Documentation |
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
.
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)
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. |
See the 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.