FINAL
library(rio)
library(magrittr)
library(polycor)
library(psych)
##
## Adjuntando el paquete: 'psych'
## The following object is masked from 'package:polycor':
##
## polyserial
library(matrixcalc)
library(GPArotation)
##
## Adjuntando el paquete: 'GPArotation'
## The following objects are masked from 'package:psych':
##
## equamax, varimin
library(BBmisc)
##
## Adjuntando el paquete: 'BBmisc'
## The following object is masked from 'package:base':
##
## isFALSE
DATA
energia = import("energia_ok.csv")
PORCENTAJES
energia$pct_ELEC = energia$SI_ELEC / energia$TOTAL_ELEC
energia$pct_BGAS = energia$SI_BGAS / energia$TOTAL_BGAS
energia$pct_CARBON = energia$SI_CARBON / energia$TOTAL_CARBON
energia$pct_LENA = energia$SI_LENA / energia$TOTAL_LENA
data for factorial
select = c("pct_ELEC", "pct_BGAS", "pct_CARBON","pct_LENA")
theData = energia [,select]
head(theData,10)
## pct_ELEC pct_BGAS pct_CARBON pct_LENA
## 1 0.037425833 0.6938123 0.011475517 0.5281998
## 2 0.007863632 0.4843704 0.014115464 0.6406662
## 3 0.015870984 0.5963138 0.007423525 0.6998592
## 4 0.001418871 0.1556704 0.002635046 0.8926725
## 5 0.006817149 0.4801545 0.002499621 0.8611574
## 6 0.007089878 0.4124127 0.002835951 0.8010471
## 7 0.008094467 0.5103641 0.010633908 0.6574929
## 8 0.019911791 0.6552298 0.004713106 0.4648463
## 9 0.007980050 0.2384040 0.001995012 0.8907731
## 10 0.008403361 0.1976063 0.001018589 0.9106188
correlations
corMatrix=polycor::hetcor(theData)$correlations
previous evaluations
KMO(corMatrix)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = corMatrix)
## Overall MSA = 0.63
## MSA for each item =
## pct_ELEC pct_BGAS pct_CARBON pct_LENA
## 0.91 0.59 0.72 0.59
cortest.bartlett(corMatrix,n=nrow(theData))$p.value>0.05 #false
## [1] FALSE
is.singular.matrix(corMatrix) #false
## [1] FALSE
fa.parallel(theData, fa = 'fa',correct = T,plot = F) # 1 factor
## Parallel analysis suggests that the number of factors = 1 and the number of components = NA
run factor analysis
resfa <- fa(theData,
nfactors = 1,
cor = 'mixed',
rotate = "varimax", #oblimin?
fm="minres")
see results
print(resfa$loadings)
##
## Loadings:
## MR1
## pct_ELEC 0.491
## pct_BGAS 0.912
## pct_CARBON 0.280
## pct_LENA -0.956
##
## MR1
## SS loadings 2.065
## Proportion Var 0.516
fa.diagram(resfa,main = "Resultados del EFA")
run factor analysis
resfa_obli <- fa(theData,
nfactors = 1,
cor = 'mixed',
rotate = "oblimin", #oblimin?
fm="minres")
see results
print(resfa_obli$loadings) ##los resultados son los mismos
##
## Loadings:
## MR1
## pct_ELEC 0.491
## pct_BGAS 0.912
## pct_CARBON 0.280
## pct_LENA -0.956
##
## MR1
## SS loadings 2.065
## Proportion Var 0.516
fa.diagram(resfa_obli,main = "Resultados del EFA")