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: bootstrap(), 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.109123299 0.054975563 0.16168684 -0.24870025 0.425717592 #> 2 -0.202101105 -0.439303388 0.14579547 -0.05885785 -0.023027851 #> 3 -0.471839095 -0.354213278 -0.13851729 0.03947177 0.127257879 #> 4 -0.149886329 -0.357452743 0.46677529 -0.27741115 0.077288264 #> 5 -0.054154754 -0.187315288 0.10131322 -0.06208843 0.252942566 #> 6 -0.184875705 -0.281873451 0.16530180 -0.36652296 -0.024532176 #> 7 -0.633513514 -0.003192051 0.04938091 0.36577527 -0.333022470 #> 8 0.111024200 0.470089790 0.25963818 -0.08628167 -0.257080890 #> 9 -0.319376872 0.169610820 -0.11316796 0.15767952 -0.379247052 #> 10 -0.231466801 -0.039627876 0.08699085 -0.05684970 0.368198000 #> 11 -0.158821164 0.065069722 -0.43341315 -0.23993230 -0.101920866 #> 12 -0.393375093 -0.072824536 -0.08505967 0.43335222 0.289540025 #> 13 -0.102536041 0.096390194 -0.15798005 0.40009925 -0.140084394 #> 14 -0.233431541 0.201635900 -0.24114369 0.43540344 -0.125532373 #> 15 -0.248192400 -0.264432911 -0.02444280 0.14391474 -0.084986075 #> 16 -0.505379844 0.451050906 0.31152594 0.05592028 0.009375028 #> 17 -0.201517869 0.284770055 0.32024143 -0.11443165 -0.029546086 #> 18 0.161989752 -0.076977588 0.13792556 0.34451163 0.081214811 #> 19 -0.003267757 0.260799711 0.29097171 -0.29854259 -0.272341875 #> 20 -0.100581499 0.304027532 0.08569409 -0.18687955 0.377749524
## 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.265422662 -0.28553208 0.20476159 0.0437515324 0.3805617016 #> 2 0.074955529 -0.12987175 -0.30161237 0.1425312317 -0.1128968354 #> 3 0.598365271 -0.55460806 0.61907123 -0.1308936165 -0.0453839350 #> 4 0.522649532 -0.21698348 0.35574828 -0.0363703198 -0.2380899616 #> 5 0.157449794 -0.18744284 0.32906186 -0.0729069324 0.0724395673 #> 6 0.330877735 -0.26726023 0.14049756 -0.0222810876 0.0582227706 #> 7 0.141706335 -0.05278356 -0.26430609 0.0309624970 -0.0493329334 #> 8 0.151241719 0.18222450 -0.24003358 0.2507679172 0.1334193258 #> 9 0.480579157 0.06464666 -0.54663942 -0.1338839353 0.2659301661 #> 10 -0.004939948 0.08255363 0.09771134 -0.0103449479 -0.1804268636 #> 11 0.631589766 0.16489399 -0.14049151 0.2318085961 0.0819051131 #> 12 0.560293621 -0.47488636 0.32612629 -0.0996269600 -0.1657716311 #> 13 0.033817339 -0.32840434 -0.24005696 0.0012124875 0.0672520660 #> 14 0.005169003 -0.26322860 0.31816791 0.0003470442 0.1888286405 #> 15 0.255986104 -0.39249749 -0.45654217 0.1432337813 0.4139803161 #> 16 0.185796623 -0.59380004 0.04650435 0.1980901259 0.0774625878 #> 17 0.115363131 -0.20394175 0.15543271 0.0798040749 0.1515472479 #> 18 0.290189174 -0.07693599 -0.40375333 -0.3603173367 0.1119579058 #> 19 0.527853940 -0.15276386 0.03580294 0.0380603146 -0.0005629022 #> 20 0.123030567 -0.54588764 0.14682372 -0.1433492847 -0.1387268886