This tutorial explores the structure detection approach to reduce the variables into relevant sub-indices. This is a second method to reduce the dimensions to avoid multicollinearity when variables are forming theoretical groups. This method is the first step to estimate SEM model. This method can be used to constitute indexes of unequal weight-ages rather than the averaging method which has equal weight-ages.
Loading Libraries
library(psych) # for rotated factor analysis
library(polycor)
library(readxl) # to read excel file
library(GPArotation)
library(tidyverse)
Loading data
df <- read_excel(“D:/UMT notes/MPhil – MS courses/Applied Econometrics/lectures applied econometrics/lecture 6/data reduction using factor analysis/car_sales.xlsx”, skip = 1)
Selecting variables
df1 <- df %>% select(type, price, engine_s, horsepow, wheelbas, width, length, curb_wgt, fuel_cap, mpg)
df1 <- drop_na (df1)
corrplot(cor(df1), method=”color”)
df1_hetcor <- hetcor(df1)
df1_c <- df1_hetcor$correlations
df1_factor <- cortest.bartlett(df1_c)
Bartlett Test
df1_factor
KMO(df1_c)
qgraph(cor(df1), title = “Q Graph of Indicators”, posCol=”darkgreen”, negCol=”darkmagenta”)
qgraph(cor(df1), title = “Q Graph of Indicators”, layout=”spring”, shape=”rectangle”, posCol=”darkgreen”, negCol=”darkmagenta”)
pa is principal axis factor approach
threefactor <- fa(df1, nfactors = 2, rotate =”Varimax”, fm = “pa”)
threefactor_common <- sort(threefactor$communality, decreasing = TRUE)
data.frame(threefactor_common)
threefactor_unique <- sort(threefactor$uniqueness, decreasing = TRUE)
data.frame(threefactor_unique)
Loading Libraries
library(psych) # for rotated factor analysis
library(polycor)
library(readxl) # to read excel file
library(GPArotation)
library(tidyverse)
Loading data
df <- read_excel(“D:/UMT notes/MPhil – MS courses/Applied Econometrics/lectures applied econometrics/lecture 6/data reduction using factor analysis/car_sales.xlsx”, skip = 1)
Selecting variables
df1 <- df %>% select(type, price, engine_s, horsepow, wheelbas, width, length, curb_wgt, fuel_cap, mpg)
df1 <- drop_na (df1)
corrplot(cor(df1), method=”color”)
df1_hetcor <- hetcor(df1)
df1_c <- df1_hetcor$correlations
df1_factor <- cortest.bartlett(df1_c)
Bartlett Test
df1_factor
KMO(df1_c)
qgraph(cor(df1), title = “Q Graph of Indicators”, posCol=”darkgreen”, negCol=”darkmagenta”)
qgraph(cor(df1), title = “Q Graph of Indicators”, layout=”spring”, shape=”rectangle”, posCol=”darkgreen”, negCol=”darkmagenta”)
pa is principal axis factor approach
threefactor <- fa(df1, nfactors = 2, rotate =”Varimax”, fm = “pa”)
threefactor_common <- sort(threefactor$communality, decreasing = TRUE)
data.frame(threefactor_common)
threefactor_unique <- sort(threefactor$uniqueness, decreasing = TRUE)
data.frame(threefactor_unique)
paf <- fa.parallel(df1, fm = ‘pa’, fa = ‘fa’)
df3 <- threefactor$scores
print(threefactor)
print(threefactor$loadings, cutoff = 0.3)
fa.diagram(threefactor, main = “Factor Analyis of Car Data”)
Other Tutorials available for this method in SPSS are – https://youtu.be/lbQ_ZZkfQOc