Skip to contents

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

Usage

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

# S4 method for MCA
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(), mca(), 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.016180251 -0.077592576 -0.01343008 -0.15784502 -0.133522902
#> 2  -0.033895179 -0.328592023 -0.26341671  0.30270493  0.355614089
#> 3  -0.127934128  0.061615988 -0.16253292 -0.38665397  0.124998588
#> 4  -0.157773852  0.102959785 -0.24594788 -0.13332535  0.160451942
#> 5  -0.068729501 -0.191322198  0.02053709 -0.11189040 -0.004501452
#> 6   0.252222115 -0.091312728 -0.21183868 -0.15475244  0.230578553
#> 7   0.081323499 -0.277625596  0.23904583  0.06461852 -0.276636651
#> 8  -0.148091661  0.093316811 -0.18692812 -0.12552963  0.249424847
#> 9   0.557943849  0.438932297  0.23151019 -0.03084062  0.117453222
#> 10 -0.060637558  0.039644931 -0.03032355 -0.15349881 -0.342285107
#> 11  0.010347067 -0.303781759 -0.10551184  0.42208790  0.372575047
#> 12  0.249809992  0.110677609  0.13968170  0.46825774  0.359126007
#> 13  0.140237787 -0.061402810  0.33366129  0.12741400  0.177470768
#> 14  0.065019780  0.326064354  0.30494219  0.29323520  0.105539059
#> 15 -0.158497969  0.002617092  0.15073247  0.22936973  0.415578958
#> 16  0.303747857  0.341633353 -0.37073250  0.08106986 -0.090304840
#> 17  0.003772628 -0.018710373 -0.09780423 -0.35332587  0.159165332
#> 18  0.248147149 -0.254611742 -0.28227942 -0.17260588 -0.111091594
#> 19  0.168304594  0.195696384 -0.44343241 -0.04313237 -0.198473100
#> 20  0.231248932  0.165774410 -0.31739560  0.32210890  0.084939007

## 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.30729049  0.236384813  0.43793640  4.065473e-01 -0.327051045
#> 2   0.35087757 -0.352722273  0.56114690  1.517428e-01 -0.311094940
#> 3   0.13352074  0.148547902 -0.17343781  1.866746e-01 -0.032048361
#> 4   0.07420491  0.155005848  0.12610837  3.785932e-01 -0.094358693
#> 5   0.13457211  0.019071126 -0.42420280 -6.396752e-02  0.105549048
#> 6   0.08384225  0.191327883 -0.15530005 -1.369250e-01 -0.136965827
#> 7   0.46736580 -0.108452624  0.36197475  4.598092e-02  0.131312472
#> 8   0.23410593 -0.243493221 -0.51012482  1.512683e-01  0.212685556
#> 9   0.23850634 -0.198287596 -0.39778721  1.348564e-02 -0.001077467
#> 10 -0.15584395 -0.282040633 -0.28189939  1.980180e-01 -0.141969085
#> 11  0.01737386  0.116412826 -0.03194465  2.488541e-01  0.231644346
#> 12 -0.02816312  0.001211305  0.10368149 -2.305333e-01 -0.026121750
#> 13 -0.01316391 -0.007522721 -0.32932409 -2.790850e-02  0.492044025
#> 14 -0.18403429  0.184775332  0.09736779 -1.437911e-01  0.126826911
#> 15  0.11695152 -0.258524254  0.50187404 -6.142728e-02  0.197945452
#> 16 -0.15528839 -0.155831888  0.17285225 -2.276840e-01  0.037895840
#> 17  0.27159721  0.239326287  0.09883240  3.225330e-01  0.207134115
#> 18  0.23106420  0.118433799 -0.22163972 -1.379934e-04 -0.336719378
#> 19 -0.27507329 -0.088306233  0.08904732  2.989908e-05 -0.007155850
#> 20  0.14064699 -0.189041894  0.06936555 -6.800809e-02 -0.242509678