Learn R Programming

TDMR (version 2.2)

tdmPrePCA.apply: Apply PCA (Principal Component Analysis) to new data.

Description

The PCA rotation is taken from pcaList, a value returned from a prior call to tdmPrePCA.train.

Usage

tdmPrePCA.apply(dset, pcaList, opts, dtrain = NULL)

Arguments

dset

the data frame with the new data

pcaList

a value returned from a prior call to tdmPrePCA.train

opts

a list from which we need here the following entries:

  • PRE.knum: if >0 and if PRE.PCA="kernel", take only a subset of PRE.knum records from dset

  • PRE.PCA.npc: if >0, then add for the first PRE.PCA.npc PCs the monomials of degree 2 (see tdmPreAddMonomials)

  • PRE.PCA.numericV vector with all column names in dset for which PCA is performed. These columns may contain *numeric* values only.

dtrain

[NULL] optional, only needed in case that dset is a 0-row-data frame: then we 'borrow' the columns from dtrain, the data set returned from tdmPrePCA.train in pca$dset.

Value

pca, a list with entries:

dset

the input data frame dset with columns numeric.variables replaced by the PCs with names PC1, PC2, ... (in case PRE.PCA=="linear") or with names KP1, KP2, ... (in case PRE.PCA=="kernel") and optional with monomial columns added, if PRE.PCA.npc>0

numeric.variables

the new column names for PCs and for the monomials

See Also

tdmPrePCA.train