predict.PCAmix: Prediction of new scores in PCAmix or PCArot

Description Usage Arguments Value Author(s) References See Also Examples

Description

This function performs the scores of new observations on the principal components of PCAmix. If the components have been rotated, this function performs the scores of the new observations on the rotated principal components. In other words, this function is projecting the new observations onto the principal components of PCAmix (or PCArot) obtained previoulsy on a separated dataset. Note that the new observations must be described with the same variables than those used in PCAmix (or PCArot).

Usage

1
2
3
## S3 method for class 'PCAmix'
predict(object, X.quanti = NULL, X.quali = NULL,
  rename.level = FALSE, ...)

Arguments

object

an object of class PCAmix obtained with the function PCAmix or PCArot.

X.quanti

a numeric data matrix or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns).

X.quali

a categorical matrix of data, or an object that can be coerced to such a matrix (such as a character vector, a factor or a data frame with all factor columns).

rename.level

boolean, if TRUE all the levels of the qualitative variables are renamed as follows: "variable_name=level_name". This prevents to have identical names for the levels.

...

urther arguments passed to or from other methods. They are ignored in this function.

Value

Returns the matrix of the scores of the new observations on the principal components or on the rotated principal components of PCAmix.

Author(s)

Marie Chavent marie.chavent@u-bordeaux.fr, Amaury Labenne.

References

Chavent M., Kuentz-Simonet V., Labenne A., Saracco J., Multivariate analysis of mixed data: The PCAmixdata R package, arXiv:1411.4911 [stat.CO].

See Also

PCAmix,PCArot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# quantitative data
data(decathlon)
n <- nrow(decathlon)
sub <- sample(1:n,20)
pca<-PCAmix(decathlon[sub,1:10], graph=FALSE)
predict(pca,decathlon[-sub,1:10])
rot <- PCArot(pca,dim=4)
predict(rot,decathlon[-sub,1:10])

# quantitative and qualitative data
data(wine)
str(wine)
X.quanti <- splitmix(wine)$X.quanti
X.quali <- splitmix(wine)$X.quali
pca<-PCAmix(X.quanti[,1:27],X.quali,ndim=4,graph=FALSE)
n <- nrow(wine)
sub <- sample(1:n,10)
pca<-PCAmix(X.quanti[sub,1:27],X.quali[sub,],ndim=4)
pred <- predict(pca,X.quanti[-sub,1:27],X.quali[-sub,])
plot(pca,axes=c(1,2))
points(pred[,c(1,2)],col=2,pch=16)
text(pred[,c(1,2)], labels = rownames(X.quanti[-sub,1:27]), col=2,pos=3)

Example output

                dim1       dim2        dim3       dim4        dim5
KARPOV    -1.8668132  0.5485845  1.40889581 -1.4714966  0.39602061
YURKOV     1.5294624  1.9582734 -1.73869215 -0.3166235  0.16982132
McMULLEN  -0.9627772  0.3442828 -1.12846754 -2.0564943  0.90934292
MARTINEAU  2.0665630 -0.3785125 -0.42263062 -0.5995998 -1.47288824
HERNU      1.3549269 -0.1868845  1.21103322 -0.4880550 -0.49612037
BARRAS     1.0901523 -0.7450109 -0.04298967 -0.4773397 -0.40136451
Sebrle    -3.2824099  3.4150755 -1.03074317  1.6466002  0.37346958
Clay      -3.8333933  3.0754417 -0.05630483  0.9177711 -0.08347119
Karpov    -5.4278068  1.6818772 -0.56502661 -0.7450926  0.21085918
Macey     -2.2007755  1.7670587 -2.49777003 -1.1892653  0.41623023
Hernu     -1.1737189  0.1416835 -1.06121846  0.3379449 -0.29438583
Nool      -0.6980387 -0.3434860  1.57946910  2.8380448  0.18219964
Schwarzl  -0.6330506 -0.7996796  0.86917722  0.8524437  0.21210389
Pogorelov -0.4706288  1.1126352  0.79643328 -0.7469953  1.38234572
Smith     -1.1445503  1.8936178 -1.01067294 -1.2902987 -2.70880569
Averyanov -1.1808934 -0.5301643  0.34532126  0.5268205  0.87901453
Terek      0.5628700  0.6903239  2.15057070  0.4210848  0.73350299
Gomez     -0.3693580 -0.7761291 -0.81929826  0.4471115 -1.32020321
Lorenzo    1.6150419 -1.9093760 -0.86531951  0.3252723 -1.22244959
Uldal      2.2930626 -0.3927922  0.18808804 -0.8181141 -1.45829099
Casarsa    3.6436785  2.5616093  0.34633377 -2.9208616 -1.14045126
            dim1.rot   dim2.rot    dim3.rot    dim4.rot
