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

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

# S4 method for 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(), pca()

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.409155083  0.330502130 -0.04215916 -0.065611889  0.22658729
#> 2  -0.403567627 -0.105086358 -0.04168067  0.176013226  0.17250804
#> 3   0.098838216  0.109621294 -0.01629390 -0.180836979  0.14993994
#> 4   0.026972747  0.343496783 -0.22524990  0.132099550  0.17087617
#> 5   0.241270064  0.260262199  0.06199829  0.059025862  0.36163014
#> 6   0.022960207  0.016138209 -0.12923699  0.377704196  0.12953728
#> 7   0.147818492  0.524378264  0.04982817  0.101458524  0.13705401
#> 8   0.049917274  0.054746114 -0.37691264  0.001110668 -0.41527920
#> 9   0.296475897  0.005630195  0.25330890  0.105188027 -0.08043109
#> 10  0.297115941 -0.058599968  0.31615198  0.183835722  0.25592680
#> 11 -0.002701417  0.323253816  0.13835036 -0.455850510 -0.32844556
#> 12 -0.156622911  0.028253035 -0.09708823  0.360424718  0.21181498
#> 13  0.119886427  0.602741936  0.16686680  0.091463926  0.06931678
#> 14 -0.053714484 -0.205103323 -0.30310962  0.006835815 -0.34179489
#> 15  0.180760913 -0.245051207  0.16802318  0.591534946  0.08040566
#> 16 -0.152048135  0.313780923 -0.56881463 -0.008916062  0.25644139
#> 17  0.490370721  0.306903514  0.08794433  0.062457885 -0.11962892
#> 18  0.012122712  0.227580831 -0.12209653 -0.154033245  0.09459119
#> 19  0.097500075  0.391511923  0.10871316  0.053865490 -0.07245598
#> 20  0.028136468 -0.199289798 -0.28243662 -0.143577282 -0.08642087

## 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.08210895  0.48235739 -0.33866274 -0.19725678 -0.01008236
#> 2  -0.01248495  0.44378605  0.24713569  0.08995940  0.28241198
#> 3  -0.40285186  0.51220464 -0.20894275 -0.10132784 -0.36420792
#> 4   0.14883072 -0.04819102 -0.26160223 -0.05112275  0.06875579
#> 5  -0.42181772  0.41541245 -0.29864796 -0.04612703  0.16175098
#> 6  -0.05614313 -0.24513097  0.28000003  0.16523535 -0.11145822
#> 7  -0.08939965  0.17992756 -0.34662206  0.10659580  0.21270295
#> 8  -0.06381120  0.02166612 -0.10836273  0.01160032  0.29371273
#> 9   0.00182329  0.50561552 -0.04657796  0.15792872 -0.10906638
#> 10  0.07955668  0.35880063 -0.13136590 -0.04426035 -0.10937904
#> 11 -0.10108709 -0.05722226  0.21457930  0.09415890  0.25518093
#> 12  0.17708520  0.47884148  0.26682894 -0.10602943  0.10070164
#> 13 -0.21245103  0.14944072 -0.07996240  0.09893115  0.42747813
#> 14 -0.12168503  0.54515571  0.36927612  0.39875671  0.02898272
#> 15 -0.31488812  0.23188645  0.06834786  0.13949497 -0.48280593
#> 16  0.15923664  0.03784771 -0.17174545  0.43722933  0.15086437
#> 17  0.11851195  0.41183119  0.19462841  0.19026106  0.27692516
#> 18 -0.02198704  0.13762452  0.06017651  0.10005686 -0.16261132
#> 19 -0.16556984 -0.04085356  0.15556685  0.42293698 -0.11204282
#> 20 -0.04234011  0.12856898 -0.11019379  0.08852926  0.10863259