User Tools

Site Tools


Action disabled: register
factor_analysis_examples

EFA datasets: Car buying factors

efa.csv

# read the dataset into R variable using the read.csv(file) function
data <- read.csv("http://commres.net/wiki/_media/r/efa.csv")
head(data)
# install the package
# install.packages("psych")
# install.packages("GPArotation")
# load the package
library(psych)
library(GPArotation)
# calculate the correlation matrix
corMat <- cor(data)
# display the correlation matrix
round(corMat,3)
# use fa() to conduct an oblique principal-axis exploratory factor analysis
# save the solution to an R variable
fa.ini <- fa(r = corMat)
# display the solution output
fa.ini
names(fa.ini)
fa.ini$e.values
num <- 5
fa.5 <- fa(r=corMat, nfactors=num, rotate="varimax", fm="pa")
fa.5.oblimin.minres <- fa(r=corMat, nfactors=num, rotate="oblimin", fm="minres")
fa.5.vm.minres <- fa(r=corMat, nfactors=num, rotate="varimax", fm="minres")

fa.sort(fa.5.oblimin.minres)
fa.sort(fa.5.vm.minres)
> fa.sort(fa.5.oblimin.minres)
Factor Analysis using method =  minres
Call: fa(r = corMat, nfactors = num, rotate = "oblimin", fm = "minres")
Standardized loadings (pattern matrix) based upon correlation matrix
                      MR1   MR2   MR4   MR5   MR3   h2    u2 com
Resale_Value         0.73 -0.20  0.08 -0.05 -0.10 0.59 0.413 1.2
Price                0.58  0.23 -0.11 -0.01 -0.07 0.35 0.645 1.4
Maintenance          0.55  0.11 -0.01  0.26  0.01 0.45 0.549 1.5
Fuel_Efficiency      0.38  0.01  0.33  0.23  0.22 0.49 0.512 3.3
Safety              -0.31  0.23  0.17  0.07 -0.24 0.21 0.790 3.6
Space_comfort       -0.02  0.88  0.04 -0.06  0.03 0.83 0.172 1.0
Fuel_Type            0.03  0.52  0.11  0.02 -0.13 0.30 0.699 1.2
Technology           0.00  0.28  0.14  0.06  0.01 0.13 0.873 1.6
After_Sales_Service -0.01  0.04  0.95 -0.01 -0.01 0.92 0.085 1.0
Color                0.03 -0.05  0.02  0.78  0.09 0.67 0.329 1.0
Exterior_Looks       0.09  0.05  0.03 -0.54  0.31 0.33 0.669 1.7
Testimonials        -0.23  0.04 -0.04  0.08  0.63 0.47 0.535 1.3
Test_drive           0.06 -0.02  0.23 -0.06  0.44 0.26 0.745 1.6
Product_reviews      0.33  0.25 -0.08  0.12  0.35 0.36 0.642 3.2

                       MR1  MR2  MR4  MR5  MR3
SS loadings           1.64 1.41 1.21 1.12 0.97
Proportion Var        0.12 0.10 0.09 0.08 0.07
Cumulative Var        0.12 0.22 0.30 0.38 0.45
Proportion Explained  0.26 0.22 0.19 0.18 0.15
Cumulative Proportion 0.26 0.48 0.67 0.85 1.00

 With factor correlations of 
      MR1   MR2  MR4   MR5  MR3
MR1  1.00 -0.03 0.16  0.25 0.03
MR2 -0.03  1.00 0.32 -0.07 0.21
MR4  0.16  0.32 1.00  0.13 0.07
MR5  0.25 -0.07 0.13  1.00 0.17
MR3  0.03  0.21 0.07  0.17 1.00

Mean item complexity =  1.8
Test of the hypothesis that 5 factors are sufficient.

The degrees of freedom for the null model are  91  and the objective function was  2.97
The degrees of freedom for the model are 31  and the objective function was  0.34 

The root mean square of the residuals (RMSR) is  0.04 
The df corrected root mean square of the residuals is  0.06 

Fit based upon off diagonal values = 0.97
Measures of factor score adequacy             
                                                   MR1  MR2  MR4  MR5  MR3
Correlation of (regression) scores with factors   0.87 0.92 0.96 0.86 0.79
Multiple R square of scores with factors          0.76 0.85 0.92 0.73 0.63
Minimum correlation of possible factor scores     0.52 0.70 0.85 0.46 0.26


> fa.sort(fa.5.vm.minres)
Factor Analysis using method =  minres
Call: fa(r = corMat, nfactors = num, rotate = "varimax", fm = "minres")
Standardized loadings (pattern matrix) based upon correlation matrix
                      MR1   MR2   MR3   MR5   MR4   h2    u2 com
Resale_Value         0.69 -0.22 -0.17  0.16  0.01 0.59 0.413 1.5
Maintenance          0.61  0.07  0.07  0.07  0.25 0.45 0.549 1.4
Price                0.57  0.15 -0.05 -0.04 -0.02 0.35 0.645 1.2
Fuel_Efficiency      0.46  0.09  0.28  0.37  0.23 0.49 0.512 3.2
Space_comfort        0.02  0.87  0.21  0.00 -0.17 0.83 0.172 1.2
Fuel_Type            0.06  0.54 -0.02  0.08 -0.04 0.30 0.699 1.1
Technology           0.04  0.32  0.09  0.13  0.03 0.13 0.873 1.5
Safety              -0.28  0.30 -0.16  0.11  0.05 0.21 0.790 2.9
Testimonials        -0.18  0.04  0.66 -0.05  0.02 0.47 0.535 1.2
Test_drive           0.09  0.06  0.43  0.23 -0.07 0.26 0.745 1.7
Product_reviews      0.38  0.18  0.41 -0.03  0.07 0.36 0.642 2.4
After_Sales_Service  0.06  0.37  0.06  0.88  0.04 0.92 0.085 1.4
Color                0.21 -0.05  0.26  0.07  0.74 0.67 0.329 1.4
Exterior_Looks      -0.01  0.05  0.20  0.01 -0.54 0.33 0.669 1.3

                       MR1  MR2  MR3  MR5  MR4
