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()

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.22984790  0.22339744 -0.22446601  0.14573354  0.181147656
#> 2   0.12109012  0.11785375 -0.15816258 -0.01213206 -0.216803763
#> 3  -0.23649478  0.02010735 -0.27194406 -0.17464071  0.004694312
#> 4  -0.22466803  0.34123011 -0.16201640 -0.21901299  0.099064599
#> 5   0.06850205 -0.48819388 -0.24625716 -0.09764892  0.006713169
#> 6   0.16724263  0.14756745  0.33433338 -0.29859197  0.024620967
#> 7   0.53995548 -0.07678737  0.15537943 -0.04114299  0.364877048
#> 8   0.30194199 -0.38036616 -0.09664650 -0.28370508 -0.011526677
#> 9   0.25024205 -0.44356792  0.10951934 -0.45234477  0.172925433
#> 10 -0.10262459  0.27978328  0.02389598 -0.05348861  0.281518413
#> 11  0.28899651  0.26090596 -0.12469636  0.03166779  0.078563954
#> 12 -0.35548325  0.60557976 -0.23333581  0.19834291 -0.076035094
#> 13 -0.07108079  0.23617505  0.32379701  0.09093099  0.136181209
#> 14  0.20498573 -0.25716338  0.05508702  0.12947667  0.152732854
#> 15  0.24799006  0.03677552 -0.11389546 -0.11416812  0.165384096
#> 16 -0.33523511  0.25086232  0.18246551 -0.19273040 -0.165932779
#> 17 -0.04457814  0.26803288 -0.05718665 -0.19945476  0.295026362
#> 18  0.28930946  0.37755828 -0.33240593 -0.03828841  0.091695220
#> 19  0.51083443  0.04041245 -0.34600420 -0.07566008 -0.232495800
#> 20  0.14725862  0.05618548 -0.02167869  0.13608174  0.094928766

## 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.4466090045  0.406295781  0.10727807 -0.15893196 -0.1788408377
#> 2   0.1315399156  0.224004570  0.37424905 -0.04390725  0.3516888817
#> 3   0.4513717908 -0.004536489  0.13294947  0.11110379  0.1754847881
#> 4  -0.2550115654  0.226816494 -0.20271663  0.34410746  0.1268956885
#> 5  -0.2018713199 -0.121812569  0.10960253 -0.07457661 -0.4596579759
#> 6  -0.0008006736  0.304071510 -0.46883342  0.22211348 -0.0535238926
#> 7   0.4859435763 -0.005787092 -0.16828999 -0.19587074  0.0201276347
#> 8   0.0917721712  0.124022469 -0.15405133 -0.04184395 -0.1394249752
#> 9   0.0933808114 -0.237898604  0.10994040 -0.36463834  0.2490203667
#> 10  0.1937853025  0.027502108 -0.23522528 -0.18982868 -0.2209218609
#> 11  0.4942137076  0.004918101 -0.13860808  0.27168835 -0.0024116618
#> 12  0.3332635148  0.048078596 -0.15793977 -0.12297949  0.0945725579
#> 13  0.2097816216 -0.134223192  0.03936531 -0.13342062 -0.2482250891
#> 14  0.0274122032  0.038212113 -0.15541007  0.12693730  0.3245487410
#> 15 -0.0578160816  0.255787678 -0.20051450  0.05951471  0.2092218993
#> 16  0.0735984987  0.079321248  0.08777002 -0.23385498  0.3265644250
#> 17  0.2160610636  0.230196162  0.25328087 -0.17201132  0.1133773325
#> 18 -0.4306321919 -0.066298983  0.14231808 -0.23844740  0.0003338666
#> 19  0.4041131592  0.087214730  0.13997104 -0.49152023  0.1957259499
#> 20  0.2513168088  0.563541947 -0.47070575  0.01686564 -0.2411289177