KARPOV    -1.7530921 -0.6094987  2.14962096 -0.58340409
YURKOV     2.0367379  1.8277585 -0.12075196 -1.35462045
McMULLEN  -0.4384438 -0.4199708  0.72548064 -2.49053204
MARTINEAU  2.1177692 -0.6544774 -0.10671651 -0.44859805
HERNU      1.1899623 -0.8594151  1.00755842  0.54605550
BARRAS     1.0459961 -0.9295198 -0.07492046 -0.19485424
Sebrle    -2.8629596  4.2048411 -0.16223228 -0.09136729
Clay      -3.4830443  3.2959895  0.80964963 -0.09806896
Karpov    -4.9004380  1.5291042  0.94263401 -1.78111641
Macey     -1.3918380  1.6907326 -0.08506062 -2.95113999
Hernu     -1.0194729  0.6862176 -0.83592598 -0.54594569
Nool      -1.3600744  0.8251628 -0.88983962  3.19124314
Schwarzl  -0.9662138 -0.4062517 -0.30390780  1.22664627
Pogorelov -0.3330802  0.3160567  1.50430491 -0.27752831
Smith     -0.5503511  1.2357435  1.00437798 -1.99557548
Averyanov -1.3440180 -0.1688933 -0.31631991  0.54742310
Terek      0.2576362  0.1283203  1.45745792  1.66235278
Gomez     -0.3991695 -0.1340676 -1.16459283 -0.11324127
Lorenzo    1.4215567 -1.2546563 -1.65563907  0.12302960
Uldal      2.2779923 -0.9751911  0.42782690 -0.21512287
Casarsa    4.2372347  0.1806285  3.14666154 -1.94482132
'data.frame':	21 obs. of  31 variables:
 $ Label                        : Factor w/ 3 levels "Saumur","Bourgueuil",..: 1 1 2 3 1 2 2 1 3 1 ...
 $ Soil                         : Factor w/ 4 levels "Reference","Env1",..: 2 2 2 3 1 1 1 2 2 3 ...
 $ Odor.Intensity.before.shaking: num  3.07 2.96 2.86 2.81 3.61 ...
 $ Aroma.quality.before.shaking : num  3 2.82 2.93 2.59 3.43 ...
 $ Fruity.before.shaking        : num  2.71 2.38 2.56 2.42 3.15 ...
 $ Flower.before.shaking        : num  2.28 2.28 1.96 1.91 2.15 ...
 $ Spice.before.shaking         : num  1.96 1.68 2.08 2.16 2.04 ...
 $ Visual.intensity             : num  4.32 3.22 3.54 2.89 4.39 ...
 $ Nuance                       : num  4 3 3.39 2.79 4.04 ...
 $ Surface.feeling              : num  3.27 2.81 3 2.54 3.38 ...
 $ Odor.Intensity               : num  3.41 3.37 3.25 3.16 3.54 ...
 $ Quality.of.odour             : num  3.31 3 2.93 2.88 3.36 ...
 $ Fruity                       : num  2.88 2.56 2.77 2.39 3.16 ...
 $ Flower                       : num  2.32 2.44 2.19 2.08 2.23 ...
 $ Spice                        : num  1.84 1.74 2.25 2.17 2.15 ...
 $ Plante                       : num  2 2 1.75 2.3 1.76 ...
 $ Phenolic                     : num  1.65 1.38 1.25 1.48 1.6 ...
 $ Aroma.intensity              : num  3.26 2.96 3.08 2.54 3.62 ...
 $ Aroma.persistency            : num  2.96 2.81 2.8 2.58 3.3 ...
 $ Aroma.quality                : num  3.2 2.93 3.08 2.48 3.46 ...
 $ Attack.intensity             : num  2.96 3.04 3.22 2.7 3.46 ...
 $ Acidity                      : num  2.11 2.11 2.18 3.18 2.57 ...
 $ Astringency                  : num  2.43 2.18 2.25 2.19 2.54 ...
 $ Alcohol                      : num  2.5 2.65 2.64 2.5 2.79 ...
 $ Balance                      : num  3.25 2.93 3.32 2.33 3.46 ...
 $ Smooth                       : num  2.73 2.5 2.68 1.68 3.04 ...
 $ Bitterness                   : num  1.93 1.93 2 1.96 2.07 ...
 $ Intensity                    : num  2.86 2.89 3.07 2.46 3.64 ...
 $ Harmony                      : num  3.14 2.96 3.14 2.04 3.64 ...
 $ Overall.quality              : num  3.39 3.21 3.54 2.46 3.74 ...
 $ Typical                      : num  3.25 3.04 3.18 2.25 3.44 ...

PCAmixdata documentation built on May 2, 2019, 12:38 p.m.