GLM_EFA

Dimitrios Zacharatos

Description

This shows the output of several EFA functions from workingfunctions.
Installation instructions for workingfunctions can be found here

Plot Loadings

model<-psych::fa(mtcars,nfactors=2,rotate="oblimin",fm="pa",oblique.scores=TRUE)
plot_loadings(model=model,matrix_type="structure")

plot_loadings(model=model,matrix_type="pattern")

cm<-matrix(c(1,.8,.8,.1,.1,.1,
             .8,1,.8,.1,.1,.1,
             .8,.8,1,.1,.1,.1,
             .1,.1,.1,1,.8,.8,
             .1,.1,.1,.8,1,.8,
             .1,.1,.1,.8,.8,1),
           ncol=6,nrow=6)
df1<-generate_correlation_matrix(cm,nrows=10000)
model1<-psych::fa(df1,nfactors=2,rotate="oblimin",fm="pa",oblique.scores=TRUE)
plot_loadings(model=model1,matrix_type="pattern",base_size=10)

cm<-matrix(c(1,.1,.1,.1,.1,.1,
             .1,1,.1,.1,.1,.1,
             .1,.1,1,.1,.1,.1,
             .1,.1,.1,1,.8,.8,
             .1,.1,.1,.8,1,.8,
             .1,.1,.1,.8,.8,1),
           ncol=6,nrow=6)
df1<-generate_correlation_matrix(cm,nrows=10000)
model2<-psych::fa(df1,nfactors=2,rotate="oblimin",fm="pa",oblique.scores=TRUE)
plot_loadings(model=model2,matrix_type="pattern",base_size=10)

cm<-matrix(c(1,.01,.01,.01,.01,.01,
             .01,1,.01,.01,.01,.01,
             .01,.01,1,.01,.01,.01,
             .01,.01,.01,1,.01,.01,
             .01,.01,.01,.01,1,.01,
             .01,.01,.01,.01,.01,1),
           ncol=6,nrow=6)
df1<-generate_correlation_matrix(cm,nrows=10000)
model3<-psych::fa(df1,nfactors=2,rotate="oblimin",fm="pa",oblique.scores=TRUE)
plot_loadings(model=model3,matrix_type="pattern",base_size=10)

Plot Scree

plot_scree(df=mtcars,title="",base_size=15)

Model Loadings

model<-psych::fa(mtcars,nfactors=2,rotate="oblimin",fm="pa",oblique.scores=TRUE)
model_loadings(model=model,cut=NULL,matrix_type="pattern")
##       Matrix variable   PA1  PA2
## qsec Pattern     qsec -0.92     
## hp   Pattern       hp  0.89     
## carb Pattern     carb  0.85     
## vs   Pattern       vs  -0.8     
## cyl  Pattern      cyl           
## mpg  Pattern      mpg           
## am   Pattern       am       0.93
## gear Pattern     gear       0.93
## drat Pattern     drat       0.78
## wt   Pattern       wt           
## disp Pattern     disp
model_loadings(model=model,cut=0.4,matrix_type="structure")
##         Matrix variable   PA1   PA2
## hp   Structure       hp  0.93      
## cyl  Structure      cyl  0.85 -0.68
## vs   Structure       vs -0.83      
## qsec Structure     qsec -0.82      
## carb Structure     carb  0.78      
## mpg  Structure      mpg -0.76  0.72
## am   Structure       am        0.89
## gear Structure     gear        0.87
## drat Structure     drat        0.83
## wt   Structure       wt  0.61 -0.81
## disp Structure     disp  0.75 -0.77
model_loadings(model=model,cut=0.4,matrix_type="all",sort=FALSE)
##       Matrix variable   PA1   PA2
## 1    Pattern      mpg -0.61  0.55
## 2    Pattern      cyl  0.71 -0.48
## 3    Pattern     disp  0.58  -0.6
## 4    Pattern       hp  0.89      
## 5    Pattern     drat        0.78
## 6    Pattern       wt  0.42  -0.7
## 7    Pattern     qsec -0.92      
## 8    Pattern       vs  -0.8      
## 9    Pattern       am        0.93
## 10   Pattern     gear        0.93
## 11   Pattern     carb  0.85      
## 12 Structure      mpg -0.76  0.72
## 13 Structure      cyl  0.85 -0.68
## 14 Structure     disp  0.75 -0.77
## 15 Structure       hp  0.93      
## 16 Structure     drat        0.83
## 17 Structure       wt  0.61 -0.81
## 18 Structure     qsec -0.82      
## 19 Structure       vs -0.83      
## 20 Structure       am        0.89
## 21 Structure     gear        0.87
## 22 Structure     carb  0.78