SS loadings           1.72 1.50 1.09 1.03 1.00
Proportion Var        0.12 0.11 0.08 0.07 0.07
Cumulative Var        0.12 0.23 0.31 0.38 0.45
Proportion Explained  0.27 0.24 0.17 0.16 0.16
Cumulative Proportion 0.27 0.51 0.68 0.84 1.00

Mean item complexity =  1.7
Test of the hypothesis that 5 factors are sufficient.

The degrees of freedom for the null model are  91  and the objective function was  2.97
The degrees of freedom for the model are 31  and the objective function was  0.34 

The root mean square of the residuals (RMSR) is  0.04 
The df corrected root mean square of the residuals is  0.06 

Fit based upon off diagonal values = 0.97
Measures of factor score adequacy             
                                                   MR1  MR2  MR3  MR5  MR4
Correlation of (regression) scores with factors   0.86 0.91 0.80 0.93 0.82
Multiple R square of scores with factors          0.75 0.82 0.64 0.87 0.67
Minimum correlation of possible factor scores     0.50 0.64 0.27 0.75 0.34
> 
> 
Factor Analysis using method =  minres
Call: fa(r = corMat, nfactors = num, rotate = "varimax", fm = "minres")
Standardized loadings (pattern matrix) based upon correlation matrix
                      MR1   MR2   MR3   MR5   MR4   h2    u2 com
----------------------------------------------------------------                      
Resale_Value         0.69 -0.22 -0.17  0.16  0.01 0.59 0.413 1.5
Maintenance          0.61  0.07  0.07  0.07  0.25 0.45 0.549 1.4
Price                0.57  0.15 -0.05 -0.04 -0.02 0.35 0.645 1.2
Fuel_Efficiency      0.46  0.09  0.28  0.37  0.23 0.49 0.512 3.2
----------------------------------------------------------------
Space_comfort        0.02  0.87  0.21  0.00 -0.17 0.83 0.172 1.2
Fuel_Type            0.06  0.54 -0.02  0.08 -0.04 0.30 0.699 1.1
Technology           0.04  0.32  0.09  0.13  0.03 0.13 0.873 1.5
Safety              -0.28  0.30 -0.16  0.11  0.05 0.21 0.790 2.9
----------------------------------------------------------------
Testimonials        -0.18  0.04  0.66 -0.05  0.02 0.47 0.535 1.2
Test_drive           0.09  0.06  0.43  0.23 -0.07 0.26 0.745 1.7
Product_reviews      0.38  0.18  0.41 -0.03  0.07 0.36 0.642 2.4
----------------------------------------------------------------
After_Sales_Service  0.06  0.37  0.06  0.88  0.04 0.92 0.085 1.4
----------------------------------------------------------------
Color                0.21 -0.05  0.26  0.07  0.74 0.67 0.329 1.4
Exterior_Looks      -0.01  0.05  0.20  0.01 -0.54 0.33 0.669 1.3

                       MR1  MR2  MR3  MR5  MR4
SS loadings           1.72 1.50 1.09 1.03 1.00
Proportion Var        0.12 0.11 0.08 0.07 0.07
Cumulative Var        0.12 0.23 0.31 0.38 0.45
Proportion Explained  0.27 0.24 0.17 0.16 0.16
Cumulative Proportion 0.27 0.51 0.68 0.84 1.00

2

food <- read.csv("http://commres.net/wiki/_media/r/food-texture.csv",
                 row.names = "X")
str(food)
food.ini <- fa(food)
food.ini$e.values  # we decide to get two factors based on eigenvalues
food.fa <- factanal(food, factors = 2)
food.fa
food.fa$uniquenesses
apply(food.fa$loadings^2,1,sum) # communality
1 - apply(food.fa$loadings^2,1,sum) # 1 - communality = uniq
Lambda <- food.fa$loadings
Psi <- diag(food.fa$uniquenesses)
S <- food.fa$correlation
Sigma <- Lambda %*% t(Lambda) + Psi
round(S - Sigma, 6)
food.fa.none <- factanal(food, factors = 2, rotation = "none")
food.fa.varimax <- factanal(food, factors = 2, rotation = "varimax")
food.fa.promax <- factanal(food, factors = 2, rotation = "promax")

par(mfrow = c(1,3))
plot(food.fa.none$loadings[,1], 
     food.fa.none$loadings[,2],
     xlab = "Factor 1", 
     ylab = "Factor 2", 
     ylim = c(-1,1),
     xlim = c(-1,1),
     main = "No rotation")
abline(h = 0, v = 0)

plot(food.fa.varimax$loadings[,1], 
     food.fa.varimax$loadings[,2],
     xlab = "Factor 1", 
     ylab = "Factor 2", 
     ylim = c(-1,1),
     xlim = c(-1,1),
     main = "Varimax rotation")

text(food.fa.varimax$loadings[,1]-0.08, 
     food.fa.varimax$loadings[,2]+0.08,
      colnames(food),
      col="blue")
abline(h = 0, v = 0)

plot(food.fa.promax$loadings[,1], 
     food.fa.promax$loadings[,2],
     xlab = "Factor 1", 
     ylab = "Factor 2",
     ylim = c(-1,1),
     xlim = c(-1,1),
     main = "Promax rotation")
abline(h = 0, v = 0)

par(mfrow = c(1,1))
factor_analysis_examples.txt · Last modified: 2022/05/05 15:02 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki