xfit | R Documentation |
Function xfit
calculates the estimate of a matrix X
(say Xfit
) from given multivariate (e.g. PCA or PLS) scores and loadings of dimension a
.
Function xssr
calculates the sum of the squared X-
residuals SSR[i] = sum(E[i]^2) (i = 0, ..., a)
, where E[i] = X - Xfit[i]
, and X[0]
the centered matrix X
, The returned SSR is a vector of length a + 1
.
xfit(T, P, xmeans = rep(0, dim(P)[1]))
xssr(X, T, P, xmeans = rep(0, dim(P)[1]))
X |
Only for |
T |
A |
P |
A |
xmeans |
An eventual centering vector (length |
For |
Fitted matrix |
For |
SSR vector of length |
data(datcass)
Xr <- datcass$Xr
Xu <- datcass$Xu
headm(Xr)
headm(Xu)
ncomp <- 2
#ncomp <- 10
fm <- pca(Xr, Xu, ncomp = ncomp)
##################### Approximation of Xr
Xr.fit <- xfit(fm$Tr, fm$P, fm$xmeans)
headm(Xr.fit)
s <- sample(1:nrow(Xr), size = 1)
plotsp(Xr[s, , drop = FALSE], col = "red", zeroes = TRUE)
plotsp(Xr.fit[s, , drop = FALSE], col = "blue", add = TRUE, lty = 2)
##################### Approximation of Xu
Xu.fit <- xfit(fm$Tu, fm$P, fm$xmeans)
headm(Xu.fit)
s <- sample(1:nrow(Xu), size = 1)
plotsp(Xu[s, , drop = FALSE], col = "red", zeroes = TRUE)
plotsp(Xu.fit[s, , drop = FALSE], col = "blue", add = TRUE, lty = 2)
##################### SSR
xssr(Xr, fm$Tr, fm$P, fm$xmeans)
xssr(Xu, fm$Tu, fm$P, fm$xmeans)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.