Compute Residual

model<-psych::fa(mtcars,nfactors=2,rotate="oblimin",fm="pa",oblique.scores=TRUE)
compute_residual_stats(model)
##                       residual_statistics       value critical                              formula
## 1              Root Mean Squared Residual  0.04419293       NA              sqrt(mean(residuals^2))
## 2     Number of absolute residuals > 0.05 13.00000000       NA                  abs(residuals)>0.05
## 3 Proportion of absolute residuals > 0.05  0.23636364      0.5 numberLargeResiduals/nrow(residuals)

Report EFA

cm<-matrix(c(1,.8,.8,.1,.1,.1,
             .8,1,.8,.1,.1,.1,
             .8,.8,1,.1,.1,.1,
             .1,.1,.1,1,.8,.8,
             .1,.1,.1,.8,1,.8,
             .1,.1,.1,.8,.8,1),
           ncol=6,nrow=6)
df1<-generate_correlation_matrix(cm,nrows=10000)
model<-psych::fa(df1,nfactors=2,rotate="oblimin",fm="pa",oblique.scores=TRUE)
result<-report_efa(model=model,df=df1)

result
## $correlations
##                        type            X1            X2            X3            X4            X5            X6
## X1  reproduced correlations  8.029710e-01  8.022465e-01  8.026759e-01  8.079004e-02  7.968185e-02  9.059877e-02
## X2  reproduced correlations  8.022465e-01  8.015498e-01  8.019680e-01  8.536400e-02  8.425188e-02  9.514245e-02
## X3  reproduced correlations  8.026759e-01  8.019680e-01  8.023908e-01  8.355765e-02  8.244689e-02  9.334987e-02
## X4  reproduced correlations  8.079004e-02  8.536400e-02  8.355765e-02  8.074858e-01  8.065270e-01  8.047871e-01
## X5  reproduced correlations  7.968185e-02  8.425188e-02  8.244689e-02  8.065270e-01  8.055707e-01  8.038187e-01
## X6  reproduced correlations  9.059877e-02  9.514245e-02  9.334987e-02  8.047871e-01  8.038187e-01  8.022253e-01
## X11   observed correlations  1.000000e+00  8.022812e-01  8.027364e-01  8.144221e-02  7.922614e-02  9.040050e-02
## X21   observed correlations  8.022812e-01  1.000000e+00  8.019934e-01  8.487331e-02  8.420571e-02  9.568204e-02
## X31   observed correlations  8.027364e-01  8.019934e-01  1.000000e+00  8.339506e-02  8.294894e-02  9.300951e-02
## X41   observed correlations  8.144221e-02  8.487331e-02  8.339506e-02  1.000000e+00  8.066169e-01  8.048166e-01
## X51   observed correlations  7.922614e-02  8.420571e-02  8.294894e-02  8.066169e-01  1.000000e+00  8.038186e-01
## X61   observed correlations  9.040050e-02  9.568204e-02  9.300951e-02  8.048166e-01  8.038186e-01  1.000000e+00
## X12   residual correlations  1.970290e-01  3.461689e-05  6.051535e-05  6.521679e-04 -4.557042e-04 -1.982738e-04
## X22   residual correlations  3.461689e-05  1.984502e-01  2.539922e-05 -4.906850e-04 -4.616466e-05  5.395892e-04
## X32   residual correlations  6.051535e-05  2.539922e-05  1.976092e-01 -1.625891e-04  5.020468e-04 -3.403591e-04
## X42   residual correlations  6.521679e-04 -4.906850e-04 -1.625891e-04  1.925142e-01  8.990569e-05  2.950289e-05
## X52   residual correlations -4.557042e-04 -4.616466e-05  5.020468e-04  8.990569e-05  1.944293e-01 -1.330340e-07
## X62   residual correlations -1.982738e-04  5.395892e-04 -3.403591e-04  2.950289e-05 -1.330340e-07  1.977747e-01
## 
## $npobs
##       X1    X2    X3    X4    X5    X6
## X1 10000 10000 10000 10000 10000 10000
## X2 10000 10000 10000 10000 10000 10000
## X3 10000 10000 10000 10000 10000 10000
## X4 10000 10000 10000 10000 10000 10000
## X5 10000 10000 10000 10000 10000 10000
## X6 10000 10000 10000 10000 10000 10000
## 
## $residual_stats
##                       residual_statistics        value critical                              formula
## 1              Root Mean Squared Residual 0.0003281413       NA              sqrt(mean(residuals^2))
## 2     Number of absolute residuals > 0.05 0.0000000000       NA                  abs(residuals)>0.05
## 3 Proportion of absolute residuals > 0.05 0.0000000000      0.5 numberLargeResiduals/nrow(residuals)
## 
## $determinant_test
##   determinant above_critical
## 1 0.009986523           TRUE
## 
## $bartlett_test
##   x_squared[bartlett] df[bartlett] p[bartlett]
## 1            46047.53           15           0
## 
## $kmo_test
##    Overall_MSA       MSA Kaiser_1974
## X1   0.7683298 0.7673630        Good
## X2   0.7683298 0.7688482        Good
## X3   0.7683298 0.7680652        Good
## X4   0.7683298 0.7665333        Good
## X5   0.7683298 0.7678210        Good
## X6   0.7683298 0.7713582        Good
## 
## $loadings
##       Matrix variable       PA1       PA2               type row.names.model.Vaccounted.
## 1    Pattern       X4 0.9000000 0.0000000                                       
## 2    Pattern       X5 0.9000000 0.0000000                                       
## 3    Pattern       X6 0.8900000 0.0100000                                       
## 4    Pattern       X1 0.0000000 0.9000000                                       
## 5    Pattern       X2 0.0000000 0.9000000                                       
## 6    Pattern       X3 0.0000000 0.9000000                                       
## 7  Structure       X4 0.9000000 0.0900000                                       
## 8  Structure       X5 0.9000000 0.0900000                                       
## 9  Structure       X6 0.9000000 0.1000000                                       
## 10 Structure       X1 0.0900000 0.9000000                                       
## 11 Structure       X2 0.1000000 0.9000000                                       
## 12 Structure       X3 0.1000000 0.9000000                                       
## 13            2.4151943 2.4069989 variance accounted                 SS loadings
## 14            0.4025324 0.4011665 variance accounted              Proportion Var
## 15            0.4025324 0.8036989 variance accounted              Cumulative Var
## 16            0.5008498 0.4991502 variance accounted        Proportion Explained
## 17            0.5008498 1.0000000 variance accounted       Cumulative Proportion
## 
## $instruction_loading_critical_values
##    sample critical_loading
## 1      50             0.75
## 2      60             0.70
## 3      70             0.65
## 4      85             0.60
## 5     100             0.55
## 6     120             0.50
## 7     150             0.45
## 8     200             0.40
## 9     250             0.35
## 10    350             0.30
## 
## $weights
##            PA1         PA2
## X1 -0.03563484  0.34879769
## X2 -0.03330409  0.34562171
## X3 -0.03429605  0.34741996
## X4  0.35215475 -0.03618723
## X5  0.34840281 -0.03623816
## X6  0.34090284 -0.03065831