Pages (Desktop)

Pages (Mobile)

Showing posts with label PCA. Show all posts
Showing posts with label PCA. Show all posts

Better Biplots for Principal Component Analysis

Principal component analysis (pca) is a great dimension reduction method to reduce large datasets to a smaller set, keeping the key, or principal components. R offers functions to carry out pca with ease, but creating good looking biplots in R can be quite involved, or require additional packages.

I've written a new, better biplot function, which makes creating beautiful looking biplots a breeze. And, its all written in base R, so does not require any additional packages to be installed. Just load the script and start plotting!

PC1 (73%) PC2 (22.9%) -3 -2 -1 0 1 2 3 -3 -2 -1 0 1 2 3 Species setosa versicolor virginica -1.0 -0.5 0.0 0.5 1.0 -1.0 -0.5 0.0 0.5 1.0 Sepal.Length Sepal.Width Petal.Length Petal.Width


Principal Components Analysis (PCA) in R - Part 2

In the second part of my guide for principal components analysis (PCA) in R, I additionally cover loadings plots, adding convex hulls to your biplots, more customisation options, and show you some more examples of PCA biplots created using R's base functionality...


Principal Components Analysis (PCA) in R

There is no shortage of ways to do principal components analysis (PCA) in R. Many packages offer functions for calculating and plotting PCA, with additional options not available in the base R installation. R offers two functions for doing PCA: princomp() and prcomp(), while plots can be visualised using the biplot() function. However, the plots produced by biplot() are often hard to read and the function lacks many of the options commonly available for customising plots.

This guide will show you how to do principal components analysis in R using prcomp(), and how to create beautiful looking biplots using R's base functionality, giving you total control over their appearance. I'll also show you how to add 95% confidence ellipses to the biplot using the "ellipse" package.