tune.pca | R Documentation |
tune.pca
can be used to quickly visualise the proportion of explained
variance for a large number of principal components in PCA.
tune.pca(
X,
ncomp = NULL,
center = TRUE,
scale = TRUE,
max.iter = 100,
tol = 1e-09,
logratio = c("none", "CLR", "ILR"),
V = NULL,
multilevel = NULL
)
X |
numeric matrix of predictors. |
ncomp |
integer, the number of components to initially analyse in
|
center |
a logical value indicating whether the variables should be
shifted to be zero centered. Alternately, a vector of length equal the
number of columns of |
scale |
a logical value indicating whether the variables should be
scaled to have unit variance before the analysis takes place. The default is
|
max.iter |
Integer, the maximum number of iterations. |
tol |
Numeric, convergence tolerance criteria. |
logratio |
one of ('none','CLR','ILR'). Default to 'none' |
V |
Matrix used in the logratio transformation id provided. |
multilevel |
Design matrix for multilevel analysis (for repeated measurements). |
The calculation is done either by a singular value decomposition of the
(possibly centered and scaled) data matrix, if the data is complete or by
using the NIPALS algorithm if there is data missing. Unlike
princomp
, the print method for these objects prints the
results in a nice format and the plot
method produces a bar plot of
the percentage of variance explaned by the principal components (PCs).
When using NIPALS (missing values), we make the assumption that the first
(min(ncol(X),
nrow(X)
) principal components will account for
100 % of the explained variance.
Note that scale= TRUE
cannot be used if there are zero or constant
(for center = TRUE
) variables.
Components are omitted if their standard deviations are less than or equal
to comp.tol
times the standard deviation of the first component. With
the default null setting, no components are omitted. Other settings for
comp.tol
could be comp.tol = sqrt(.Machine$double.eps)
, which
would omit essentially constant components, or comp.tol = 0
.
logratio transform and multilevel analysis are performed sequentially as
internal pre-processing step, through logratio.transfo
and
withinVariation
respectively.
tune.pca
returns a list with class "tune.pca"
containing the following components:
sdev |
the square root of the eigenvalues of the covariance/correlation matrix, though the calculation is actually done with the singular values of the data matrix). |
prop_expl_var |
The proportion of explained variance accounted for by each principal component. |
cum.var |
the cumulative proportion of explained variance accounted for by the sequential accumulation of principal components is calculated using the sum of the proportion of explained variance |
Ignacio González, Leigh Coonan, Kim-Anh Le Cao, Fangzhou Yao, Florian Rohart, Al J Abadi
nipals
, biplot
,
plotIndiv
, plotVar
and http://www.mixOmics.org
for more details.
# load data
data(liver.toxicity)
# run tuning
tune <- tune.pca(liver.toxicity$gene, center = TRUE, scale = TRUE)
plot(tune)
# set up multilevel dataset
repeat.indiv <- c(1, 2, 1, 2, 1, 2, 1, 2, 3, 3, 4, 3, 4, 3, 4, 4, 5, 6, 5, 5,
6, 5, 6, 7, 7, 8, 6, 7, 8, 7, 8, 8, 9, 10, 9, 10, 11, 9, 9,
10, 11, 12, 12, 10, 11, 12, 11, 12, 13, 14, 13, 14, 13, 14,
13, 14, 15, 16, 15, 16, 15, 16, 15, 16)
design <- data.frame(sample = repeat.indiv)
# run tuning
tune <- tune.pca(liver.toxicity$gene, center = TRUE, scale = TRUE, multilevel = design)
plot(tune)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.