Last data update: 2014.03.03

R: Proportional and Cumulative Variation of Loading Components
Loadings.variationR Documentation

Proportional and Cumulative Variation of Loading Components

Description

Principal Component Analysis (PCA) methods prcomp and princomp do not accurately reflect the proportion of total variation of each principal component. Instead princomp calculates these values on the eigenvalue adjusted data, which misleadingly indicates that each component contributes equally to the variability in the loadings output. prcomp does not report the proportion of variablity. To rectify this, Loadings.variation displays the relative and cumulative contribution of variation for each component by accounting for all variability in data. Component variation is reported by the lambda value (which corresponds to the eigenvalue in princomp), while the proportion and cumulative variation relate these values to the total variability in data.

Usage

Loadings.variation(sdev, digits = 5)

Arguments

sdev

vector of standard deviations for each component

digits

number of decimal places to retain. Default is 5.

Details

For each component:

Lambda = sdev^2 Component Variance PTV = Lambda / sum(Lambda) Proportion of Total Variation CTV = cumsum(PTV) Cumulative Total Variation

All variability is accounted for in Principal Components, where each component is orthogonal and in decreasing order of variation explained. This allows PTV to be calculated as a proportion of the sum of individual variances and CTV=1 when accounting for all components.

Value

labeled matrix of variation for loading components. Lambda represents the variation for each component, PTV is the Proportion of Total Variation and CTV is the Cumulative Proportion of Total Variation. Values are rounded according to the number of digits specified.

Author(s)

Lisa McFerrin

See Also

prcomp, princomp

Examples


PCA_SVD = prcomp(USArrests, scale = TRUE)
PCA_SVD$rotation
Loadings.variation(PCA_SVD$sdev)

PCA_EIG = princomp(USArrests, cor = TRUE)
PCA_EIG$loadings
Loadings.variation(PCA_EIG$sdev)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(HDMD)
Loading required package: psych
Loading required package: MASS
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HDMD/Loadings.variation.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Loadings.variation
> ### Title: Proportional and Cumulative Variation of Loading Components
> ### Aliases: Loadings.variation
> 
> ### ** Examples
> 
> 
> PCA_SVD = prcomp(USArrests, scale = TRUE)
> PCA_SVD$rotation
                PC1        PC2        PC3         PC4
Murder   -0.5358995  0.4181809 -0.3412327  0.64922780
Assault  -0.5831836  0.1879856 -0.2681484 -0.74340748
UrbanPop -0.2781909 -0.8728062 -0.3780158  0.13387773
Rape     -0.5434321 -0.1673186  0.8177779  0.08902432
> Loadings.variation(PCA_SVD$sdev)
          [,1]    [,2]    [,3]    [,4]
Lambda 2.48024 0.98977 0.35656 0.17343
PTV    0.62006 0.24744 0.08914 0.04336
CTV    0.62006 0.86750 0.95664 1.00000
> 
> PCA_EIG = princomp(USArrests, cor = TRUE)
> PCA_EIG$loadings

Loadings:
         Comp.1 Comp.2 Comp.3 Comp.4
Murder   -0.536  0.418 -0.341  0.649
Assault  -0.583  0.188 -0.268 -0.743
UrbanPop -0.278 -0.873 -0.378  0.134
Rape     -0.543 -0.167  0.818       

               Comp.1 Comp.2 Comp.3 Comp.4
SS loadings      1.00   1.00   1.00   1.00
Proportion Var   0.25   0.25   0.25   0.25
Cumulative Var   0.25   0.50   0.75   1.00
> Loadings.variation(PCA_EIG$sdev)
        Comp.1  Comp.2  Comp.3  Comp.4
Lambda 2.48024 0.98977 0.35656 0.17343
PTV    0.62006 0.24744 0.08914 0.04336
CTV    0.62006 0.86750 0.95664 1.00000
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>