Lab Exercise for R: Factor Analysis

Exercise 1: Simplify a multidimensional construct based on its correlational structure

In a dataset with multiple continuous variables we try to represent correlations between them with newly derived axes. These axes are made from linear combinations of the original variables.

Use file "BodyMeasures.txt", optimize the coordinate space based on correaltions between the original variables

> bodyMeasures <- read.table("http://caspar.bgsu.edu/~courses/stats/Labs/Datasets/BodyMeasures.txt", header=T)
> bodyMeasures_cont <-
bodyMeasures[,2:12]
> fit <- princomp(bodyMeasures_cont, cor=TRUE)

> summary(fit)                      # amount of variance explained (i.e., eigenvalue) by each axis
> loadings(fit)                       # eigenvector matrix

> # diagnostic plots
> plot(fit,type="lines")         # scree plot

If you like to extract scores on a particular PC axis, you can display all scores, or extract one specific one

> fit$scores
> PC1scores <- fit$scores[,1]
> PC1scores

Now rotate the extracted axes for easier interpretation

> library(psych)
> fitr <- principal(bodyMeasures_cont, nfactors=2, rotate="varimax")
> fitr
                                     # display results


last modified: 3/7/15