View source: R/explained_variance.R
explained_variance | R Documentation |
explained_variance
calculates the proportion of variance explained by
a set of *orthogonal* variates / components and divides by the total variance
in data
using the definition of 'redundancy'. This applies to any
component-based approaches where components are orthogonal. It is worth
noting that any missing values are set to zero (which is the column mean for
the centered input data) prior to calculation of total variance in the data.
Therefore, this function would underestimate the total variance in presence
of abundant missing values. One can use impute.nipals
function
to impute the missing values to avoid such behaviour.
explained_variance(data, variates, ncomp)
data |
numeric matrix of predictors |
variates |
variates as obtained from a |
ncomp |
number of components. Should be lower than the number of
columns of |
Variance explained by component t_h
in X
for dimension
h
:
Rd(X, t_h) = \frac{1}{p} \sum_{j = 1}^p \mbox{cor}^2(X^j,
t_h)
where X^j
is the variable centered and scaled, p
is the
total number of variables.
explained_variance
returns a named numeric vector containing
the proportion of explained variance for each variate after setting all
missing values in the data to zero (see details).
Florian Rohart, Kim-Anh Lê Cao, Al J Abadi
Tenenhaus, M., La Régression PLS théorie et pratique (1998). Technip, Paris, chap2.
spls
, splsda
, plotIndiv
,
plotVar
, cim
, network
.
data(liver.toxicity)
X <- liver.toxicity$gene
Y <- liver.toxicity$clinic
toxicity.spls <- spls(X, Y, ncomp = 2, keepX = c(50, 50), keepY = c(10, 10))
ex = explained_variance(toxicity.spls$X, toxicity.spls$variates$X, ncomp =2)
# ex should be the same as
toxicity.spls$prop_expl_var$X
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.