## taking subset of numeric variables
Sub_BOMDELBOM <- BOMDELBOM.df[,c(8,11,12,13,17,18,22,23)]
head(Sub_BOMDELBOM)## FlyingMinutes Capacity SeatPitch SeatWidth Price AdvancedBookingDays
## 1 130 156 30 17 4051 54
## 2 125 156 30 17 11587 52
## 3 135 189 29 17 3977 48
## 4 135 180 30 18 4234 59
## 5 130 189 29 17 6837 48
## 6 130 156 30 17 6518 52
## MarketShare LoadFactor
## 1 15.4 83.32
## 2 15.4 83.32
## 3 13.2 94.06
## 4 39.6 87.20
## 5 13.2 94.06
## 6 15.4 83.32
n.factors <- 2
fit <- factanal(Sub_BOMDELBOM,
n.factors, # number of factors to extract
scores=c("regression"),
rotation="none")
print(fit, digits=2, cutoff=.3, sort=TRUE)##
## Call:
## factanal(x = Sub_BOMDELBOM, factors = n.factors, scores = c("regression"), rotation = "none")
##
## Uniquenesses:
## FlyingMinutes Capacity SeatPitch SeatWidth
## 0.97 0.65 0.00 0.00
## Price AdvancedBookingDays MarketShare LoadFactor
## 0.99 1.00 0.31 0.49
##
## Loadings:
## Factor1 Factor2
## Capacity 0.59
## SeatPitch 0.81 -0.58
## SeatWidth 0.81 0.58
## MarketShare 0.36 0.75
## LoadFactor -0.39 0.60
## FlyingMinutes
## Price
## AdvancedBookingDays
##
## Factor1 Factor2
## SS loadings 1.96 1.64
## Proportion Var 0.24 0.20
## Cumulative Var 0.24 0.45
##
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 153.21 on 13 degrees of freedom.
## The p-value is 4.64e-26
# plot factor 1 by factor 2
load <- fit$loadings[,1:2]
plot(load,type="n") # set up plot
text(load,labels=names(Sub_BOMDELBOM),cex=.7) # add variable namesfit <- factanal(Sub_BOMDELBOM,
n.factors, # number of factors to extract
rotation="varimax") # 'varimax' is an ortho rotation
load <- fit$loadings[,1:2]
load## Factor1 Factor2
## FlyingMinutes -0.02744605 -0.18256077
## Capacity 0.49399400 0.32676786
## SeatPitch 0.99669918 0.04002925
## SeatWidth 0.28209404 0.95678310
## Price 0.07904794 -0.08653190
## AdvancedBookingDays -0.01683792 0.06225741
## MarketShare -0.18464260 0.81139640
## LoadFactor -0.67490484 0.23447409
plot(load,type="n") # set up plot
text(load,labels=names(Sub_BOMDELBOM),cex=.7) # add variable names## Warning: package 'psy' was built under R version 4.0.3