nipals {ade4} R Documentation

## Non-linear Iterative Partial Least Squares (NIPALS) algorithm

### Description

This function performs NIPALS algorithm, i.e. a principal component analysis of a data table that can contain missing values.

### Usage

```nipals(df, nf = 2, rec = FALSE, niter = 100, tol = 1e-09)
## S3 method for class 'nipals':
scatter(x, xax = 1, yax = 2, clab.row = 0.75, clab.col = 1, posieig = "top", sub = NULL, ...)
## S3 method for class 'nipals':
print(x, ...)
```

### Arguments

 `df` a data frame that can contain missing values `nf` an integer, the number of axes to keep `rec` a logical that specify if the functions must perform the reconstitution of the data using the `nf` axes `niter` an integer, the maximum number of iterations `tol` a real, the tolerance used in the iterative algorithm `x` an object of class `nipals` `xax` the column number for the x-axis `yax` the column number for the y-axis `clab.row` a character size for the rows `clab.col` a character size for the columns `posieig` if "top" the eigenvalues bar plot is upside, if "bottom" it is downside, if "none" no plot `sub` a string of characters to be inserted as legend `...` further arguments passed to or from other methods

### Details

Data are scaled (mean 0 and variance 1) prior to the analysis.

### Value

Returns a list of classes `nipals`:

 `tab` the scaled data frame `eig` the pseudoeigenvalues `rank` the rank of the analyzed matrice `nf` the number of factors `c1` the column normed scores `co` the column coordinates `li` the row coordinates `call` the call function `nb` the number of iterations for each axis `rec` a data frame obtained by the reconstitution of the scaled data using the `nf` axes

### Author(s)

Stephane Dray dray@biomserv.univ-lyon1.fr

### References

Wold, H. (1966) Estimation of principal components and related models by iterative least squares. In P. Krishnaiah, editors.Multivariate Analysis, Academic Press, 391–420.

Wold, S., Esbensen, K. and Geladi, P. (1987) Principal component analysis Chemometrics and Intelligent Laboratory Systems, 2, 37–52.

`dudi.pca`

### Examples

```data(doubs)
## nipals is equivalent to dudi.pca when there are no NA
acp1 <- dudi.pca(doubs\$mil, scannf = FALSE, nf = 2)
nip1 <- nipals(doubs\$mil)
par(mfrow=c(2,2))
barplot(acp1\$eig, main ="dudi.pca")
barplot(nip1\$eig, main = "nipals")
plot(acp1\$c1[,1], nip1\$c1[,1], main = "col scores", xlab="dudi.pca", ylab="nipals")
plot(acp1\$li[,1], nip1\$li[,1], main = "row scores", xlab="dudi.pca",
ylab="nipals")

## Not run:
## with NAs:
doubs\$mil[1,1] <- NA
nip2 <- nipals(doubs\$mil)
cor(nip1\$li, nip2\$li)
nip1\$eig
nip2\$eig

## End(Not run)
```

### Worked out examples

```
> ### Name: nipals
> ### Title: Non-linear Iterative Partial Least Squares (NIPALS) algorithm
> ### Aliases: nipals print.nipals scatter.nipals
> ### Keywords: multivariate
>
> ### ** Examples
>
> data(doubs)
> ## nipals is equivalent to dudi.pca when there are no NA
> acp1 <- dudi.pca(doubs\$mil, scannf = FALSE, nf = 2)
> nip1 <- nipals(doubs\$mil)
> par(mfrow=c(2,2))
> barplot(acp1\$eig, main ="dudi.pca")
```
```> barplot(nip1\$eig, main = "nipals")
```
```> plot(acp1\$c1[,1], nip1\$c1[,1], main = "col scores", xlab="dudi.pca", ylab="nipals")
```
```> plot(acp1\$li[,1], nip1\$li[,1], main = "row scores", xlab="dudi.pca",
+ ylab="nipals")
```
```>
>
> ## with NAs:
> doubs\$mil[1,1] <- NA
> nip2 <- nipals(doubs\$mil)
> cor(nip1\$li, nip2\$li)
[,1]        [,2]
[1,] 0.999980606 0.001581087
[2,] 0.005205899 0.999719937
> nip1\$eig
[1] 6.765115 2.388152
> nip2\$eig
[1] 6.810109 2.425019
>
>
>
>
>
>
```