3
$\begingroup$

I wanted to demonstrate a small example in order to understand better the $\textbf{Nonlinear Iterative Partial Least}$ $\textbf{Squares algorithm}$.

My goal is to calculate all the Principal components of a $3\times 3$ matrix iteratively.

So, I defined the following matrix $X$

X
    [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    2    2
[3,]    0    0    1

I centered the matrix $X$ and followed the exact same steps described on the section $\textbf{NIPALS}$ in this $R$ pdf, https://cran.r-project.org/web/packages/nipals/vignettes/nipals_algorithm.html.

The algorithm that I wrote found correctly the first two principal components, $PC_{1},PC_{2}$ (with different signs than the ones calculated from the $PCA$ method) but it calculated completely wrong the last principal component $PC_{3}$. Is this something expected, because I read that $\textbf{NIPALS}$ is a method for calculating a few principal components, so I assume because it is an approximation method it might not me able to calculate all the principal components.

$\endgroup$

1 Answer 1

2
$\begingroup$

If you read the NIPALS documentation, it is said:

The NIPALS (Nonlinear Iterative Partial Least Squares) algorithm can be used to find the first few (or all) principal components with the decomposition

So you were right, it is something expected.

The author proposes a correction called "Gram-Schmidt orthogonalization" which seems "not very computationally expensive" and can solve your problem.

To use it in R, run nipals::nipals(B2, gramschmidt=TRUE)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.