supervised.pca: Supervised PCA

View source: R/supervised.pca.R

Supervised PCAR Documentation

Supervised PCA

Description

Supervised PCA.

Usage

supervised.pca(target, dataset, indices, center = TRUE, scale = TRUE, 
colours = NULL, graph = TRUE) 

Arguments

target

A numerical vector or a factor denoting the class of each sample, the response variable.

dataset

A matrix with numerical data (the predictor variables).

indices

A vector with indices denoting whcih variables have been selected.

center

In the calculation of the PCA, should the data be centered? Default value is TRUE.

scale

In the calculation of the PCA, should the data be scaled to unity variance? Default value is TRUE.

colours

Should the colour of the points be defined by the target variable or do you want to pass your own colours? This must be a vector whose length is equal to the length of the target.

graph

Should two graphs be returned? The scores of the frist two principal components based on all the data and based on the selected variables.

Details

This is not exactly the standard supervised PCA as suggested by Bair et al (2006). What we do here essentially is the following: PCA on all variables and on the variables selected by a variable selection algortihm.

Value

A list including:

mod.all

The output returned by prcomp applied to all variables.

mode.sel

The output returned by prcomp applied to the selected variables.

var.percent

The percentage of variance explained by the selected variables.

Author(s)

Michail Tsagris

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr

References

Bair E., Hastie T., Debashis P. and Tibshirani R. (2006). Prediction by supervised principal components. Journal of the American Statistical Association 101(473): 119–137.

See Also

gomp, fbed.reg, MMPC

Examples

x <- as.matrix(iris[, 1:4])
target <- iris[, 5]
supervised.pca(target, x, indices = 1:2)

MXM documentation built on Aug. 25, 2022, 9:05 a.m.