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.297490379  0.097878222  0.32730750 -0.08670700 -0.18573017
#> 2  -0.313426609  0.594843892  0.03655129 -0.37486425 -0.35490186
#> 3   0.356802550 -0.200141363 -0.12682117 -0.07312492  0.34820040
#> 4  -0.263612660  0.394598197  0.02279673 -0.22883478 -0.09532713
#> 5  -0.190487429 -0.401114923  0.12506244  0.17177566 -0.04565600
#> 6   0.007030088 -0.008806933  0.19267682  0.09037668 -0.08126021
#> 7  -0.062670459 -0.266202620  0.13826557 -0.42502942 -0.14673778
#> 8   0.396044221  0.011033386 -0.07031766  0.09314319 -0.26351638
#> 9  -0.029569729  0.173970880 -0.26718643 -0.16111445 -0.16437769
#> 10 -0.028575352  0.022847301 -0.15775198 -0.08543860 -0.19825379
#> 11  0.235916004 -0.137323754  0.45025971  0.18507469  0.09373412
#> 12  0.170901172 -0.157114306 -0.04326690  0.30528826  0.13914006
#> 13 -0.116398356 -0.139808207 -0.45686923  0.18135085  0.06789483
#> 14  0.205702088 -0.073663416  0.13073005  0.21448477  0.11844901
#> 15 -0.140222473  0.286408113 -0.01715162  0.04206743 -0.33052551
#> 16  0.030874105 -0.155941520  0.22228018 -0.59689455 -0.19982782
#> 17  0.187422940  0.172658799  0.04401447  0.12705101  0.06469886
#> 18 -0.082061050  0.147745332  0.17861350 -0.01215004  0.08247793
#> 19  0.273069567  0.254930838  0.36661749 -0.14470018  0.37483272
#> 20  0.166112974  0.271460683  0.42447423  0.01717218 -0.17346440

## 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.056456533  0.001354843 -0.23580956 -0.02665807  0.23840100
#> 2   0.122940987  0.263453863 -0.12795097 -0.03290069  0.20974080
#> 3  -0.152415818 -0.247413681  0.27650858 -0.12217455 -0.11191471
#> 4   0.129625759 -0.053124768  0.61392007 -0.30107491  0.14630630
#> 5   0.097918984  0.027188030 -0.20611334  0.08391671  0.21040869
#> 6  -0.110492949  0.074663277 -0.20000345 -0.08819936  0.07669736
#> 7   0.069889055 -0.085059653  0.10212533  0.17372487  0.35938648
#> 8   0.041468064 -0.034038683 -0.21984887  0.21876694 -0.19074327
#> 9   0.077338319 -0.062602866 -0.27556496 -0.37459904 -0.03840334
#> 10  0.285367586 -0.279576690 -0.39686158 -0.17733878  0.10816741
#> 11  0.134051707 -0.265811227  0.08259165 -0.02971663  0.18040186
#> 12 -0.014583237  0.078895904  0.01612977 -0.34621468  0.23353582
#> 13 -0.062043182  0.235230181 -0.10833539 -0.03839515 -0.10424868
#> 14  0.015404913 -0.098228511  0.20737676  0.17235483  0.36357546
#> 15  0.215377009 -0.129303529  0.24561175  0.14620860  0.14340878
#> 16  0.138049350  0.089071993 -0.15710159 -0.24473722  0.30093378
#> 17  0.204501996 -0.210671614 -0.27763833 -0.36507570 -0.23006282
#> 18  0.043810295 -0.152438046  0.10576771  0.15825697  0.17479236
#> 19 -0.005509191 -0.174711771 -0.10198307 -0.27174611 -0.16527083
#> 20 -0.399109908  0.418862832  0.01117604 -0.09711557  0.24085461