Skip to contents

Predict the projection of new individuals/rows or variables/columns.

Usage

# S4 method for class 'CA'
predict(object, newdata, margin = 1)

# S4 method for class 'MCA'
predict(object, newdata, margin = 1)

# S4 method for class 'PCA'
predict(object, newdata, margin = 1)

Arguments

object

A CA or PCA object.

newdata

An object of supplementary points coercible to a matrix for which to compute principal coordinates.

margin

A length-one numeric vector giving the subscript which the data will be predicted: 1 indicates individuals/rows (the default), 2 indicates variables/columns.

Value

A data.frame of coordinates.

See also

Other multivariate analysis: ca(), mca(), pca(), pcoa()

Author

N. Frerebeau

Examples

## Create a matrix
A <- matrix(data = sample(1:10, 100, TRUE), nrow = 10, ncol = 10)

## Compute correspondence analysis
X <- ca(A, sup_row = 8:10, sup_col = 7:10)

## Predict new row coordinates
Y <- matrix(data = sample(1:10, 120, TRUE), nrow = 20, ncol = 6)
predict(X, Y, margin = 1)
#>              F1          F2          F3          F4          F5
#> 1  -0.128729299 -0.10818032 -0.28141357  0.22837513  0.10092295
#> 2   0.008121081  0.17028784  0.10379300  0.02906333 -0.06312539
#> 3  -0.160557061  0.05341086  0.14594044 -0.19515079 -0.15087036
#> 4  -0.057715821  0.07074400 -0.12705850  0.42742953 -0.04397607
#> 5  -0.117628254  0.24528565 -0.46157158  0.12254404 -0.02080062
#> 6   0.178112797 -0.02005509  0.37060924 -0.24227422 -0.12743457
#> 7   0.334988780  0.24796911 -0.05571254 -0.10966582 -0.17614132
#> 8  -0.250268416 -0.10093360  0.09066519  0.04076770  0.47087426
#> 9   0.259326889  0.48049118 -0.01603082  0.04921786 -0.03381440
#> 10  0.088317816  0.43658750  0.27114687  0.29903275 -0.30408585
#> 11 -0.369276777  0.05421755 -0.07186879 -0.01892826 -0.07841824
#> 12  0.312227631  0.39196624 -0.01959556  0.22946974  0.37427428
#> 13  0.039287192  0.07615105 -0.30140007 -0.31568099 -0.02506324
#> 14  0.184665640 -0.09939800 -0.04084344 -0.10024053  0.12179249
#> 15  0.206202178  0.56466303 -0.05641571  0.54282300 -0.33286021
#> 16 -0.028086985  0.16621222 -0.18655128  0.53860759 -0.08052961
#> 17 -0.140471355 -0.18951745  0.32475345  0.06906093 -0.09491990
#> 18  0.226491468  0.23547227  0.22619649 -0.05558173  0.31818430
#> 19  0.019360997 -0.21569121 -0.03774573 -0.20344281  0.08544785
#> 20  0.051210701 -0.36342220  0.19193448 -0.07545041 -0.08750094

## Predict new column coordinates
Z <- matrix(data = sample(1:10, 140, TRUE), nrow = 7, ncol = 20)
predict(X, Z, margin = 2)
#>              F1          F2          F3          F4           F5
#> 1  -0.007778935 -0.06590696 -0.24994122 -0.17246430 -0.103566273
#> 2  -0.014574674 -0.06888883 -0.32532760 -0.10531564  0.097639337
#> 3  -0.331380197 -0.20832587 -0.18515268 -0.02155093  0.134644940
#> 4  -0.402912301 -0.08755611  0.03481876  0.13802858  0.056973646
#> 5   0.060876109 -0.07668870  0.10867197 -0.01803285 -0.250749950
#> 6   0.311203953  0.07489021 -0.54747603  0.05344443 -0.049140586
#> 7   0.093209429  0.29260414  0.06890015 -0.30250813 -0.146335238
#> 8   0.555794516  0.14877195 -0.42435015 -0.16769966  0.138918229
#> 9   0.249983310 -0.23792363 -0.43321719  0.04345054 -0.142323994
#> 10  0.022457354 -0.04565814 -0.26252092 -0.10526162  0.121526468
#> 11 -0.315653969  0.26146294  0.42844705 -0.38889845  0.074593041
#> 12 -0.310194545  0.06815641 -0.25939921 -0.14271163 -0.008288752
#> 13  0.027045722  0.05953004 -0.30708687 -0.17880406 -0.367429060
#> 14  0.025996136 -0.41738533 -0.53954969 -0.36465292  0.413890909
#> 15  0.189363737 -0.27457772 -0.13617487 -0.29518543  0.616320669
#> 16 -0.196653053  0.12268971 -0.37407331 -0.03630774 -0.264267802
#> 17  0.091275762  0.44158341  0.04081940 -0.27642974 -0.183977410
#> 18  0.084936907  0.12898072 -0.30835094  0.38116538 -0.123561968
#> 19  0.363482409 -0.25521327  0.21745105 -0.27262856  0.080429002
#> 20  0.069667057  0.08142962  0.01414399  0.05244094  0.114946580