library(tidyverse)
library(psych)
library(lavaan)
library(semPlot)
library(semPower)
library(knitr)
library(apaTables)
library(stats)
library(dplyr)
library(rstatix)

teacher2<- read.csv("teacher2.csv")

teacher2<- 
separate(data = teacher2, col = Q5, into = c("teach1", "Teach2"), sep = ",")%>%
  mutate(Level = case_when(teach1 %in% c("10th Grade", "11th Grade", "12th Grade", "10th Grade", "9th Grade") ~ "High_School",
        teach1 %in% c("6th Grade", "7th Grade", "8th Grade") ~ "Middle_School",
        teach1 %in% c("Kindergarten", "1st Grade", "2nd Grade", "3rd Grade", "4th Grade", "5th Grade") ~ "Elementary",
        teach1 == "Post Birth or Pre-K" ~ "Pre_K",
        teach1 == "Other (please explain)" ~ "Other"))

teacher2<- teacher2%>%
  mutate(gender = case_when(Q4 == "Female" ~ "Female",
         Q4 == "Male" ~ "Male"))

teacher2<- teacher2%>%
  mutate(Teach = Q17_1 + Q17_3 + Q17_5)%>%
  mutate(anx = Q19_1 + Q19_2 + Q19_3 + Q19_4 + Q19_5)%>%
  mutate(Dep =  Q20_2 + Q20_3 + Q20_5 + Q20_7 + Q20_8)%>%
  mutate(Dep2 = Q20_1 + Q20_2 + Q20_3 + Q20_4 + Q20_5 + Q20_6 + Q20_7 + Q20_8)%>%
  mutate(PROS =  Q23_3 + Q23_8 + Q23_9)%>%
  mutate(GOV = Q23_5 + Q23_6 + Q23_7) %>%
  mutate(COM = Q23_1 + Q23_2 + Q23_4) %>%
  mutate(ASSM = Q41_1 + Q41_2 + Q41_4)%>%
  mutate(TEFF = Q44_1 + Q44_2 + Q44_3 + Q44_4) %>%
  mutate(Leave = Q15_4 + Q21 + Q25 + Q29 + Q41_3)

teacher2<- teacher2%>%
mutate(locale = case_when(Q10 %in% c("Rural community", "Small community, non-rural") ~ "Small Rural",
        Q10 %in% c("Other", "Suburban Area", "Traditional public school", "Urban Area", "Small community, non-rural") ~ "Larger Community"))
library(dplyr)
descriptives<- dplyr:: select(teacher2, Teach, anx, Dep, PROS, GOV, COM, ASSM, TEFF, Leave)

descriptivetable<- psych::describe(descriptives)
write.csv(descriptivetable, "descriptives.csv")
descriptivetable
##       vars   n  mean   sd median trimmed  mad min max range  skew kurtosis   se
## Teach    1 621  9.30 1.76      9    9.37 1.48   3  12     9 -0.43     0.15 0.07
## anx      2 619 14.13 3.72     14   14.32 4.45   5  20    15 -0.40    -0.39 0.15
## Dep      3 619 12.12 3.42     12   12.13 2.97   5  20    15 -0.01    -0.02 0.14
## PROS     4 602  7.72 2.10      8    7.69 1.48   3  12     9 -0.01    -0.58 0.09
## GOV      5 591  6.16 2.12      6    6.10 1.48   3  12     9  0.30    -0.36 0.09
## COM      6 601  7.63 2.00      8    7.71 1.48   3  12     9 -0.32    -0.12 0.08
## ASSM     7 545  9.70 1.73     10    9.84 1.48   4  12     8 -0.53    -0.27 0.07
## TEFF     8 521 11.88 2.27     12   11.91 1.48   4  16    12 -0.25     0.64 0.10
## Leave    9 483 13.63 3.35     14   13.82 2.97   5  20    15 -0.52    -0.28 0.15
gendertable<-with(teacher2, table(gender))
genderprop<- prop.table(gendertable)

teachertable<- with(teacher2, table(Cont1))
teacherprop<- prop.table(teachertable)

gradetable<- with(teacher2, table(Level))
gradeprop<- prop.table(gradetable)
gendertable
## gender
## Female   Male 
##    502    156
genderprop
## gender
##    Female      Male 
## 0.7629179 0.2370821
teachertable
## Cont1
##              Elective English Language Arts    General Elementary 
##                    87                    70                   195 
##                  Math                 Other               Science 
##                    83                    46                    42 
##        Social Studies     Special Education 
##                    53                    89
teacherprop
## Cont1
##              Elective English Language Arts    General Elementary 
##            0.13082707            0.10526316            0.29323308 
##                  Math                 Other               Science 
##            0.12481203            0.06917293            0.06315789 
##        Social Studies     Special Education 
##            0.07969925            0.13383459
gradetable
## Level
##    Elementary   High_School Middle_School         Other         Pre_K 
##           277           166           172            34            25
gradeprop
## Level
##    Elementary   High_School Middle_School         Other         Pre_K 
##    0.41097923    0.24629080    0.25519288    0.05044510    0.03709199
#Teach and Gender
teachgender<-lm(Teach ~ gender, data = teacher2)
apa.aov.table(teachgender,"teachgenderanova.doc")
## 
## 
## ANOVA results using Teach as the dependent variable
##  
## 
##    Predictor       SS  df       MS        F    p partial_eta2
##  (Intercept) 39328.77   1 39328.77 12734.92 .000             
##       gender    11.51   1    11.51     3.73 .054          .01
##        Error  1871.49 606     3.09                           
##  CI_90_partial_eta2
##                    
##          [.00, .02]
##                    
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, Teach~gender)
## # A tibble: 1 x 7
##   .y.   group1 group2 effsize    n1    n2 magnitude 
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>     
## 1 Teach Female Male    -0.184   502   156 negligible
genderTeach<- na.omit(dplyr::select(teacher2, ResponseId, Teach, gender))
genderTeach<- genderTeach %>% 
  group_by(gender) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(Teach), 
             SD = sd(Teach, .75))

#Teach and Grade Level
teachgrade<-lm(Teach ~ Level, data = teacher2)
apa.aov.table(teachgrade,"teachlevelanova.doc")
## 
## 
## ANOVA results using Teach as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 22153.85   1 22153.85 7090.84 .000                                
##        Level     8.76   4     2.19    0.70 .591          .00         [.00, .01]
##        Error  1921.44 615     3.12                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, Teach~Level)
## # A tibble: 10 x 7
##    .y.   group1        group2         effsize    n1    n2 magnitude 
##  * <chr> <chr>         <chr>            <dbl> <int> <int> <ord>     
##  1 Teach Elementary    High_School   -0.0753    277   166 negligible
##  2 Teach Elementary    Middle_School -0.0785    277   172 negligible
##  3 Teach Elementary    Other         -0.186     277    34 negligible
##  4 Teach Elementary    Pre_K          0.203     277    25 small     
##  5 Teach High_School   Middle_School -0.00522   166   172 negligible
##  6 Teach High_School   Other         -0.107     166    34 negligible
##  7 Teach High_School   Pre_K          0.269     166    25 small     
##  8 Teach Middle_School Other         -0.0982    172    34 negligible
##  9 Teach Middle_School Pre_K          0.268     172    25 small     
## 10 Teach Other         Pre_K          0.377      34    25 small
teachLevel<- na.omit(dplyr::select(teacher2, ResponseId, Teach, Level))
teachLevel<- teachLevel %>% 
  group_by(Level) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(Teach), 
             SD = sd(Teach, .75))
teachLevel
## # A tibble: 5 x 4
##   Level             n   Avg    SD
##   <chr>         <int> <dbl> <dbl>
## 1 Elementary      260  9.23  1.68
## 2 High_School     155  9.36  1.78
## 3 Middle_School   151  9.37  1.88
## 4 Other            31  9.55  1.73
## 5 Pre_K            23  8.87  1.87
#Anxiety and Gender
anxgender<-lm(anx ~ gender, data = teacher2)
apa.aov.table(anxgender,"anxgenderanova.doc")
## 
## 
## ANOVA results using anx as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 97370.49   1 97370.49 7343.53 .000                                
##       gender   354.52   1   354.52   26.74 .000          .04         [.02, .07]
##        Error  7995.39 603    13.26                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, anx~gender)
## # A tibble: 1 x 7
##   .y.   group1 group2 effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 anx   Female Male     0.480   502   156 small
GenAnx<- na.omit(dplyr::select(teacher2, ResponseId, anx, gender))
GenAnx<- GenAnx %>% 
  group_by(gender) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(anx), 
             SD = sd(anx, .75))

#Anxiety and Grade Level
anxgrade<-lm(anx ~ Level, data = teacher2)
apa.aov.table(anxgrade,"anxlevelanova.doc")
## 
## 
## ANOVA results using anx as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 54484.68   1 54484.68 3989.30 .000                                
##        Level   190.42   4    47.60    3.49 .008          .02         [.00, .04]
##        Error  8372.16 613    13.66                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, anx~Level)
## # A tibble: 10 x 7
##    .y.   group1        group2         effsize    n1    n2 magnitude 
##  * <chr> <chr>         <chr>            <dbl> <int> <int> <ord>     
##  1 anx   Elementary    High_School    0.365     277   166 small     
##  2 anx   Elementary    Middle_School  0.0839    277   172 negligible
##  3 anx   Elementary    Other         -0.0418    277    34 negligible
##  4 anx   Elementary    Pre_K          0.102     277    25 negligible
##  5 anx   High_School   Middle_School -0.271     166   172 small     
##  6 anx   High_School   Other         -0.420     166    34 small     
##  7 anx   High_School   Pre_K         -0.298     166    25 small     
##  8 anx   Middle_School Other         -0.127     172    34 negligible
##  9 anx   Middle_School Pre_K          0.00694   172    25 negligible
## 10 anx   Other         Pre_K          0.152      34    25 negligible
ANXLevel<- na.omit(dplyr::select(teacher2, ResponseId, anx, Level))
ANXLevel<- ANXLevel %>% 
  group_by(Level) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(anx), 
             SD = sd(anx, .75))

GenAnx
## # A tibble: 2 x 4
##   gender     n   Avg    SD
##   <chr>  <int> <dbl> <dbl>
## 1 Female   458  14.6  3.56
## 2 Male     147  12.8  3.87
ANXLevel
## # A tibble: 5 x 4
##   Level             n   Avg    SD
##   <chr>         <int> <dbl> <dbl>
## 1 Elementary      257  14.6  3.69
## 2 High_School     158  13.2  3.63
## 3 Middle_School   149  14.2  3.90
## 4 Other            31  14.7  3.45
## 5 Pre_K            23  14.2  3.03
#Depression and Gender
Depgender<-lm(Dep ~ gender, data = teacher2)
apa.aov.table(Depgender,"Depgenderanova.doc")
## 
## 
## ANOVA results using Dep as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 70238.96   1 70238.96 6109.00 .000                                
##       gender   110.88   1   110.88    9.64 .002          .02         [.00, .04]
##        Error  6933.06 603    11.50                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, Dep~gender)
## # A tibble: 1 x 7
##   .y.   group1 group2 effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 Dep   Female Male     0.293   502   156 small
GenDep<- na.omit(dplyr::select(teacher2, ResponseId, Dep, gender))
GenDep<- GenDep %>% 
  group_by(gender) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(Dep), 
             SD = sd(Dep, .75))

#Depression and Grade Level
Depgrade<-lm(Dep ~ Level, data = teacher2)
apa.aov.table(Depgrade,"Deplevelanova.doc")
## 
## 
## ANOVA results using Dep as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 39466.98   1 39466.98 3387.87 .000                                
##        Level    73.51   4    18.38    1.58 .179          .01         [.00, .02]
##        Error  7141.14 613    11.65                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, Dep~Level)
## # A tibble: 10 x 7
##    .y.   group1        group2          effsize    n1    n2 magnitude 
##  * <chr> <chr>         <chr>             <dbl> <int> <int> <ord>     
##  1 Dep   Elementary    High_School    0.241      277   166 small     
##  2 Dep   Elementary    Middle_School  0.0216     277   172 negligible
##  3 Dep   Elementary    Other          0.0236     277    34 negligible
##  4 Dep   Elementary    Pre_K          0.131      277    25 negligible
##  5 Dep   High_School   Middle_School -0.214      166   172 small     
##  6 Dep   High_School   Other         -0.224      166    34 small     
##  7 Dep   High_School   Pre_K         -0.130      166    25 negligible
##  8 Dep   Middle_School Other          0.000890   172    34 negligible
##  9 Dep   Middle_School Pre_K          0.105      172    25 negligible
## 10 Dep   Other         Pre_K          0.110       34    25 negligible
DEPLevel<- na.omit(dplyr::select(teacher2, ResponseId, Dep, Level))
DEPLevel<- DEPLevel %>% 
  group_by(Level) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(Dep), 
             SD = sd(Dep, .75))

GenDep
## # A tibble: 2 x 4
##   gender     n   Avg    SD
##   <chr>  <int> <dbl> <dbl>
## 1 Female   459  12.4  3.36
## 2 Male     146  11.4  3.47
DEPLevel
## # A tibble: 5 x 4
##   Level             n   Avg    SD
##   <chr>         <int> <dbl> <dbl>
## 1 Elementary      258  12.4  3.39
## 2 High_School     156  11.5  3.43
## 3 Middle_School   150  12.3  3.55
## 4 Other            31  12.3  3.21
## 5 Pre_K            23  12.0  2.85
counselingdata<- dplyr::select(teacher2, Q11, Q14_1, Q14_2, Q14_3, Q14_4, Q14_5, Q15_1, Q15_2, Q15_3, Q15_4, Q17_1, Q17_2, Q17_3, Q17_4, Q17_5, Q19_1, Q19_2, Q19_3, Q19_4, Q19_5, Q20_1, Q20_2, Q20_3, Q20_4, Q20_5, Q20_6, Q20_7, Q20_8, Q20_9, Q20_10, Q21, Q23_1, Q23_2, Q23_3, Q23_4, Q23_5, Q23_6, Q23_7, Q23_8, Q23_9, Q23_10, Q24_1, Q24_2, Q24_3, Q24_4, Q24_5, Q24_6, Q24_7, Q24_8, Q24_9, Q24_10, Q25, Q27_1, Q27_2, Q27_3, Q27_4, Q27_5, Q27_6, Q27_7, Q27_8, Q28_1, Q28_2, Q28_3, Q28_4, Q28_5, Q28_6, Q28_7, Q28_8, Q29, Q30, Q32_1, Q32_2, Q32_3, Q32_4, Q32_5, Q32_6, Q32_7, Q37, Q38, Q39, Q41_1, Q41_2, Q41_3, Q41_4, Q41_5, Q41_6, Q41_7, Q41_8, Q41_9, Q41_10, Q44_1, Q44_2, Q44_3, Q44_4, Q45_1, Q45_2, Q45_3, Q45_4, Level, gender, Teach, anx, Dep, Dep2, PROS, ASSM, TEFF, Leave, Q16, Q22, Q26, Q33, Q40, Q42, Q43, Q46, Q50, Q53, Q56, Q58, Q60, Q62, Q63)


write.csv(counselingdata, "counselingdata.csv")
#Depression and Gender
Depgender2<-lm(Dep2 ~ gender, data = teacher2)
apa.aov.table(Depgender2,"Depgenderanovas.doc")
## 
## 
## ANOVA results using Dep2 as the dependent variable
##  
## 
##    Predictor        SS  df        MS       F    p partial_eta2
##  (Intercept) 182683.02   1 182683.02 6661.70 .000             
##       gender    223.10   1    223.10    8.14 .004          .01
##        Error  16316.62 595     27.42                          
##  CI_90_partial_eta2
##                    
##          [.00, .03]
##                    
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, Dep2~gender)
## # A tibble: 1 x 7
##   .y.   group1 group2 effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 Dep2  Female Male     0.271   502   156 small
GenDep2<- na.omit(dplyr::select(teacher2, ResponseId, Dep2, gender))
GenDep2<- GenDep2 %>% 
  dplyr::group_by(gender) %>% 
             dplyr::summarize(
             n = n_distinct(ResponseId),
             Avg = mean(Dep2), 
             SD = sd(Dep2, .75))

#Depression and Grade Level
Depgrade2<-lm(Dep2 ~ Level, data = teacher2)
apa.aov.table(Depgrade2,"Deplevelanovas.doc")
## 
## 
## ANOVA results using Dep2 as the dependent variable
##  
## 
##    Predictor        SS  df        MS       F    p partial_eta2
##  (Intercept) 103807.94   1 103807.94 3746.13 .000             
##        Level    243.22   4     60.80    2.19 .068          .01
##        Error  16764.96 605     27.71                          
##  CI_90_partial_eta2
##                    
##          [.00, .03]
##                    
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, Dep2~Level)
## # A tibble: 10 x 7
##    .y.   group1        group2        effsize    n1    n2 magnitude 
##  * <chr> <chr>         <chr>           <dbl> <int> <int> <ord>     
##  1 Dep2  Elementary    High_School    0.286    277   166 small     
##  2 Dep2  Elementary    Middle_School  0.0336   277   172 negligible
##  3 Dep2  Elementary    Other          0.0716   277    34 negligible
##  4 Dep2  Elementary    Pre_K          0.0356   277    25 negligible
##  5 Dep2  High_School   Middle_School -0.253    166   172 small     
##  6 Dep2  High_School   Other         -0.220    166    34 small     
##  7 Dep2  High_School   Pre_K         -0.267    166    25 small     
##  8 Dep2  Middle_School Other          0.0374   172    34 negligible
##  9 Dep2  Middle_School Pre_K          0        172    25 negligible
## 10 Dep2  Other         Pre_K         -0.0397    34    25 negligible
DEPLevel2<- na.omit(dplyr::select(teacher2, ResponseId, Dep2, Level))
DEPLevel2<- DEPLevel2 %>% 
  group_by(Level) %>% 
             dplyr::summarize(
             n = n_distinct(ResponseId),
             Avg = mean(Dep2), 
             SD = sd(Dep2, .75))

GenDep2
## # A tibble: 2 x 4
##   gender     n   Avg    SD
##   <chr>  <int> <dbl> <dbl>
## 1 Female   453  20.1  5.20
## 2 Male     144  18.7  5.34
DEPLevel2
## # A tibble: 5 x 4
##   Level             n   Avg    SD
##   <chr>         <int> <dbl> <dbl>
## 1 Elementary      255  20.2  5.24
## 2 High_School     154  18.6  5.42
## 3 Middle_School   147  20    5.26
## 4 Other            31  19.8  5.09
## 5 Pre_K            23  20    4.65
#Prof Supp and Gender
PROSgender<-lm(PROS ~ gender, data = teacher2)
apa.aov.table(PROSgender,"PROSgenderanova.doc")
## 
## 
## ANOVA results using PROS as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 26113.74   1 26113.74 5924.75 .000                                
##       gender    24.16   1    24.16    5.48 .020          .01         [.00, .03]
##        Error  2596.06 589     4.41                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, PROS~gender)
## # A tibble: 1 x 7
##   .y.   group1 group2 effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 PROS  Female Male    -0.232   502   156 small
PSGend<- na.omit(dplyr::select(teacher2, ResponseId, PROS, gender))
PSGend<- PSGend %>% 
  group_by(gender) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(PROS), 
             SD = sd(PROS, .75))

#Prof Supp and Grade Level
PROSgrade<-lm(PROS ~ Level, data = teacher2)
apa.aov.table(PROSgrade,"PROSlevelanova.doc")
## 
## 
## ANOVA results using PROS as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 15574.01   1 15574.01 3541.07 .000                                
##        Level    26.20   4     6.55    1.49 .204          .01         [.00, .02]
##        Error  2621.28 596     4.40                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, PROS~Level)
## # A tibble: 10 x 7
##    .y.   group1        group2        effsize    n1    n2 magnitude 
##  * <chr> <chr>         <chr>           <dbl> <int> <int> <ord>     
##  1 PROS  Elementary    High_School    0.0381   277   166 negligible
##  2 PROS  Elementary    Middle_School  0.0913   277   172 negligible
##  3 PROS  Elementary    Other          0.207    277    34 small     
##  4 PROS  Elementary    Pre_K          0.486    277    25 small     
##  5 PROS  High_School   Middle_School  0.0574   166   172 negligible
##  6 PROS  High_School   Other          0.176    166    34 negligible
##  7 PROS  High_School   Pre_K          0.466    166    25 small     
##  8 PROS  Middle_School Other          0.110    172    34 negligible
##  9 PROS  Middle_School Pre_K          0.383    172    25 small     
## 10 PROS  Other         Pre_K          0.284     34    25 small
PROLevel<- na.omit(dplyr::select(teacher2, ResponseId, PROS, Level))
PROLevel<- PROLevel %>% 
  group_by(Level) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(PROS), 
             SD = sd(PROS, .75))

PSGend
## # A tibble: 2 x 4
##   gender     n   Avg    SD
##   <chr>  <int> <dbl> <dbl>
## 1 Female   450  7.62  2.14
## 2 Male     141  8.09  1.95
PROLevel
## # A tibble: 5 x 4
##   Level             n   Avg    SD
##   <chr>         <int> <dbl> <dbl>
## 1 Elementary      253  7.85  2.11
## 2 High_School     151  7.77  1.96
## 3 Middle_School   145  7.65  2.21
## 4 Other            29  7.41  2.06
## 5 Pre_K            23  6.83  2.08
#Assessment and Gender
ASSMgender<-lm(ASSM ~ gender, data = teacher2)
apa.aov.table(ASSMgender,"ASSMgenderanova.doc")
## 
## 
## ANOVA results using ASSM as the dependent variable
##  
## 
##    Predictor       SS  df       MS        F    p partial_eta2
##  (Intercept) 39024.39   1 39024.39 12887.60 .000             
##       gender     4.85   1     4.85     1.60 .206          .00
##        Error  1616.98 534     3.03                           
##  CI_90_partial_eta2
##                    
##          [.00, .02]
##                    
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
 cohens_d(teacher2, ASSM~gender)
## # A tibble: 1 x 7
##   .y.   group1 group2 effsize    n1    n2 magnitude 
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>     
## 1 ASSM  Female Male     0.124   502   156 negligible
ASSMGen<- na.omit(dplyr::select(teacher2, ResponseId, ASSM, gender))
ASSMGen<- ASSMGen %>% 
  group_by(gender) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(ASSM), 
             SD = sd(ASSM, .75))

#Assessment and Grade Level
ASSMgrade<-lm(ASSM ~ Level, data = teacher2)
apa.aov.table(ASSMgrade,"ASSMlevelanova.doc")
## 
## 
## ANOVA results using ASSM as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 22660.21   1 22660.21 7762.27 .000                                
##        Level    57.86   4    14.46    4.96 .001          .04         [.01, .06]
##        Error  1573.49 539     2.92                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
asmd<-cohens_d(teacher2, ASSM~Level)

ASSMLevel<- na.omit(dplyr:: select(teacher2, ResponseId, ASSM, Level))
ASSMLevel<-ASSMLevel %>% 
  group_by(Level) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(ASSM), 
             SD = sd(ASSM, .75))
ASSMGen
## # A tibble: 2 x 4
##   gender     n   Avg    SD
##   <chr>  <int> <dbl> <dbl>
## 1 Female   410  9.76  1.68
## 2 Male     126  9.53  1.93
ASSMLevel
## # A tibble: 5 x 4
##   Level             n   Avg    SD
##   <chr>         <int> <dbl> <dbl>
## 1 Elementary      228  9.97  1.65
## 2 High_School     137  9.20  1.76
## 3 Middle_School   131  9.72  1.79
## 4 Other            27  9.56  1.42
## 5 Pre_K            21 10.2   1.84
write.csv(asmd, "asmd.csv")
#Efficacy and Gender
TEFFgender<-lm(TEFF ~ gender, data = teacher2)
apa.aov.table(TEFFgender,"TEFFgenderanova.doc")
## 
## 
## ANOVA results using TEFF as the dependent variable
##  
## 
##    Predictor       SS  df       MS        F    p partial_eta2
##  (Intercept) 55513.87   1 55513.87 10736.84 .000             
##       gender     5.09   1     5.09     0.98 .322          .00
##        Error  2636.91 510     5.17                           
##  CI_90_partial_eta2
##                    
##          [.00, .01]
##                    
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, TEFF~gender)
## # A tibble: 1 x 7
##   .y.   group1 group2 effsize    n1    n2 magnitude 
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>     
## 1 TEFF  Female Male     0.106   502   156 negligible
TEFFGen<- na.omit(dplyr::select(teacher2, ResponseId, TEFF, gender))
TEFFGen<- TEFFGen %>% 
  group_by(gender) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(TEFF), 
             SD = sd(TEFF, .75))

#Efficacy and Grade Level
TEFFgrade<-lm(TEFF ~ Level, data = teacher2)
apa.aov.table(TEFFgrade,"TEFFlevelanova.doc")
## 
## 
## ANOVA results using TEFF as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 33049.24   1 33049.24 6605.79 .000                                
##        Level    99.04   4    24.76    4.95 .001          .04         [.01, .06]
##        Error  2576.58 515     5.00                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
teffd<-cohens_d(teacher2, TEFF~Level)

TEFFLevel<- na.omit(dplyr::select(teacher2, ResponseId, TEFF, Level))
TEFFLevel<- TEFFLevel %>% 
  group_by(Level) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(TEFF), 
             SD = sd(TEFF, .75))
TEFFGen
## # A tibble: 2 x 4
##   gender     n   Avg    SD
##   <chr>  <int> <dbl> <dbl>
## 1 Female   390  11.9  2.32
## 2 Male     122  11.7  2.10
TEFFLevel
## # A tibble: 5 x 4
##   Level             n   Avg    SD
##   <chr>         <int> <dbl> <dbl>
## 1 Elementary      217  12.3  2.38
## 2 High_School     129  11.5  2.15
## 3 Middle_School   129  11.4  2.11
## 4 Other            25  12.2  2.31
## 5 Pre_K            20  12.0  1.79
write.csv(teffd, "teffd.csv")
#leave and Gender
LVgender<-lm(Leave ~ gender, data = teacher2)
apa.aov.table(LVgender,"Leavegenderanova.doc")
## 
## 
## ANOVA results using Leave as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 68337.78   1 68337.78 6072.17 .000                                
##       gender    36.52   1    36.52    3.25 .072          .01         [.00, .02]
##        Error  5323.27 473    11.25                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
cohens_d(teacher2, Leave~gender)
## # A tibble: 1 x 7
##   .y.   group1 group2 effsize    n1    n2 magnitude 
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>     
## 1 Leave Female Male     0.193   502   156 negligible
LVGen<- na.omit(dplyr::select(teacher2, ResponseId, Leave, gender))
LVGen<- LVGen %>% 
  group_by(gender) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(Leave), 
             SD = sd(Leave, .75))

#leave and Grade Level
LVgrade<-lm(Leave ~ Level, data = teacher2)
apa.aov.table(LVgrade,"Leavelevelanova.doc")
## 
## 
## ANOVA results using Leave as the dependent variable
##  
## 
##    Predictor       SS  df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 39761.10   1 39761.10 3585.66 .000                                
##        Level   121.61   4    30.40    2.74 .028          .02         [.00, .04]
##        Error  5289.42 477    11.09                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
LVD<-cohens_d(teacher2, Leave~Level)

LVLevel<- na.omit(dplyr::select(teacher2, ResponseId, Leave, Level))
LVLevel<- LVLevel %>% 
  group_by(Level) %>% 
              summarize(
             n = n_distinct(ResponseId),
             Avg = mean(Leave), 
             SD = sd(Leave, .75))
LVGen
## # A tibble: 2 x 4
##   gender     n   Avg    SD
##   <chr>  <int> <dbl> <dbl>
## 1 Female   360  13.8  3.36
## 2 Male     115  13.1  3.35
LVLevel
## # A tibble: 5 x 4
##   Level             n   Avg    SD
##   <chr>         <int> <dbl> <dbl>
## 1 Elementary      205  13.9  3.33
## 2 High_School     120  12.9  3.27
## 3 Middle_School   117  13.8  3.47
## 4 Other            21  12.8  3.32
## 5 Pre_K            19  14.8  2.72
write.csv(LVD, "LeaveD.csv")
teacher2$Q15_4b<- as.character(teacher2$Q15_4)

## Anxiety
TukeyHSD(aov(anx ~ Level, data = teacher2))
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = anx ~ Level, data = teacher2)
## 
## $Level
##                                  diff        lwr        upr     p adj
## High_School-Elementary    -1.33879230 -2.3609551 -0.3166294 0.0033563
## Middle_School-Elementary  -0.31870055 -1.3598054  0.7224043 0.9188549
## Other-Elementary           0.14936614 -1.7730172  2.0717494 0.9995456
## Pre_K-Elementary          -0.34291998 -2.5435128  1.8576728 0.9931008
## Middle_School-High_School  1.02009175 -0.1345271  2.1747106 0.1120739
## Other-High_School          1.48815843 -0.4979944  3.4743113 0.2435892
## Pre_K-High_School          0.99587232 -1.2606414  3.2523860 0.7470906
## Other-Middle_School        0.46806668 -1.5279006  2.4640340 0.9681609
## Pre_K-Middle_School       -0.02421943 -2.2893765  2.2409376 0.9999998
## Pre_K-Other               -0.49228612 -3.2748380  2.2902657 0.9888124
### Assessment
TukeyHSD(aov(ASSM ~ Level, data = teacher2))
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = ASSM ~ Level, data = teacher2)
## 
## $Level
##                                 diff         lwr        upr     p adj
## High_School-Elementary    -0.7722180 -1.27773590 -0.2667000 0.0003259
## Middle_School-Elementary  -0.2517410 -0.76443945  0.2609575 0.6638017
## Other-Elementary          -0.4137427 -1.36552721  0.5380418 0.7572898
## Pre_K-Elementary           0.2687970 -0.79765290  1.3352469 0.9586540
## Middle_School-High_School  0.5204770 -0.05098762  1.0919415 0.0937340
## Other-High_School          0.3584753 -0.62621039  1.3431609 0.8569605
## Pre_K-High_School          1.0410149 -0.05489903  2.1369289 0.0717706
## Other-Middle_School       -0.1620017 -1.15039289  0.8263895 0.9916150
## Pre_K-Middle_School        0.5205380 -0.57870664  1.6197826 0.6937557
## Pre_K-Other                0.6825397 -0.67811193  2.0431913 0.6453002
### Teaching Efficacy
TukeyHSD(aov(TEFF ~ Level, data = teacher2))
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = TEFF ~ Level, data = teacher2)
## 
## $Level
##                                 diff        lwr        upr     p adj
## High_School-Elementary    -0.8448898 -1.5256289 -0.1641507 0.0065500
## Middle_School-Elementary  -0.9534169 -1.6341560 -0.2726778 0.0013306
## Other-Elementary          -0.1410138 -1.4342421  1.1522144 0.9982683
## Pre_K-Elementary          -0.3910138 -1.8218723  1.0398447 0.9449479
## Middle_School-High_School -0.1085271 -0.8709353  0.6538810 0.9951154
## Other-High_School          0.7038760 -0.6341449  2.0418968 0.6019920
## Pre_K-High_School          0.4538760 -1.0175915  1.9253434 0.9165693
## Other-Middle_School        0.8124031 -0.5256177  2.1504239 0.4584861
## Pre_K-Middle_School        0.5624031 -0.9090643  2.0338705 0.8336089
## Pre_K-Other               -0.2500000 -2.0869132  1.5869132 0.9958935
### Leave Efficacy
TukeyHSD(aov(Leave ~ Level, data = teacher2))
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Leave ~ Level, data = teacher2)
## 
## $Level
##                                 diff        lwr        upr     p adj
## High_School-Elementary    -1.0018293 -2.0498999 0.04624135 0.0688013
## Middle_School-Elementary  -0.1490515 -1.2055636 0.90746065 0.9952749
## Other-Elementary          -1.1649245 -3.2541440 0.92429494 0.5454984
## Pre_K-Elementary           0.8626444 -1.3240430 3.04933179 0.8167078
## Middle_School-High_School  0.8527778 -0.3319185 2.03747409 0.2817981
## Other-High_School         -0.1630952 -2.3199739 1.99378338 0.9995902
## Pre_K-High_School          1.8644737 -0.3869457 4.11589304 0.1573041
## Other-Middle_School       -1.0158730 -3.1768661 1.14512010 0.6992407
## Pre_K-Middle_School        1.0116959 -1.2436655 3.26705729 0.7348478
## Pre_K-Other                2.0275689 -0.8595187 4.91465655 0.3064501
matrix<- dplyr::select(teacher2, Teach,  PROS, GOV, COM, ASSM, TEFF,)
matrix2<-na.omit(matrix)

apa.cor.table(matrix, filename = "correlation.doc")
## 
## 
## Means, standard deviations, and correlations with confidence intervals
##  
## 
##   Variable M     SD   1           2            3            4          
##   1. Teach 9.30  1.76                                                  
##                                                                        
##   2. PROS  7.72  2.10 .39**                                            
##                       [.32, .46]                                       
##                                                                        
##   3. GOV   6.16  2.12 .34**       .39**                                
##                       [.27, .41]  [.32, .46]                           
##                                                                        
##   4. COM   7.63  2.00 .48**       .39**        .50**                   
##                       [.41, .54]  [.32, .46]   [.43, .55]              
##                                                                        
##   5. ASSM  9.70  1.73 -.01        -.17**       -.17**       -.08       
##                       [-.10, .07] [-.25, -.09] [-.25, -.09] [-.16, .01]
##                                                                        
##   6. TEFF  11.88 2.27 .39**       .14**        .20**        .46**      
##                       [.31, .46]  [.05, .22]   [.11, .28]   [.39, .53] 
##                                                                        
##   5          
##              
##              
##              
##              
##              
##              
##              
##              
##              
##              
##              
##              
##              
##              
##   .05        
##   [-.04, .13]
##              
## 
## Note. M and SD are used to represent mean and standard deviation, respectively.
## Values in square brackets indicate the 95% confidence interval.
## The confidence interval is a plausible range of population correlations 
## that could have caused the sample correlation (Cumming, 2014).
##  * indicates p < .05. ** indicates p < .01.
## 
#Build data set for Writing Apprehension EFA

EFAData<- read.csv("EFAData.csv")

IPSEFA<-fa(r = EFAData, nfactors = 3, rotate= 'oblimin')
loadings <- unclass(IPSEFA$loadings)
h2 <- IPSEFA$communalities
#There is also factors_data$communality which has same values
u2 <- IPSEFA$uniquenesses
com <- IPSEFA$complexity
EFA <- cbind(loadings, h2, u2, com)
EFA
##                MR1         MR2          MR3         h2        u2      com
## X       0.13701206 -0.10258100 -0.027125974 0.01617835 0.9838288 1.945041
## Q23_1  -0.02229822 -0.09148562  0.818594701 0.60596262 0.3940362 1.026479
## Q23_2  -0.01145255  0.09420182  0.779050016 0.66375329 0.3362476 1.029675
## Q23_3  -0.11255183  0.44289848  0.032870330 0.17306547 0.8269328 1.140298
## Q23_4   0.19667523  0.14922216  0.522969724 0.51549346 0.4845068 1.456567
## Q23_5   0.86338828 -0.09811495  0.100926082 0.76125758 0.2387438 1.053491
## Q23_6   0.86376750  0.08294811 -0.076558917 0.75771363 0.2422852 1.034295
## Q23_7   0.48050141  0.18671265  0.080493493 0.39982869 0.6001707 1.358140
## Q23_8  -0.12948205  0.77413116  0.029820277 0.54132613 0.4586734 1.058957
## Q23_9   0.11461797  0.81838406  0.006064608 0.77162996 0.2283703 1.039327
## Q23_10  0.35983605  0.45204979  0.118099642 0.57414507 0.4258545 2.059821
IPSEFA
## Factor Analysis using method =  minres
## Call: fa(r = EFAData, nfactors = 3, rotate = "oblimin")
## Standardized loadings (pattern matrix) based upon correlation matrix
##          MR1   MR2   MR3    h2   u2 com
## X       0.14 -0.10 -0.03 0.016 0.98 1.9
## Q23_1  -0.02 -0.09  0.82 0.606 0.39 1.0
## Q23_2  -0.01  0.09  0.78 0.664 0.34 1.0
## Q23_3  -0.11  0.44  0.03 0.173 0.83 1.1
## Q23_4   0.20  0.15  0.52 0.515 0.48 1.5
## Q23_5   0.86 -0.10  0.10 0.761 0.24 1.1
## Q23_6   0.86  0.08 -0.08 0.758 0.24 1.0
## Q23_7   0.48  0.19  0.08 0.400 0.60 1.4
## Q23_8  -0.13  0.77  0.03 0.541 0.46 1.1
## Q23_9   0.11  0.82  0.01 0.772 0.23 1.0
## Q23_10  0.36  0.45  0.12 0.574 0.43 2.1
## 
##                        MR1  MR2  MR3
## SS loadings           2.12 1.93 1.73
## Proportion Var        0.19 0.18 0.16
## Cumulative Var        0.19 0.37 0.53
## Proportion Explained  0.37 0.33 0.30
## Cumulative Proportion 0.37 0.70 1.00
## 
##  With factor correlations of 
##      MR1  MR2  MR3
## MR1 1.00 0.45 0.46
## MR2 0.45 1.00 0.39
## MR3 0.46 0.39 1.00
## 
## Mean item complexity =  1.3
## Test of the hypothesis that 3 factors are sufficient.
## 
## The degrees of freedom for the null model are  55  and the objective function was  4.48 with Chi Square of  870.64
## The degrees of freedom for the model are 25  and the objective function was  0.24 
## 
## The root mean square of the residuals (RMSR) is  0.03 
## The df corrected root mean square of the residuals is  0.05 
## 
## The harmonic number of observations is  200 with the empirical chi square  21.69  with prob <  0.65 
## The total number of observations was  200  with Likelihood Chi Square =  47  with prob <  0.0049 
## 
## Tucker Lewis Index of factoring reliability =  0.94
## RMSEA index =  0.066  and the 90 % confidence intervals are  0.036 0.095
## BIC =  -85.45
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                    MR1  MR2  MR3
## Correlation of (regression) scores with factors   0.94 0.92 0.90
## Multiple R square of scores with factors          0.88 0.85 0.82
## Minimum correlation of possible factor scores     0.76 0.70 0.64
write.csv(EFA, "EFA.csv")
LVModel<- 
  
  '
LV=~ Q15_4 + Q25 + Q29 + Q41_3

 '

fitlv<- cfa(LVModel, data=teacher2)



summary(fitlv, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-12 ended normally after 18 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         8
## 
##                                                   Used       Total
##   Number of observations                           487         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 8.624
##   Degrees of freedom                                 2
##   P-value (Chi-square)                           0.013
## 
## Model Test Baseline Model:
## 
##   Test statistic                               342.394
##   Degrees of freedom                                 6
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.980
##   Tucker-Lewis Index (TLI)                       0.941
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2448.454
##   Loglikelihood unrestricted model (H1)      -2444.142
##                                                       
##   Akaike (AIC)                                4912.908
##   Bayesian (BIC)                              4946.414
##   Sample-size adjusted Bayesian (BIC)         4921.022
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.082
##   90 Percent confidence interval - lower         0.032
##   90 Percent confidence interval - upper         0.142
##   P-value RMSEA <= 0.05                          0.128
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.026
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   LV =~                                                                 
##     Q15_4             1.000                               0.741    0.675
##     Q25               0.943    0.095    9.931    0.000    0.699    0.811
##     Q29               0.567    0.064    8.825    0.000    0.420    0.494
##     Q41_3             0.499    0.067    7.412    0.000    0.370    0.405
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q15_4             0.656    0.065   10.132    0.000    0.656    0.544
##    .Q25               0.255    0.046    5.556    0.000    0.255    0.343
##    .Q29               0.548    0.039   13.884    0.000    0.548    0.756
##    .Q41_3             0.698    0.048   14.607    0.000    0.698    0.836
##     LV                0.550    0.081    6.753    0.000    1.000    1.000
parameterEstimates(fitlv, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  dplyr:: select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
LV Q15_4 1.000 0.000 NA NA 0.675
LV Q25 0.943 0.095 9.931 0 0.811
LV Q29 0.567 0.064 8.825 0 0.494
LV Q41_3 0.499 0.067 7.412 0 0.405
residuals(fitlv, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##       Q15_4  Q25    Q29    Q41_3 
## Q15_4  0.000                     
## Q25    0.003  0.000              
## Q29   -0.047  0.019  0.000       
## Q41_3  0.049 -0.033  0.026  0.000
semPaths(fitlv, "par", edge.label.cex = 1.2, fade = FALSE)

Support<- 
  
  '
SUP=~ Q23_5 + Q23_6 + Q23_7 + Q23_3 + Q23_8 + Q23_9 + Q23_10 + Q23_1 + Q23_2 + Q23_4


'

fitC<- cfa(Support, data=teacher2)



summary(fitC, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-12 ended normally after 26 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        20
## 
##                                                   Used       Total
##   Number of observations                           583         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                               879.500
##   Degrees of freedom                                35
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              2679.393
##   Degrees of freedom                                45
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.679
##   Tucker-Lewis Index (TLI)                       0.588
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -6314.829
##   Loglikelihood unrestricted model (H1)      -5875.080
##                                                       
##   Akaike (AIC)                               12669.659
##   Bayesian (BIC)                             12757.023
##   Sample-size adjusted Bayesian (BIC)        12693.530
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.203
##   90 Percent confidence interval - lower         0.192
##   90 Percent confidence interval - upper         0.215
##   P-value RMSEA <= 0.05                          0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.105
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   SUP =~                                                                
##     Q23_5             1.000                               0.541    0.684
##     Q23_6             1.086    0.071   15.205    0.000    0.587    0.710
##     Q23_7             0.963    0.073   13.171    0.000    0.521    0.606
##     Q23_3             0.400    0.058    6.873    0.000    0.216    0.307
##     Q23_8             0.972    0.083   11.730    0.000    0.526    0.535
##     Q23_9             1.226    0.080   15.240    0.000    0.663    0.712
##     Q23_10            1.286    0.080   16.135    0.000    0.695    0.761
##     Q23_1             0.775    0.067   11.508    0.000    0.419    0.524
##     Q23_2             0.912    0.068   13.478    0.000    0.493    0.621
##     Q23_4             0.952    0.066   14.355    0.000    0.515    0.666
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q23_5             0.333    0.022   14.964    0.000    0.333    0.532
##    .Q23_6             0.339    0.023   14.630    0.000    0.339    0.496
##    .Q23_7             0.468    0.030   15.688    0.000    0.468    0.633
##    .Q23_3             0.449    0.027   16.826    0.000    0.449    0.906
##    .Q23_8             0.690    0.043   16.118    0.000    0.690    0.714
##    .Q23_9             0.428    0.029   14.604    0.000    0.428    0.493
##    .Q23_10            0.352    0.026   13.770    0.000    0.352    0.421
##    .Q23_1             0.465    0.029   16.170    0.000    0.465    0.726
##    .Q23_2             0.388    0.025   15.571    0.000    0.388    0.614
##    .Q23_4             0.333    0.022   15.166    0.000    0.333    0.557
##     SUP               0.292    0.033    8.917    0.000    1.000    1.000
parameterEstimates(fitC, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
SUP Q23_5 1.000 0.000 NA NA 0.684
SUP Q23_6 1.086 0.071 15.205 0 0.710
SUP Q23_7 0.963 0.073 13.171 0 0.606
SUP Q23_3 0.400 0.058 6.873 0 0.307
SUP Q23_8 0.972 0.083 11.730 0 0.535
SUP Q23_9 1.226 0.080 15.240 0 0.712
SUP Q23_10 1.286 0.080 16.135 0 0.761
SUP Q23_1 0.775 0.067 11.508 0 0.524
SUP Q23_2 0.912 0.068 13.478 0 0.621
SUP Q23_4 0.952 0.066 14.355 0 0.666
residuals(fitC, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##        Q23_5  Q23_6  Q23_7  Q23_3  Q23_8  Q23_9  Q23_10 Q23_1  Q23_2  Q23_4 
## Q23_5   0.000                                                               
## Q23_6   0.248  0.000                                                        
## Q23_7   0.071  0.142  0.000                                                 
## Q23_3  -0.133 -0.084 -0.010  0.000                                          
## Q23_8  -0.181 -0.094 -0.047  0.221  0.000                                   
## Q23_9  -0.127 -0.080 -0.032  0.070  0.270  0.000                            
## Q23_10 -0.033 -0.036 -0.038 -0.027  0.090  0.185  0.000                     
## Q23_1  -0.027 -0.081 -0.065  0.003 -0.087 -0.099 -0.056  0.000              
## Q23_2  -0.023 -0.057 -0.063  0.023 -0.064 -0.084 -0.078  0.327  0.000       
## Q23_4   0.038 -0.050 -0.025  0.048 -0.074 -0.080 -0.063  0.159  0.199  0.000
semPaths(fitC, "par", edge.label.cex = 1.2, fade = FALSE)

OnSupport2F<- 
  
  '
GOVs=~ Q23_5 + Q23_6 + Q23_7
PRO=~ Q23_3 + Q23_8 + Q23_9 + Q23_10
COMs=~ Q23_1 + Q23_2 + Q23_4


'

fitd<- cfa(OnSupport2F, data=teacher2)



summary(fitd, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-12 ended normally after 41 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        23
## 
##                                                   Used       Total
##   Number of observations                           583         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                               211.674
##   Degrees of freedom                                32
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              2679.393
##   Degrees of freedom                                45
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.932
##   Tucker-Lewis Index (TLI)                       0.904
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5980.916
##   Loglikelihood unrestricted model (H1)      -5875.080
##                                                       
##   Akaike (AIC)                               12007.833
##   Bayesian (BIC)                             12108.301
##   Sample-size adjusted Bayesian (BIC)        12035.285
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.098
##   90 Percent confidence interval - lower         0.086
##   90 Percent confidence interval - upper         0.111
##   P-value RMSEA <= 0.05                          0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.063
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   GOVs =~                                                               
##     Q23_5             1.000                               0.645    0.816
##     Q23_6             1.141    0.055   20.884    0.000    0.736    0.890
##     Q23_7             0.851    0.054   15.677    0.000    0.549    0.639
##   PRO =~                                                                
##     Q23_3             1.000                               0.236    0.335
##     Q23_8             2.870    0.380    7.552    0.000    0.678    0.689
##     Q23_9             3.560    0.452    7.872    0.000    0.841    0.903
##     Q23_10            3.114    0.400    7.787    0.000    0.735    0.805
##   COMs =~                                                               
##     Q23_1             1.000                               0.584    0.729
##     Q23_2             1.159    0.067   17.253    0.000    0.677    0.852
##     Q23_4             0.976    0.061   16.047    0.000    0.570    0.737
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   GOVs ~~                                                               
##     PRO               0.087    0.014    6.349    0.000    0.570    0.570
##     COMs              0.214    0.023    9.228    0.000    0.568    0.568
##   PRO ~~                                                                
##     COMs              0.072    0.012    6.065    0.000    0.521    0.521
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q23_5             0.209    0.019   10.982    0.000    0.209    0.334
##    .Q23_6             0.142    0.020    6.998    0.000    0.142    0.208
##    .Q23_7             0.438    0.029   15.301    0.000    0.438    0.592
##    .Q23_3             0.440    0.026   16.792    0.000    0.440    0.888
##    .Q23_8             0.507    0.034   14.863    0.000    0.507    0.525
##    .Q23_9             0.160    0.024    6.682    0.000    0.160    0.185
##    .Q23_10            0.294    0.025   11.956    0.000    0.294    0.352
##    .Q23_1             0.300    0.023   13.145    0.000    0.300    0.468
##    .Q23_2             0.173    0.021    8.307    0.000    0.173    0.274
##    .Q23_4             0.274    0.021   12.945    0.000    0.274    0.457
##     GOVs              0.416    0.037   11.111    0.000    1.000    1.000
##     PRO               0.056    0.014    3.929    0.000    1.000    1.000
##     COMs              0.341    0.036    9.411    0.000    1.000    1.000
parameterEstimates(fitd, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
GOVs Q23_5 1.000 0.000 NA NA 0.816
GOVs Q23_6 1.141 0.055 20.884 0 0.890
GOVs Q23_7 0.851 0.054 15.677 0 0.639
PRO Q23_3 1.000 0.000 NA NA 0.335
PRO Q23_8 2.870 0.380 7.552 0 0.689
PRO Q23_9 3.560 0.452 7.872 0 0.903
PRO Q23_10 3.114 0.400 7.787 0 0.805
COMs Q23_1 1.000 0.000 NA NA 0.729
COMs Q23_2 1.159 0.067 17.253 0 0.852
COMs Q23_4 0.976 0.061 16.047 0 0.737
residuals(fitd, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##        Q23_5  Q23_6  Q23_7  Q23_3  Q23_8  Q23_9  Q23_10 Q23_1  Q23_2  Q23_4 
## Q23_5   0.000                                                               
## Q23_6   0.008  0.000                                                        
## Q23_7  -0.036  0.004  0.000                                                 
## Q23_3  -0.079 -0.036  0.053  0.000                                          
## Q23_8  -0.136 -0.064  0.026  0.154  0.000                                   
## Q23_9  -0.060 -0.032  0.070 -0.014  0.029  0.000                            
## Q23_10  0.113  0.096  0.130 -0.063 -0.058  0.000  0.000                     
## Q23_1  -0.007 -0.078 -0.012  0.036 -0.069 -0.069  0.037  0.000              
## Q23_2   0.006 -0.047  0.004  0.064 -0.039 -0.043  0.037  0.032  0.000       
## Q23_4   0.151  0.050  0.111  0.123  0.017  0.047  0.134 -0.030 -0.016  0.000
semPaths(fitd, "par", edge.label.cex = 1.2, fade = FALSE)

AnxModel<-
  '

ANXs=~ Q19_1 + Q19_2 + Q19_3 + Q19_4 + Q19_5
'
fitAnx<- cfa(AnxModel, data=teacher2)

summary(fitAnx, fit.measures=TRUE, standardized=TRUE)
## lavaan 0.6-12 ended normally after 21 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        10
## 
##                                                   Used       Total
##   Number of observations                           619         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                                19.833
##   Degrees of freedom                                 5
##   P-value (Chi-square)                           0.001
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1699.553
##   Degrees of freedom                                10
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.991
##   Tucker-Lewis Index (TLI)                       0.982
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -3202.234
##   Loglikelihood unrestricted model (H1)      -3192.318
##                                                       
##   Akaike (AIC)                                6424.469
##   Bayesian (BIC)                              6468.750
##   Sample-size adjusted Bayesian (BIC)         6437.002
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.069
##   90 Percent confidence interval - lower         0.039
##   90 Percent confidence interval - upper         0.102
##   P-value RMSEA <= 0.05                          0.135
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.017
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   ANXs =~                                                               
##     Q19_1             1.000                               0.743    0.811
##     Q19_2             0.899    0.043   21.085    0.000    0.668    0.775
##     Q19_3             1.036    0.042   24.470    0.000    0.770    0.873
##     Q19_4             0.934    0.043   21.597    0.000    0.694    0.789
##     Q19_5             0.855    0.047   18.011    0.000    0.635    0.684
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q19_1             0.288    0.021   13.738    0.000    0.288    0.342
##    .Q19_2             0.297    0.020   14.609    0.000    0.297    0.400
##    .Q19_3             0.185    0.017   11.177    0.000    0.185    0.238
##    .Q19_4             0.292    0.020   14.299    0.000    0.292    0.377
##    .Q19_5             0.459    0.029   15.871    0.000    0.459    0.532
##     ANXs              0.552    0.047   11.821    0.000    1.000    1.000
parameterEstimates(fitAnx, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
ANXs Q19_1 1.000 0.000 NA NA 0.811
ANXs Q19_2 0.899 0.043 21.085 0 0.775
ANXs Q19_3 1.036 0.042 24.470 0 0.873
ANXs Q19_4 0.934 0.043 21.597 0 0.789
ANXs Q19_5 0.855 0.047 18.011 0 0.684
residuals(fitAnx, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##       Q19_1  Q19_2  Q19_3  Q19_4  Q19_5 
## Q19_1  0.000                            
## Q19_2  0.018  0.000                     
## Q19_3 -0.019  0.013  0.000              
## Q19_4 -0.008 -0.028  0.018  0.000       
## Q19_5  0.040 -0.026 -0.015  0.004  0.000
semPaths(fitAnx, "par", edge.label.cex = 1.2, fade = FALSE)

DepModel<-
  'DEPs=~ Q20_1 + Q20_2 + Q20_3 + Q20_4 + Q20_5 + Q20_6 + Q20_7 + Q20_8'
fitdep<- cfa(DepModel, data=teacher2)

summary(fitdep, fit.measures=TRUE, standardized=TRUE)
## lavaan 0.6-12 ended normally after 21 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        16
## 
##                                                   Used       Total
##   Number of observations                           611         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                               151.742
##   Degrees of freedom                                20
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              2426.622
##   Degrees of freedom                                28
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.945
##   Tucker-Lewis Index (TLI)                       0.923
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5093.503
##   Loglikelihood unrestricted model (H1)      -5017.632
##                                                       
##   Akaike (AIC)                               10219.006
##   Bayesian (BIC)                             10289.648
##   Sample-size adjusted Bayesian (BIC)        10238.851
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.104
##   90 Percent confidence interval - lower         0.089
##   90 Percent confidence interval - upper         0.120
##   P-value RMSEA <= 0.05                          0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.041
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   DEPs =~                                                               
##     Q20_1             1.000                               0.677    0.795
##     Q20_2             1.064    0.048   22.379    0.000    0.720    0.829
##     Q20_3             0.956    0.053   18.188    0.000    0.647    0.701
##     Q20_4             0.801    0.046   17.554    0.000    0.542    0.681
##     Q20_5             0.876    0.052   16.960    0.000    0.593    0.661
##     Q20_6             0.978    0.052   18.927    0.000    0.662    0.724
##     Q20_7             1.006    0.050   20.096    0.000    0.681    0.760
##     Q20_8             0.694    0.046   15.010    0.000    0.470    0.595
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q20_1             0.266    0.019   14.270    0.000    0.266    0.367
##    .Q20_2             0.237    0.018   13.393    0.000    0.237    0.313
##    .Q20_3             0.434    0.028   15.692    0.000    0.434    0.509
##    .Q20_4             0.341    0.021   15.884    0.000    0.341    0.537
##    .Q20_5             0.453    0.028   16.045    0.000    0.453    0.563
##    .Q20_6             0.397    0.026   15.435    0.000    0.397    0.475
##    .Q20_7             0.339    0.023   14.934    0.000    0.339    0.422
##    .Q20_8             0.402    0.024   16.467    0.000    0.402    0.646
##     DEPs              0.458    0.040   11.452    0.000    1.000    1.000
parameterEstimates(fitdep, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
DEPs Q20_1 1.000 0.000 NA NA 0.795
DEPs Q20_2 1.064 0.048 22.379 0 0.829
DEPs Q20_3 0.956 0.053 18.188 0 0.701
DEPs Q20_4 0.801 0.046 17.554 0 0.681
DEPs Q20_5 0.876 0.052 16.960 0 0.661
DEPs Q20_6 0.978 0.052 18.927 0 0.724
DEPs Q20_7 1.006 0.050 20.096 0 0.760
DEPs Q20_8 0.694 0.046 15.010 0 0.595
residuals(fitdep, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##       Q20_1  Q20_2  Q20_3  Q20_4  Q20_5  Q20_6  Q20_7  Q20_8 
## Q20_1  0.000                                                 
## Q20_2  0.064  0.000                                          
## Q20_3 -0.034 -0.022  0.000                                   
## Q20_4  0.005 -0.039  0.090  0.000                            
## Q20_5 -0.006 -0.059  0.058  0.113  0.000                     
## Q20_6 -0.039  0.032 -0.022 -0.053 -0.003  0.000              
## Q20_7 -0.030 -0.020  0.004  0.001 -0.021  0.040  0.000       
## Q20_8 -0.008 -0.004 -0.027 -0.094 -0.011  0.032  0.081  0.000
semPaths(fitdep, "par", edge.label.cex = 1.2, fade = FALSE)

DepModel2<-
  'DEPs=~ Q20_1 + Q20_2 + Q20_3 + Q20_5 + Q20_6 + Q20_7 + Q20_8'
fitdep2<- cfa(DepModel2, data=teacher2)

summary(fitdep2, fit.measures=TRUE, standardized=TRUE)
## lavaan 0.6-12 ended normally after 21 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        14
## 
##                                                   Used       Total
##   Number of observations                           616         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                                79.787
##   Degrees of freedom                                14
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              2073.338
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.968
##   Tucker-Lewis Index (TLI)                       0.952
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -4567.307
##   Loglikelihood unrestricted model (H1)      -4527.413
##                                                       
##   Akaike (AIC)                                9162.614
##   Bayesian (BIC)                              9224.539
##   Sample-size adjusted Bayesian (BIC)         9180.092
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.087
##   90 Percent confidence interval - lower         0.069
##   90 Percent confidence interval - upper         0.106
##   P-value RMSEA <= 0.05                          0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.030
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   DEPs =~                                                               
##     Q20_1             1.000                               0.680    0.796
##     Q20_2             1.081    0.047   22.778    0.000    0.736    0.843
##     Q20_3             0.933    0.053   17.692    0.000    0.635    0.685
##     Q20_5             0.842    0.052   16.259    0.000    0.573    0.638
##     Q20_6             0.994    0.051   19.330    0.000    0.676    0.737
##     Q20_7             1.007    0.050   20.117    0.000    0.685    0.762
##     Q20_8             0.721    0.046   15.600    0.000    0.491    0.616
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q20_1             0.267    0.019   14.072    0.000    0.267    0.366
##    .Q20_2             0.220    0.017   12.604    0.000    0.220    0.289
##    .Q20_3             0.455    0.029   15.792    0.000    0.455    0.530
##    .Q20_5             0.478    0.030   16.191    0.000    0.478    0.593
##    .Q20_6             0.383    0.025   15.174    0.000    0.383    0.456
##    .Q20_7             0.339    0.023   14.785    0.000    0.339    0.420
##    .Q20_8             0.394    0.024   16.343    0.000    0.394    0.621
##     DEPs              0.463    0.040   11.474    0.000    1.000    1.000
parameterEstimates(fitdep2, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
DEPs Q20_1 1.000 0.000 NA NA 0.796
DEPs Q20_2 1.081 0.047 22.778 0 0.843
DEPs Q20_3 0.933 0.053 17.692 0 0.685
DEPs Q20_5 0.842 0.052 16.259 0 0.638
DEPs Q20_6 0.994 0.051 19.330 0 0.737
DEPs Q20_7 1.007 0.050 20.117 0 0.762
DEPs Q20_8 0.721 0.046 15.600 0 0.616
residuals(fitdep2, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##       Q20_1  Q20_2  Q20_3  Q20_5  Q20_6  Q20_7  Q20_8 
## Q20_1  0.000                                          
## Q20_2  0.054  0.000                                   
## Q20_3 -0.019 -0.014  0.000                            
## Q20_5  0.012 -0.047  0.087  0.000                     
## Q20_6 -0.044  0.015 -0.016  0.006  0.000              
## Q20_7 -0.030 -0.028  0.020 -0.002  0.030  0.000       
## Q20_8 -0.022 -0.022 -0.023 -0.007  0.012  0.072  0.000
semPaths(fitdep2, "par", edge.label.cex = 1.2, fade = FALSE)

TeachModel<- 
  
  '
T=~   Q17_1 + Q17_2 + Q17_3 + Q17_4 + Q17_5

 '

fitA<- cfa(TeachModel, data=teacher2)



summary(fitA, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-12 ended normally after 26 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        10
## 
##                                                   Used       Total
##   Number of observations                           618         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                                23.308
##   Degrees of freedom                                 5
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               520.307
##   Degrees of freedom                                10
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.964
##   Tucker-Lewis Index (TLI)                       0.928
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -3339.952
##   Loglikelihood unrestricted model (H1)      -3328.298
##                                                       
##   Akaike (AIC)                                6699.903
##   Bayesian (BIC)                              6744.168
##   Sample-size adjusted Bayesian (BIC)         6712.420
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.077
##   90 Percent confidence interval - lower         0.047
##   90 Percent confidence interval - upper         0.110
##   P-value RMSEA <= 0.05                          0.066
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.037
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   T =~                                                                  
##     Q17_1             1.000                               0.358    0.506
##     Q17_2             1.606    0.171    9.370    0.000    0.574    0.585
##     Q17_3             1.618    0.159   10.166    0.000    0.579    0.750
##     Q17_4             0.418    0.090    4.634    0.000    0.150    0.227
##     Q17_5             1.473    0.148    9.978    0.000    0.527    0.674
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q17_1             0.372    0.024   15.518    0.000    0.372    0.744
##    .Q17_2             0.636    0.044   14.396    0.000    0.636    0.658
##    .Q17_3             0.260    0.027    9.598    0.000    0.260    0.437
##    .Q17_4             0.411    0.024   17.262    0.000    0.411    0.948
##    .Q17_5             0.333    0.027   12.247    0.000    0.333    0.546
##     T                 0.128    0.022    5.787    0.000    1.000    1.000
parameterEstimates(fitA, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  dplyr::select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
T Q17_1 1.000 0.000 NA NA 0.506
T Q17_2 1.606 0.171 9.370 0 0.585
T Q17_3 1.618 0.159 10.166 0 0.750
T Q17_4 0.418 0.090 4.634 0 0.227
T Q17_5 1.473 0.148 9.978 0 0.674
residuals(fitA, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##       Q17_1  Q17_2  Q17_3  Q17_4  Q17_5 
## Q17_1  0.000                            
## Q17_2  0.003  0.000                     
## Q17_3  0.010  0.010  0.000              
## Q17_4 -0.038 -0.094 -0.008  0.000       
## Q17_5 -0.009  0.002 -0.011  0.100  0.000
semPaths(fitA, "par", edge.label.cex = 1.2, fade = FALSE)

QualityModel<- 
  
  '
T=~   Q17_1 +  Q17_3 +  Q17_5

 '

fitA2<- cfa(QualityModel, data=teacher2)



summary(fitA2, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-12 ended normally after 16 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           621         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               299.475
##   Degrees of freedom                                 3
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1966.063
##   Loglikelihood unrestricted model (H1)      -1966.063
##                                                       
##   Akaike (AIC)                                3944.126
##   Bayesian (BIC)                              3970.713
##   Sample-size adjusted Bayesian (BIC)         3951.664
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.000
##   P-value RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   T =~                                                                  
##     Q17_1             1.000                               0.364    0.514
##     Q17_3             1.616    0.186    8.676    0.000    0.589    0.764
##     Q17_5             1.396    0.149    9.351    0.000    0.509    0.651
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q17_1             0.369    0.025   14.703    0.000    0.369    0.735
##    .Q17_3             0.248    0.039    6.397    0.000    0.248    0.417
##    .Q17_5             0.352    0.034   10.489    0.000    0.352    0.576
##     T                 0.133    0.024    5.591    0.000    1.000    1.000
parameterEstimates(fitA2, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  dplyr::select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
T Q17_1 1.000 0.000 NA NA 0.514
T Q17_3 1.616 0.186 8.676 0 0.764
T Q17_5 1.396 0.149 9.351 0 0.651
residuals(fitA2, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##       Q17_1 Q17_3 Q17_5
## Q17_1 0                
## Q17_3 0     0          
## Q17_5 0     0     0
semPaths(fitA2, "par", edge.label.cex = 1.2, fade = FALSE)

EffModel<- 
  
  '
TEFFs=~ Q44_1 + Q44_2 + Q44_3 + Q44_4

 '

fitj<- cfa(EffModel, data=teacher2)



summary(fitj, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-12 ended normally after 25 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         8
## 
##                                                   Used       Total
##   Number of observations                           521         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 3.169
##   Degrees of freedom                                 2
##   P-value (Chi-square)                           0.205
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1168.182
##   Degrees of freedom                                 6
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.999
##   Tucker-Lewis Index (TLI)                       0.997
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1502.573
##   Loglikelihood unrestricted model (H1)      -1500.988
##                                                       
##   Akaike (AIC)                                3021.146
##   Bayesian (BIC)                              3055.192
##   Sample-size adjusted Bayesian (BIC)         3029.798
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.033
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.099
##   P-value RMSEA <= 0.05                          0.560
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.008
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   TEFFs =~                                                              
##     Q44_1             1.000                               0.545    0.782
##     Q44_2             0.941    0.044   21.152    0.000    0.513    0.870
##     Q44_3             1.079    0.050   21.403    0.000    0.588    0.882
##     Q44_4             0.887    0.053   16.668    0.000    0.484    0.708
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q44_1             0.189    0.014   13.236    0.000    0.189    0.389
##    .Q44_2             0.085    0.008   10.099    0.000    0.085    0.243
##    .Q44_3             0.099    0.011    9.423    0.000    0.099    0.222
##    .Q44_4             0.233    0.016   14.319    0.000    0.233    0.499
##     TEFFs             0.297    0.029   10.270    0.000    1.000    1.000
parameterEstimates(fitj, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  dplyr::select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
TEFFs Q44_1 1.000 0.000 NA NA 0.782
TEFFs Q44_2 0.941 0.044 21.152 0 0.870
TEFFs Q44_3 1.079 0.050 21.403 0 0.882
TEFFs Q44_4 0.887 0.053 16.668 0 0.708
residuals(fitj, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##       Q44_1  Q44_2  Q44_3  Q44_4 
## Q44_1  0.000                     
## Q44_2  0.011  0.000              
## Q44_3 -0.010  0.000  0.000       
## Q44_4 -0.001 -0.015  0.014  0.000
semPaths(fitj, "par", edge.label.cex = 1.2, fade = FALSE)

Assessmentmodel<-
  '
  ASSMs=~ Q41_1 + Q41_2 + Q41_4
  '
fitasm<- cfa(Assessmentmodel, data=teacher2)



summary(fitasm, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-12 ended normally after 27 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           545         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               277.610
##   Degrees of freedom                                 3
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1694.809
##   Loglikelihood unrestricted model (H1)      -1694.809
##                                                       
##   Akaike (AIC)                                3401.619
##   Bayesian (BIC)                              3427.424
##   Sample-size adjusted Bayesian (BIC)         3408.377
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.000
##   P-value RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   ASSMs =~                                                              
##     Q41_1             1.000                               0.549    0.683
##     Q41_2             1.160    0.160    7.245    0.000    0.637    0.829
##     Q41_4             0.475    0.063    7.517    0.000    0.260    0.393
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q41_1             0.345    0.045    7.749    0.000    0.345    0.534
##    .Q41_2             0.185    0.054    3.414    0.001    0.185    0.313
##    .Q41_4             0.372    0.024   15.360    0.000    0.372    0.846
##     ASSMs             0.301    0.051    5.857    0.000    1.000    1.000
parameterEstimates(fitasm, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  dplyr::select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
ASSMs Q41_1 1.000 0.000 NA NA 0.683
ASSMs Q41_2 1.160 0.160 7.245 0 0.829
ASSMs Q41_4 0.475 0.063 7.517 0 0.393
residuals(fitasm, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##       Q41_1 Q41_2 Q41_4
## Q41_1 0                
## Q41_2 0     0          
## Q41_4 0     0     0
semPaths(fitasm, "par", edge.label.cex = 1.2, fade = FALSE)

TeachModel2<- 
  
  '
Teachs=~Q17_1 +  Q17_3 +  Q17_5
ANXs=~ Q19_1 + Q19_2 + Q19_3 + Q19_4 + Q19_5
DEPs=~ Q20_1 + Q20_2 + Q20_3 + Q20_5 + Q20_6 + Q20_7 + Q20_8
GOVt=~ Q23_5 + Q23_6 + Q23_7
PRO=~ Q23_3 + Q23_8 + Q23_9 + Q23_10
COMt=~ Q23_1 + Q23_2 + Q23_4
ASSMs=~ Q41_1 + Q41_2 + Q41_4
TEFFs=~ Q44_1 + Q44_2 + Q44_3 + Q44_4
LV=~ Q15_4 + Q21 + Q25 + Q29 + Q41_3
 '

fitE<- cfa(TeachModel2, data=teacher2)



summary(fitE, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-12 ended normally after 117 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       110
## 
##                                                   Used       Total
##   Number of observations                           433         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                              1386.876
##   Degrees of freedom                               593
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              8851.338
##   Degrees of freedom                               666
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.903
##   Tucker-Lewis Index (TLI)                       0.891
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)             -15857.149
##   Loglikelihood unrestricted model (H1)     -15163.711
##                                                       
##   Akaike (AIC)                               31934.298
##   Bayesian (BIC)                             32382.079
##   Sample-size adjusted Bayesian (BIC)        32033.000
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.056
##   90 Percent confidence interval - lower         0.052
##   90 Percent confidence interval - upper         0.059
##   P-value RMSEA <= 0.05                          0.008
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.060
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Teachs =~                                                             
##     Q17_1             1.000                               0.352    0.555
##     Q17_3             1.382    0.148    9.332    0.000    0.487    0.642
##     Q17_5             1.657    0.164   10.129    0.000    0.583    0.776
##   ANXs =~                                                               
##     Q19_1             1.000                               0.767    0.836
##     Q19_2             0.850    0.047   17.982    0.000    0.652    0.755
##     Q19_3             0.995    0.046   21.804    0.000    0.763    0.861
##     Q19_4             0.933    0.048   19.383    0.000    0.715    0.796
##     Q19_5             0.903    0.052   17.291    0.000    0.693    0.734
##   DEPs =~                                                               
##     Q20_1             1.000                               0.660    0.769
##     Q20_2             1.118    0.061   18.353    0.000    0.738    0.840
##     Q20_3             0.949    0.067   14.250    0.000    0.627    0.674
##     Q20_5             0.849    0.064   13.316    0.000    0.560    0.635
##     Q20_6             0.995    0.065   15.367    0.000    0.657    0.720
##     Q20_7             1.042    0.063   16.640    0.000    0.688    0.772
##     Q20_8             0.730    0.058   12.478    0.000    0.482    0.598
##   GOVt =~                                                               
##     Q23_5             1.000                               0.630    0.805
##     Q23_6             1.178    0.066   17.746    0.000    0.743    0.887
##     Q23_7             0.901    0.064   14.000    0.000    0.568    0.665
##   PRO =~                                                                
##     Q23_3             1.000                               0.249    0.352
##     Q23_8             2.743    0.395    6.940    0.000    0.683    0.711
##     Q23_9             3.417    0.472    7.244    0.000    0.851    0.920
##     Q23_10            2.853    0.403    7.079    0.000    0.711    0.777
##   COMt =~                                                               
##     Q23_1             1.000                               0.568    0.718
##     Q23_2             1.074    0.075   14.379    0.000    0.610    0.806
##     Q23_4             1.013    0.074   13.762    0.000    0.575    0.754
##   ASSMs =~                                                              
##     Q41_1             1.000                               0.540    0.671
##     Q41_2             1.219    0.128    9.552    0.000    0.658    0.870
##     Q41_4             0.496    0.067    7.423    0.000    0.268    0.411
##   TEFFs =~                                                              
##     Q44_1             1.000                               0.547    0.780
##     Q44_2             0.967    0.048   19.958    0.000    0.529    0.889
##     Q44_3             1.064    0.054   19.752    0.000    0.583    0.879
##     Q44_4             0.874    0.058   15.146    0.000    0.478    0.702
##   LV =~                                                                 
##     Q15_4             1.000                               0.684    0.621
##     Q21               1.056    0.084   12.576    0.000    0.722    0.760
##     Q25               1.057    0.079   13.320    0.000    0.723    0.831
##     Q29               0.596    0.070    8.546    0.000    0.408    0.468
##     Q41_3             0.591    0.073    8.057    0.000    0.404    0.438
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Teachs ~~                                                             
##     ANXs             -0.108    0.019   -5.649    0.000   -0.398   -0.398
##     DEPs             -0.091    0.017   -5.496    0.000   -0.391   -0.391
##     GOVt              0.091    0.016    5.625    0.000    0.410    0.410
##     PRO               0.045    0.009    4.997    0.000    0.510    0.510
##     COMt              0.122    0.018    6.874    0.000    0.608    0.608
##     ASSMs             0.006    0.012    0.470    0.639    0.030    0.030
##     TEFFs             0.095    0.015    6.423    0.000    0.492    0.492
##     LV               -0.163    0.023   -6.984    0.000   -0.676   -0.676
##   ANXs ~~                                                               
##     DEPs              0.405    0.039   10.449    0.000    0.799    0.799
##     GOVt             -0.123    0.028   -4.447    0.000   -0.254   -0.254
##     PRO              -0.074    0.015   -4.965    0.000   -0.385   -0.385
##     COMt             -0.162    0.027   -5.964    0.000   -0.373   -0.373
##     ASSMs             0.109    0.026    4.253    0.000    0.264    0.264
##     TEFFs            -0.064    0.023   -2.813    0.005   -0.152   -0.152
##     LV                0.355    0.042    8.547    0.000    0.676    0.676
##   DEPs ~~                                                               
##     GOVt             -0.101    0.024   -4.238    0.000   -0.244   -0.244
##     PRO              -0.055    0.012   -4.553    0.000   -0.331   -0.331
##     COMt             -0.130    0.023   -5.534    0.000   -0.346   -0.346
##     ASSMs             0.096    0.022    4.288    0.000    0.270    0.270
##     TEFFs            -0.075    0.020   -3.750    0.000   -0.208   -0.208
##     LV                0.284    0.035    8.036    0.000    0.629    0.629
##   GOVt ~~                                                               
##     PRO               0.089    0.016    5.674    0.000    0.568    0.568
##     COMt              0.191    0.025    7.550    0.000    0.534    0.534
##     ASSMs            -0.078    0.021   -3.702    0.000   -0.230   -0.230
##     TEFFs             0.076    0.020    3.886    0.000    0.220    0.220
##     LV               -0.201    0.030   -6.686    0.000   -0.466   -0.466
##   PRO ~~                                                                
##     COMt              0.075    0.014    5.424    0.000    0.530    0.530
##     ASSMs            -0.020    0.008   -2.443    0.015   -0.151   -0.151
##     TEFFs             0.030    0.009    3.546    0.000    0.222    0.222
##     LV               -0.116    0.020   -5.690    0.000   -0.680   -0.680
##   COMt ~~                                                               
##     ASSMs            -0.031    0.019   -1.694    0.090   -0.102   -0.102
##     TEFFs             0.152    0.021    7.231    0.000    0.489    0.489
##     LV               -0.211    0.030   -7.072    0.000   -0.543   -0.543
##   ASSMs ~~                                                              
##     TEFFs             0.023    0.017    1.364    0.173    0.077    0.077
##     LV                0.133    0.026    5.023    0.000    0.359    0.359
##   TEFFs ~~                                                              
##     LV               -0.109    0.023   -4.767    0.000   -0.291   -0.291
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q17_1             0.279    0.021   13.002    0.000    0.279    0.692
##    .Q17_3             0.338    0.028   11.963    0.000    0.338    0.588
##    .Q17_5             0.225    0.026    8.579    0.000    0.225    0.398
##    .Q19_1             0.254    0.022   11.588    0.000    0.254    0.302
##    .Q19_2             0.320    0.025   12.936    0.000    0.320    0.429
##    .Q19_3             0.203    0.019   10.832    0.000    0.203    0.258
##    .Q19_4             0.296    0.024   12.392    0.000    0.296    0.367
##    .Q19_5             0.409    0.031   13.149    0.000    0.409    0.461
##    .Q20_1             0.301    0.024   12.556    0.000    0.301    0.409
##    .Q20_2             0.228    0.020   11.143    0.000    0.228    0.295
##    .Q20_3             0.471    0.035   13.480    0.000    0.471    0.546
##    .Q20_5             0.466    0.034   13.716    0.000    0.466    0.597
##    .Q20_6             0.400    0.031   13.113    0.000    0.400    0.481
##    .Q20_7             0.322    0.026   12.520    0.000    0.322    0.405
##    .Q20_8             0.416    0.030   13.889    0.000    0.416    0.642
##    .Q23_5             0.215    0.022    9.849    0.000    0.215    0.351
##    .Q23_6             0.150    0.024    6.202    0.000    0.150    0.213
##    .Q23_7             0.408    0.032   12.898    0.000    0.408    0.558
##    .Q23_3             0.439    0.030   14.484    0.000    0.439    0.876
##    .Q23_8             0.457    0.036   12.846    0.000    0.457    0.495
##    .Q23_9             0.131    0.024    5.441    0.000    0.131    0.153
##    .Q23_10            0.332    0.028   11.727    0.000    0.332    0.397
##    .Q23_1             0.303    0.026   11.590    0.000    0.303    0.484
##    .Q23_2             0.200    0.022    9.214    0.000    0.200    0.350
##    .Q23_4             0.251    0.023   10.802    0.000    0.251    0.431
##    .Q41_1             0.357    0.036    9.875    0.000    0.357    0.550
##    .Q41_2             0.139    0.040    3.471    0.001    0.139    0.244
##    .Q41_4             0.353    0.025   13.897    0.000    0.353    0.831
##    .Q44_1             0.192    0.016   12.344    0.000    0.192    0.391
##    .Q44_2             0.074    0.009    8.721    0.000    0.074    0.209
##    .Q44_3             0.099    0.011    9.243    0.000    0.099    0.227
##    .Q44_4             0.235    0.018   13.258    0.000    0.235    0.507
##    .Q15_4             0.747    0.056   13.454    0.000    0.747    0.615
##    .Q21               0.381    0.032   11.890    0.000    0.381    0.422
##    .Q25               0.233    0.023    9.960    0.000    0.233    0.309
##    .Q29               0.593    0.042   14.156    0.000    0.593    0.781
##    .Q41_3             0.689    0.048   14.243    0.000    0.689    0.808
##     Teachs            0.124    0.022    5.596    0.000    1.000    1.000
##     ANXs              0.588    0.056   10.459    0.000    1.000    1.000
##     DEPs              0.436    0.047    9.197    0.000    1.000    1.000
##     GOVt              0.397    0.042    9.413    0.000    1.000    1.000
##     PRO               0.062    0.017    3.593    0.000    1.000    1.000
##     COMt              0.323    0.041    7.958    0.000    1.000    1.000
##     ASSMs             0.292    0.046    6.407    0.000    1.000    1.000
##     TEFFs             0.300    0.032    9.386    0.000    1.000    1.000
##     LV                0.468    0.069    6.793    0.000    1.000    1.000
parameterEstimates(fitE, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  dplyr::select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
Teachs Q17_1 1.000 0.000 NA NA 0.555
Teachs Q17_3 1.382 0.148 9.332 0 0.642
Teachs Q17_5 1.657 0.164 10.129 0 0.776
ANXs Q19_1 1.000 0.000 NA NA 0.836
ANXs Q19_2 0.850 0.047 17.982 0 0.755
ANXs Q19_3 0.995 0.046 21.804 0 0.861
ANXs Q19_4 0.933 0.048 19.383 0 0.796
ANXs Q19_5 0.903 0.052 17.291 0 0.734
DEPs Q20_1 1.000 0.000 NA NA 0.769
DEPs Q20_2 1.118 0.061 18.353 0 0.840
DEPs Q20_3 0.949 0.067 14.250 0 0.674
DEPs Q20_5 0.849 0.064 13.316 0 0.635
DEPs Q20_6 0.995 0.065 15.367 0 0.720
DEPs Q20_7 1.042 0.063 16.640 0 0.772
DEPs Q20_8 0.730 0.058 12.478 0 0.598
GOVt Q23_5 1.000 0.000 NA NA 0.805
GOVt Q23_6 1.178 0.066 17.746 0 0.887
GOVt Q23_7 0.901 0.064 14.000 0 0.665
PRO Q23_3 1.000 0.000 NA NA 0.352
PRO Q23_8 2.743 0.395 6.940 0 0.711
PRO Q23_9 3.417 0.472 7.244 0 0.920
PRO Q23_10 2.853 0.403 7.079 0 0.777
COMt Q23_1 1.000 0.000 NA NA 0.718
COMt Q23_2 1.074 0.075 14.379 0 0.806
COMt Q23_4 1.013 0.074 13.762 0 0.754
ASSMs Q41_1 1.000 0.000 NA NA 0.671
ASSMs Q41_2 1.219 0.128 9.552 0 0.870
ASSMs Q41_4 0.496 0.067 7.423 0 0.411
TEFFs Q44_1 1.000 0.000 NA NA 0.780
TEFFs Q44_2 0.967 0.048 19.958 0 0.889
TEFFs Q44_3 1.064 0.054 19.752 0 0.879
TEFFs Q44_4 0.874 0.058 15.146 0 0.702
LV Q15_4 1.000 0.000 NA NA 0.621
LV Q21 1.056 0.084 12.576 0 0.760
LV Q25 1.057 0.079 13.320 0 0.831
LV Q29 0.596 0.070 8.546 0 0.468
LV Q41_3 0.591 0.073 8.057 0 0.438
CFAStand<-standardizedsolution(fitE, type = "std.all")
write.csv(CFAStand, "CFAStand.csv")
CFAStand
##        lhs op    rhs est.std    se       z pvalue ci.lower ci.upper
## 1   Teachs =~  Q17_1   0.555 0.040  13.826  0.000    0.476    0.634
## 2   Teachs =~  Q17_3   0.642 0.036  17.825  0.000    0.571    0.712
## 3   Teachs =~  Q17_5   0.776 0.031  25.110  0.000    0.715    0.837
## 4     ANXs =~  Q19_1   0.836 0.017  48.025  0.000    0.801    0.870
## 5     ANXs =~  Q19_2   0.755 0.023  32.642  0.000    0.710    0.801
## 6     ANXs =~  Q19_3   0.861 0.016  55.355  0.000    0.831    0.892
## 7     ANXs =~  Q19_4   0.796 0.020  39.249  0.000    0.756    0.836
## 8     ANXs =~  Q19_5   0.734 0.025  29.879  0.000    0.686    0.783
## 9     DEPs =~  Q20_1   0.769 0.023  34.150  0.000    0.725    0.813
## 10    DEPs =~  Q20_2   0.840 0.018  47.886  0.000    0.805    0.874
## 11    DEPs =~  Q20_3   0.674 0.029  23.363  0.000    0.618    0.731
## 12    DEPs =~  Q20_5   0.635 0.031  20.292  0.000    0.573    0.696
## 13    DEPs =~  Q20_6   0.720 0.026  27.854  0.000    0.670    0.771
## 14    DEPs =~  Q20_7   0.772 0.022  34.532  0.000    0.728    0.815
## 15    DEPs =~  Q20_8   0.598 0.033  17.931  0.000    0.533    0.664
## 16    GOVt =~  Q23_5   0.805 0.024  34.186  0.000    0.759    0.852
## 17    GOVt =~  Q23_6   0.887 0.020  43.563  0.000    0.847    0.927
## 18    GOVt =~  Q23_7   0.665 0.031  21.391  0.000    0.604    0.726
## 19     PRO =~  Q23_3   0.352 0.045   7.861  0.000    0.264    0.439
## 20     PRO =~  Q23_8   0.711 0.027  26.134  0.000    0.658    0.764
## 21     PRO =~  Q23_9   0.920 0.016  57.422  0.000    0.889    0.952
## 22     PRO =~ Q23_10   0.777 0.023  33.540  0.000    0.731    0.822
## 23    COMt =~  Q23_1   0.718 0.029  24.442  0.000    0.661    0.776
## 24    COMt =~  Q23_2   0.806 0.025  32.421  0.000    0.758    0.855
## 25    COMt =~  Q23_4   0.754 0.027  27.482  0.000    0.700    0.808
## 26   ASSMs =~  Q41_1   0.671 0.041  16.518  0.000    0.591    0.750
## 27   ASSMs =~  Q41_2   0.870 0.041  21.256  0.000    0.790    0.950
## 28   ASSMs =~  Q41_4   0.411 0.047   8.843  0.000    0.320    0.503
## 29   TEFFs =~  Q44_1   0.780 0.022  35.800  0.000    0.738    0.823
## 30   TEFFs =~  Q44_2   0.889 0.015  60.052  0.000    0.860    0.918
## 31   TEFFs =~  Q44_3   0.879 0.015  57.251  0.000    0.849    0.910
## 32   TEFFs =~  Q44_4   0.702 0.027  25.951  0.000    0.649    0.755
## 33      LV =~  Q15_4   0.621 0.033  18.756  0.000    0.556    0.686
## 34      LV =~    Q21   0.760 0.025  30.997  0.000    0.712    0.808
## 35      LV =~    Q25   0.831 0.020  41.147  0.000    0.792    0.871
## 36      LV =~    Q29   0.468 0.041  11.473  0.000    0.388    0.548
## 37      LV =~  Q41_3   0.438 0.042  10.399  0.000    0.355    0.520
## 38   Q17_1 ~~  Q17_1   0.692 0.045  15.540  0.000    0.605    0.779
## 39   Q17_3 ~~  Q17_3   0.588 0.046  12.727  0.000    0.498    0.679
## 40   Q17_5 ~~  Q17_5   0.398 0.048   8.296  0.000    0.304    0.492
## 41   Q19_1 ~~  Q19_1   0.302 0.029  10.382  0.000    0.245    0.359
## 42   Q19_2 ~~  Q19_2   0.429 0.035  12.283  0.000    0.361    0.498
## 43   Q19_3 ~~  Q19_3   0.258 0.027   9.642  0.000    0.206    0.311
## 44   Q19_4 ~~  Q19_4   0.367 0.032  11.365  0.000    0.303    0.430
## 45   Q19_5 ~~  Q19_5   0.461 0.036  12.753  0.000    0.390    0.531
## 46   Q20_1 ~~  Q20_1   0.409 0.035  11.795  0.000    0.341    0.476
## 47   Q20_2 ~~  Q20_2   0.295 0.029  10.027  0.000    0.237    0.353
## 48   Q20_3 ~~  Q20_3   0.546 0.039  14.028  0.000    0.469    0.622
## 49   Q20_5 ~~  Q20_5   0.597 0.040  15.047  0.000    0.519    0.675
## 50   Q20_6 ~~  Q20_6   0.481 0.037  12.922  0.000    0.408    0.554
## 51   Q20_7 ~~  Q20_7   0.405 0.034  11.737  0.000    0.337    0.472
## 52   Q20_8 ~~  Q20_8   0.642 0.040  16.068  0.000    0.564    0.720
## 53   Q23_5 ~~  Q23_5   0.351 0.038   9.252  0.000    0.277    0.426
## 54   Q23_6 ~~  Q23_6   0.213 0.036   5.908  0.000    0.143    0.284
## 55   Q23_7 ~~  Q23_7   0.558 0.041  13.517  0.000    0.477    0.639
## 56   Q23_3 ~~  Q23_3   0.876 0.031  27.837  0.000    0.815    0.938
## 57   Q23_8 ~~  Q23_8   0.495 0.039  12.795  0.000    0.419    0.571
## 58   Q23_9 ~~  Q23_9   0.153 0.029   5.200  0.000    0.096    0.211
## 59  Q23_10 ~~ Q23_10   0.397 0.036  11.026  0.000    0.326    0.467
## 60   Q23_1 ~~  Q23_1   0.484 0.042  11.479  0.000    0.402    0.567
## 61   Q23_2 ~~  Q23_2   0.350 0.040   8.715  0.000    0.271    0.428
## 62   Q23_4 ~~  Q23_4   0.431 0.041  10.423  0.000    0.350    0.512
## 63   Q41_1 ~~  Q41_1   0.550 0.054  10.107  0.000    0.444    0.657
## 64   Q41_2 ~~  Q41_2   0.244 0.071   3.422  0.001    0.104    0.383
## 65   Q41_4 ~~  Q41_4   0.831 0.038  21.704  0.000    0.756    0.906
## 66   Q44_1 ~~  Q44_1   0.391 0.034  11.493  0.000    0.324    0.458
## 67   Q44_2 ~~  Q44_2   0.209 0.026   7.947  0.000    0.158    0.261
## 68   Q44_3 ~~  Q44_3   0.227 0.027   8.383  0.000    0.174    0.279
## 69   Q44_4 ~~  Q44_4   0.507 0.038  13.332  0.000    0.432    0.581
## 70   Q15_4 ~~  Q15_4   0.615 0.041  14.968  0.000    0.534    0.695
## 71     Q21 ~~    Q21   0.422 0.037  11.329  0.000    0.349    0.495
## 72     Q25 ~~    Q25   0.309 0.034   9.187  0.000    0.243    0.375
## 73     Q29 ~~    Q29   0.781 0.038  20.425  0.000    0.706    0.856
## 74   Q41_3 ~~  Q41_3   0.808 0.037  21.916  0.000    0.736    0.881
## 75  Teachs ~~ Teachs   1.000 0.000      NA     NA    1.000    1.000
## 76    ANXs ~~   ANXs   1.000 0.000      NA     NA    1.000    1.000
## 77    DEPs ~~   DEPs   1.000 0.000      NA     NA    1.000    1.000
## 78    GOVt ~~   GOVt   1.000 0.000      NA     NA    1.000    1.000
## 79     PRO ~~    PRO   1.000 0.000      NA     NA    1.000    1.000
## 80    COMt ~~   COMt   1.000 0.000      NA     NA    1.000    1.000
## 81   ASSMs ~~  ASSMs   1.000 0.000      NA     NA    1.000    1.000
## 82   TEFFs ~~  TEFFs   1.000 0.000      NA     NA    1.000    1.000
## 83      LV ~~     LV   1.000 0.000      NA     NA    1.000    1.000
## 84  Teachs ~~   ANXs  -0.398 0.052  -7.641  0.000   -0.501   -0.296
## 85  Teachs ~~   DEPs  -0.391 0.053  -7.410  0.000   -0.494   -0.287
## 86  Teachs ~~   GOVt   0.410 0.053   7.715  0.000    0.306    0.515
## 87  Teachs ~~    PRO   0.510 0.048  10.591  0.000    0.416    0.605
## 88  Teachs ~~   COMt   0.608 0.047  13.047  0.000    0.517    0.699
## 89  Teachs ~~  ASSMs   0.030 0.063   0.471  0.638   -0.094    0.153
## 90  Teachs ~~  TEFFs   0.492 0.048  10.180  0.000    0.397    0.587
## 91  Teachs ~~     LV  -0.676 0.042 -15.983  0.000   -0.759   -0.593
## 92    ANXs ~~   DEPs   0.799 0.023  34.346  0.000    0.754    0.845
## 93    ANXs ~~   GOVt  -0.254 0.051  -4.939  0.000   -0.354   -0.153
## 94    ANXs ~~    PRO  -0.385 0.047  -8.269  0.000   -0.476   -0.294
## 95    ANXs ~~   COMt  -0.373 0.050  -7.504  0.000   -0.470   -0.275
## 96    ANXs ~~  ASSMs   0.264 0.053   4.942  0.000    0.159    0.369
## 97    ANXs ~~  TEFFs  -0.152 0.052  -2.927  0.003   -0.254   -0.050
## 98    ANXs ~~     LV   0.676 0.034  19.754  0.000    0.609    0.744
## 99    DEPs ~~   GOVt  -0.244 0.052  -4.693  0.000   -0.345   -0.142
## 100   DEPs ~~    PRO  -0.331 0.049  -6.814  0.000   -0.427   -0.236
## 101   DEPs ~~   COMt  -0.346 0.051  -6.807  0.000   -0.446   -0.247
## 102   DEPs ~~  ASSMs   0.270 0.054   5.038  0.000    0.165    0.375
## 103   DEPs ~~  TEFFs  -0.208 0.051  -4.054  0.000   -0.309   -0.107
## 104   DEPs ~~     LV   0.629 0.037  16.788  0.000    0.555    0.702
## 105   GOVt ~~    PRO   0.568 0.040  14.264  0.000    0.490    0.646
## 106   GOVt ~~   COMt   0.534 0.044  12.028  0.000    0.447    0.621
## 107   GOVt ~~  ASSMs  -0.230 0.055  -4.153  0.000   -0.339   -0.122
## 108   GOVt ~~  TEFFs   0.220 0.052   4.225  0.000    0.118    0.322
## 109   GOVt ~~     LV  -0.466 0.047  -9.959  0.000   -0.558   -0.374
## 110    PRO ~~   COMt   0.530 0.044  12.133  0.000    0.444    0.615
## 111    PRO ~~  ASSMs  -0.151 0.056  -2.711  0.007   -0.261   -0.042
## 112    PRO ~~  TEFFs   0.222 0.051   4.351  0.000    0.122    0.323
## 113    PRO ~~     LV  -0.680 0.035 -19.575  0.000   -0.748   -0.612
## 114   COMt ~~  ASSMs  -0.102 0.059  -1.734  0.083   -0.218    0.013
## 115   COMt ~~  TEFFs   0.489 0.045  10.892  0.000    0.401    0.577
## 116   COMt ~~     LV  -0.543 0.045 -12.011  0.000   -0.632   -0.454
## 117  ASSMs ~~  TEFFs   0.077 0.056   1.384  0.166   -0.032    0.187
## 118  ASSMs ~~     LV   0.359 0.054   6.685  0.000    0.254    0.464
## 119  TEFFs ~~     LV  -0.291 0.052  -5.638  0.000   -0.392   -0.190
residuals(fitE, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##        Q17_1  Q17_3  Q17_5  Q19_1  Q19_2  Q19_3  Q19_4  Q19_5  Q20_1  Q20_2 
## Q17_1   0.000                                                               
## Q17_3   0.054  0.000                                                        
## Q17_5  -0.023 -0.005  0.000                                                 
## Q19_1  -0.003 -0.046  0.025  0.000                                          
## Q19_2   0.004 -0.067  0.033  0.014  0.000                                   
## Q19_3   0.051 -0.043  0.061 -0.011  0.045  0.000                            
## Q19_4  -0.050 -0.092 -0.022 -0.027 -0.029  0.026  0.000                     
## Q19_5  -0.062 -0.061  0.073  0.013 -0.025 -0.015 -0.017  0.000              
## Q20_1  -0.058 -0.030 -0.029 -0.061 -0.139 -0.110  0.000 -0.005  0.000       
## Q20_2  -0.012  0.025  0.039  0.028 -0.084 -0.038  0.038  0.086  0.071  0.000
## Q20_3   0.042 -0.028  0.033  0.059  0.066  0.069  0.048  0.064 -0.013 -0.034
## Q20_5  -0.007 -0.004  0.021  0.007 -0.012  0.010  0.065  0.018  0.030 -0.060
## Q20_6  -0.109 -0.061 -0.061  0.052 -0.064 -0.054 -0.019  0.057 -0.028  0.027
## Q20_7  -0.001 -0.017  0.032  0.030  0.008  0.028  0.039  0.043 -0.027 -0.031
## Q20_8   0.052  0.036  0.065  0.025 -0.091 -0.045 -0.021  0.055 -0.003 -0.013
## Q23_5   0.023  0.046 -0.036 -0.008 -0.047  0.001 -0.065 -0.014 -0.031  0.004
## Q23_6  -0.009  0.078 -0.059  0.006 -0.033  0.034  0.010  0.033 -0.021  0.010
## Q23_7   0.002  0.068  0.031  0.001 -0.039  0.053 -0.013 -0.051 -0.050 -0.033
## Q23_3   0.077  0.081  0.083 -0.099  0.000 -0.020 -0.058 -0.087 -0.099 -0.175
## Q23_8  -0.019  0.015 -0.050 -0.054 -0.044  0.011 -0.034 -0.030 -0.021 -0.015
## Q23_9  -0.047  0.009  0.000 -0.028 -0.015  0.035  0.010  0.005 -0.003 -0.003
## Q23_10 -0.008  0.050  0.021  0.017 -0.018  0.041  0.010  0.023 -0.054  0.014
## Q23_1   0.017 -0.025  0.053  0.092  0.030  0.036 -0.012  0.080 -0.002  0.052
## Q23_2  -0.031 -0.076 -0.038  0.004 -0.049  0.027 -0.020 -0.026 -0.005 -0.012
## Q23_4   0.048  0.029  0.048 -0.027 -0.053  0.010 -0.074 -0.041 -0.094 -0.073
## Q41_1   0.032 -0.034 -0.049 -0.046 -0.046 -0.045  0.070 -0.076  0.043  0.003
## Q41_2   0.060  0.009  0.009  0.010  0.029 -0.018  0.049 -0.015 -0.029 -0.044
## Q41_4   0.025 -0.060 -0.123  0.005  0.013 -0.002  0.012  0.016  0.012  0.075
## Q44_1  -0.028 -0.028  0.104  0.026  0.033  0.043 -0.021  0.028  0.009  0.023
## Q44_2  -0.027 -0.089  0.018 -0.013  0.028 -0.021 -0.044 -0.025 -0.054 -0.028
## Q44_3   0.002 -0.057  0.005 -0.001  0.063  0.028 -0.001  0.019 -0.073 -0.044
## Q44_4  -0.012  0.013  0.090 -0.056 -0.021 -0.025 -0.042 -0.054 -0.065 -0.077
## Q15_4  -0.026  0.003 -0.062 -0.033 -0.036 -0.089 -0.058 -0.040  0.016 -0.043
## Q21     0.007 -0.025  0.006  0.133  0.091  0.054  0.062  0.080  0.067  0.088
## Q25     0.053  0.005  0.016 -0.039 -0.025 -0.075 -0.017 -0.052 -0.035 -0.033
## Q29    -0.028 -0.037 -0.150 -0.033  0.018 -0.001  0.051 -0.028 -0.023 -0.033
## Q41_3   0.096  0.089  0.061  0.053  0.024  0.045  0.079  0.037 -0.026  0.037
##        Q20_3  Q20_5  Q20_6  Q20_7  Q20_8  Q23_5  Q23_6  Q23_7  Q23_3  Q23_8 
## Q17_1                                                                       
## Q17_3                                                                       
## Q17_5                                                                       
## Q19_1                                                                       
## Q19_2                                                                       
## Q19_3                                                                       
## Q19_4                                                                       
## Q19_5                                                                       
## Q20_1                                                                       
## Q20_2                                                                       
## Q20_3   0.000                                                               
## Q20_5   0.073  0.000                                                        
## Q20_6  -0.035  0.001  0.000                                                 
## Q20_7   0.001  0.006  0.006  0.000                                          
## Q20_8  -0.020 -0.036  0.003  0.086  0.000                                   
## Q23_5   0.018 -0.070 -0.029 -0.004  0.038  0.000                            
## Q23_6   0.033 -0.010 -0.015  0.041  0.071  0.009  0.000                     
## Q23_7   0.010 -0.048 -0.014  0.000 -0.030 -0.034  0.001  0.000              
## Q23_3  -0.013 -0.047 -0.164 -0.008 -0.058 -0.123 -0.083 -0.005  0.000       
## Q23_8  -0.008 -0.061  0.025  0.064  0.050 -0.117 -0.046  0.016  0.155  0.000
## Q23_9   0.005 -0.060 -0.003  0.045  0.013 -0.060 -0.030  0.070 -0.021  0.011
## Q23_10  0.033 -0.067  0.040  0.060  0.041  0.152  0.119  0.131 -0.070 -0.050
## Q23_1   0.116 -0.006  0.014  0.081  0.129 -0.010 -0.093 -0.042 -0.011 -0.087
## Q23_2   0.025 -0.030  0.024  0.036  0.024  0.020 -0.032  0.012  0.047 -0.045
## Q23_4  -0.031 -0.091 -0.081  0.005  0.036  0.118  0.030  0.079  0.100  0.007
## Q41_1  -0.015  0.064 -0.021 -0.058 -0.039 -0.017 -0.029 -0.011 -0.065 -0.034
## Q41_2   0.034  0.051  0.008  0.028 -0.018  0.008  0.033 -0.017 -0.028 -0.021
## Q41_4   0.054 -0.010  0.033  0.010  0.005 -0.107 -0.050 -0.080 -0.046 -0.026
## Q44_1   0.060  0.009  0.042  0.065  0.075 -0.013 -0.055  0.007 -0.066 -0.097
## Q44_2   0.024 -0.004 -0.011  0.056  0.034  0.015 -0.045  0.047  0.009 -0.013
## Q44_3   0.034 -0.007 -0.013  0.059  0.063  0.014  0.000  0.041 -0.013 -0.018
## Q44_4   0.024  0.000 -0.036  0.022  0.042  0.033  0.061  0.086  0.057  0.052
## Q15_4  -0.011  0.022  0.008 -0.040 -0.029 -0.005 -0.028 -0.058 -0.077 -0.028
## Q21     0.059  0.076  0.077  0.055  0.010  0.095  0.107  0.031 -0.042  0.068
## Q25    -0.043 -0.018 -0.019 -0.057 -0.056 -0.042 -0.037 -0.139 -0.115 -0.122
## Q29    -0.058  0.007  0.008 -0.041 -0.053  0.008  0.020 -0.059  0.066  0.120
## Q41_3   0.014  0.029  0.075  0.007  0.033 -0.001  0.030 -0.025 -0.043  0.056
##        Q23_9  Q23_10 Q23_1  Q23_2  Q23_4  Q41_1  Q41_2  Q41_4  Q44_1  Q44_2 
## Q17_1                                                                       
## Q17_3                                                                       
## Q17_5                                                                       
## Q19_1                                                                       
## Q19_2                                                                       
## Q19_3                                                                       
## Q19_4                                                                       
## Q19_5                                                                       
## Q20_1                                                                       
## Q20_2                                                                       
## Q20_3                                                                       
## Q20_5                                                                       
## Q20_6                                                                       
## Q20_7                                                                       
## Q20_8                                                                       
## Q23_5                                                                       
## Q23_6                                                                       
## Q23_7                                                                       
## Q23_3                                                                       
## Q23_8                                                                       
## Q23_9   0.000                                                               
## Q23_10  0.005  0.000                                                        
## Q23_1  -0.062  0.035  0.000                                                 
## Q23_2  -0.030  0.036  0.045  0.000                                          
## Q23_4   0.047  0.126 -0.055 -0.003  0.000                                   
## Q41_1  -0.032 -0.013  0.027 -0.016 -0.090  0.000                            
## Q41_2   0.023  0.049  0.094  0.004 -0.032  0.001  0.000                     
## Q41_4  -0.068 -0.111 -0.007 -0.053 -0.091 -0.008  0.000  0.000              
## Q44_1  -0.081  0.016  0.106 -0.054 -0.022 -0.009  0.105 -0.022  0.000       
## Q44_2  -0.004  0.075  0.080 -0.056 -0.011 -0.081  0.021 -0.039  0.012  0.000
## Q44_3  -0.023  0.040  0.071 -0.047 -0.025 -0.105  0.026 -0.077 -0.017  0.005
## Q44_4   0.084  0.110  0.046  0.067  0.005 -0.061 -0.009 -0.124 -0.009 -0.018
## Q15_4   0.048  0.046  0.089  0.067 -0.037  0.039 -0.025  0.058  0.052  0.034
## Q21     0.048  0.092  0.112  0.122 -0.019  0.010 -0.038  0.035  0.035  0.040
## Q25    -0.095 -0.041  0.009  0.006 -0.089  0.006 -0.078  0.039  0.055  0.010
## Q29     0.072  0.091 -0.304 -0.224 -0.170 -0.003 -0.098  0.005 -0.195 -0.212
## Q41_3   0.114  0.145  0.072  0.044  0.024  0.314  0.426  0.221  0.127  0.095
##        Q44_3  Q44_4  Q15_4  Q21    Q25    Q29    Q41_3 
## Q17_1                                                  
## Q17_3                                                  
## Q17_5                                                  
## Q19_1                                                  
## Q19_2                                                  
## Q19_3                                                  
## Q19_4                                                  
## Q19_5                                                  
## Q20_1                                                  
## Q20_2                                                  
## Q20_3                                                  
## Q20_5                                                  
## Q20_6                                                  
## Q20_7                                                  
## Q20_8                                                  
## Q23_5                                                  
## Q23_6                                                  
## Q23_7                                                  
## Q23_3                                                  
## Q23_8                                                  
## Q23_9                                                  
## Q23_10                                                 
## Q23_1                                                  
## Q23_2                                                  
## Q23_4                                                  
## Q41_1                                                  
## Q41_2                                                  
## Q41_4                                                  
## Q44_1                                                  
## Q44_2                                                  
## Q44_3   0.000                                          
## Q44_4   0.015  0.000                                   
## Q15_4   0.034 -0.050  0.000                            
## Q21     0.025 -0.071  0.006  0.000                     
## Q25     0.023 -0.107  0.018  0.002  0.000              
## Q29    -0.240 -0.268 -0.007 -0.056  0.034  0.000       
## Q41_3   0.086  0.041  0.053 -0.009 -0.063  0.035  0.000
semPaths(fitE, "par", edge.label.cex = 1.2, fade = FALSE, exoCov = FALSE)

TeachModel3<- 
  
  '
Teachs=~ Q17_1 + Q17_3 + Q17_5
ANXs=~ Q19_1 + Q19_2 + Q19_3 + Q19_4 + Q19_5
DEPs=~ Q20_2 + Q20_3 + Q20_5 + Q20_6 + Q20_7 + Q20_8
PRO=~ Q23_3 + Q23_8 + Q23_9
ASSMs=~ Q41_1 + Q41_2 + Q41_4
TEFFs=~ Q44_1 + Q44_2 + Q44_3 + Q44_4
LV=~ Q15_4 + Q21 + Q25 + Q29 + Q41_3
 '

fitE2<- cfa(TeachModel3, data=teacher2)



summary(fitE2, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-12 ended normally after 91 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        79
## 
##                                                   Used       Total
##   Number of observations                           443         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                               853.511
##   Degrees of freedom                               356
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              6462.376
##   Degrees of freedom                               406
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.918
##   Tucker-Lewis Index (TLI)                       0.906
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)             -12895.672
##   Loglikelihood unrestricted model (H1)     -12468.917
##                                                       
##   Akaike (AIC)                               25949.344
##   Bayesian (BIC)                             26272.736
##   Sample-size adjusted Bayesian (BIC)        26022.026
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.056
##   90 Percent confidence interval - lower         0.051
##   90 Percent confidence interval - upper         0.061
##   P-value RMSEA <= 0.05                          0.018
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.059
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Teachs =~                                                             
##     Q17_1             1.000                               0.358    0.557
##     Q17_3             1.370    0.146    9.400    0.000    0.490    0.647
##     Q17_5             1.603    0.159   10.071    0.000    0.574    0.767
##   ANXs =~                                                               
##     Q19_1             1.000                               0.762    0.834
##     Q19_2             0.854    0.047   18.181    0.000    0.650    0.756
##     Q19_3             1.000    0.046   21.938    0.000    0.761    0.860
##     Q19_4             0.930    0.048   19.394    0.000    0.708    0.791
##     Q19_5             0.901    0.052   17.187    0.000    0.686    0.726
##   DEPs =~                                                               
##     Q20_2             1.000                               0.701    0.800
##     Q20_3             0.897    0.061   14.802    0.000    0.628    0.680
##     Q20_5             0.786    0.058   13.446    0.000    0.550    0.626
##     Q20_6             0.930    0.059   15.824    0.000    0.652    0.719
##     Q20_7             1.000    0.057   17.616    0.000    0.700    0.785
##     Q20_8             0.687    0.054   12.740    0.000    0.481    0.598
##   PRO =~                                                                
##     Q23_3             1.000                               0.296    0.420
##     Q23_8             2.520    0.310    8.139    0.000    0.746    0.771
##     Q23_9             2.667    0.325    8.203    0.000    0.789    0.849
##   ASSMs =~                                                              
##     Q41_1             1.000                               0.540    0.674
##     Q41_2             1.216    0.129    9.459    0.000    0.657    0.869
##     Q41_4             0.489    0.066    7.416    0.000    0.264    0.406
##   TEFFs =~                                                              
##     Q44_1             1.000                               0.546    0.782
##     Q44_2             0.967    0.048   20.181    0.000    0.528    0.890
##     Q44_3             1.061    0.053   19.979    0.000    0.579    0.880
##     Q44_4             0.871    0.058   15.129    0.000    0.475    0.695
##   LV =~                                                                 
##     Q15_4             1.000                               0.689    0.627
##     Q21               1.042    0.081   12.819    0.000    0.718    0.757
##     Q25               1.048    0.077   13.640    0.000    0.721    0.833
##     Q29               0.577    0.068    8.547    0.000    0.398    0.460
##     Q41_3             0.599    0.072    8.329    0.000    0.412    0.447
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Teachs ~~                                                             
##     ANXs             -0.110    0.019   -5.745    0.000   -0.403   -0.403
##     DEPs             -0.095    0.018   -5.390    0.000   -0.379   -0.379
##     PRO               0.053    0.010    5.271    0.000    0.501    0.501
##     ASSMs             0.007    0.012    0.565    0.572    0.035    0.035
##     TEFFs             0.095    0.015    6.415    0.000    0.484    0.484
##     LV               -0.167    0.024   -7.076    0.000   -0.676   -0.676
##   ANXs ~~                                                               
##     DEPs              0.442    0.041   10.895    0.000    0.829    0.829
##     PRO              -0.094    0.017   -5.483    0.000   -0.418   -0.418
##     ASSMs             0.110    0.025    4.317    0.000    0.266    0.266
##     TEFFs            -0.062    0.022   -2.771    0.006   -0.148   -0.148
##     LV                0.353    0.041    8.659    0.000    0.673    0.673
##   DEPs ~~                                                               
##     PRO              -0.072    0.015   -4.869    0.000   -0.349   -0.349
##     ASSMs             0.107    0.024    4.434    0.000    0.282    0.282
##     TEFFs            -0.069    0.021   -3.277    0.001   -0.180   -0.180
##     LV                0.302    0.037    8.183    0.000    0.626    0.626
##   PRO ~~                                                                
##     ASSMs            -0.028    0.010   -2.766    0.006   -0.178   -0.178
##     TEFFs             0.030    0.010    3.094    0.002    0.187    0.187
##     LV               -0.145    0.023   -6.333    0.000   -0.711   -0.711
##   ASSMs ~~                                                              
##     TEFFs             0.025    0.017    1.509    0.131    0.085    0.085
##     LV                0.135    0.026    5.101    0.000    0.362    0.362
##   TEFFs ~~                                                              
##     LV               -0.104    0.022   -4.651    0.000   -0.278   -0.278
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q17_1             0.285    0.022   13.018    0.000    0.285    0.690
##    .Q17_3             0.333    0.028   11.821    0.000    0.333    0.581
##    .Q17_5             0.230    0.026    8.712    0.000    0.230    0.411
##    .Q19_1             0.254    0.022   11.760    0.000    0.254    0.305
##    .Q19_2             0.316    0.024   13.071    0.000    0.316    0.428
##    .Q19_3             0.204    0.019   10.992    0.000    0.204    0.260
##    .Q19_4             0.299    0.024   12.604    0.000    0.299    0.374
##    .Q19_5             0.421    0.032   13.373    0.000    0.421    0.472
##    .Q20_2             0.277    0.024   11.645    0.000    0.277    0.361
##    .Q20_3             0.460    0.034   13.328    0.000    0.460    0.538
##    .Q20_5             0.469    0.034   13.718    0.000    0.469    0.608
##    .Q20_6             0.397    0.031   12.944    0.000    0.397    0.484
##    .Q20_7             0.306    0.026   11.953    0.000    0.306    0.384
##    .Q20_8             0.416    0.030   13.881    0.000    0.416    0.643
##    .Q23_3             0.408    0.029   14.232    0.000    0.408    0.823
##    .Q23_8             0.379    0.040    9.482    0.000    0.379    0.405
##    .Q23_9             0.241    0.038    6.396    0.000    0.241    0.279
##    .Q41_1             0.351    0.036    9.736    0.000    0.351    0.546
##    .Q41_2             0.141    0.041    3.444    0.001    0.141    0.246
##    .Q41_4             0.353    0.025   14.069    0.000    0.353    0.835
##    .Q44_1             0.190    0.015   12.421    0.000    0.190    0.389
##    .Q44_2             0.074    0.008    8.666    0.000    0.074    0.209
##    .Q44_3             0.098    0.011    9.207    0.000    0.098    0.226
##    .Q44_4             0.242    0.018   13.449    0.000    0.242    0.517
##    .Q15_4             0.731    0.054   13.550    0.000    0.731    0.607
##    .Q21               0.383    0.032   12.054    0.000    0.383    0.427
##    .Q25               0.230    0.023    9.996    0.000    0.230    0.307
##    .Q29               0.589    0.041   14.338    0.000    0.589    0.788
##    .Q41_3             0.682    0.047   14.377    0.000    0.682    0.800
##     Teachs            0.128    0.023    5.638    0.000    1.000    1.000
##     ANXs              0.580    0.055   10.546    0.000    1.000    1.000
##     DEPs              0.491    0.050    9.749    0.000    1.000    1.000
##     PRO               0.088    0.021    4.234    0.000    1.000    1.000
##     ASSMs             0.292    0.045    6.440    0.000    1.000    1.000
##     TEFFs             0.298    0.031    9.507    0.000    1.000    1.000
##     LV                0.474    0.068    6.960    0.000    1.000    1.000
parameterEstimates(fitE2, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  dplyr::select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
Teachs Q17_1 1.000 0.000 NA NA 0.557
Teachs Q17_3 1.370 0.146 9.400 0 0.647
Teachs Q17_5 1.603 0.159 10.071 0 0.767
ANXs Q19_1 1.000 0.000 NA NA 0.834
ANXs Q19_2 0.854 0.047 18.181 0 0.756
ANXs Q19_3 1.000 0.046 21.938 0 0.860
ANXs Q19_4 0.930 0.048 19.394 0 0.791
ANXs Q19_5 0.901 0.052 17.187 0 0.726
DEPs Q20_2 1.000 0.000 NA NA 0.800
DEPs Q20_3 0.897 0.061 14.802 0 0.680
DEPs Q20_5 0.786 0.058 13.446 0 0.626
DEPs Q20_6 0.930 0.059 15.824 0 0.719
DEPs Q20_7 1.000 0.057 17.616 0 0.785
DEPs Q20_8 0.687 0.054 12.740 0 0.598
PRO Q23_3 1.000 0.000 NA NA 0.420
PRO Q23_8 2.520 0.310 8.139 0 0.771
PRO Q23_9 2.667 0.325 8.203 0 0.849
ASSMs Q41_1 1.000 0.000 NA NA 0.674
ASSMs Q41_2 1.216 0.129 9.459 0 0.869
ASSMs Q41_4 0.489 0.066 7.416 0 0.406
TEFFs Q44_1 1.000 0.000 NA NA 0.782
TEFFs Q44_2 0.967 0.048 20.181 0 0.890
TEFFs Q44_3 1.061 0.053 19.979 0 0.880
TEFFs Q44_4 0.871 0.058 15.129 0 0.695
LV Q15_4 1.000 0.000 NA NA 0.627
LV Q21 1.042 0.081 12.819 0 0.757
LV Q25 1.048 0.077 13.640 0 0.833
LV Q29 0.577 0.068 8.547 0 0.460
LV Q41_3 0.599 0.072 8.329 0 0.447
CFAStand<-standardizedsolution(fitE2, type = "std.all")
write.csv(CFAStand, "CFAStand.csv")
CFAStand
##       lhs op    rhs est.std    se       z pvalue ci.lower ci.upper
## 1  Teachs =~  Q17_1   0.557 0.040  13.896  0.000    0.478    0.635
## 2  Teachs =~  Q17_3   0.647 0.036  17.996  0.000    0.577    0.718
## 3  Teachs =~  Q17_5   0.767 0.032  24.199  0.000    0.705    0.829
## 4    ANXs =~  Q19_1   0.834 0.017  48.144  0.000    0.800    0.868
## 5    ANXs =~  Q19_2   0.756 0.023  33.160  0.000    0.712    0.801
## 6    ANXs =~  Q19_3   0.860 0.015  55.612  0.000    0.830    0.890
## 7    ANXs =~  Q19_4   0.791 0.020  38.857  0.000    0.751    0.831
## 8    ANXs =~  Q19_5   0.726 0.025  29.226  0.000    0.678    0.775
## 9    DEPs =~  Q20_2   0.800 0.021  38.138  0.000    0.758    0.841
## 10   DEPs =~  Q20_3   0.680 0.029  23.627  0.000    0.623    0.736
## 11   DEPs =~  Q20_5   0.626 0.032  19.595  0.000    0.564    0.689
## 12   DEPs =~  Q20_6   0.719 0.026  27.315  0.000    0.667    0.770
## 13   DEPs =~  Q20_7   0.785 0.022  35.778  0.000    0.742    0.828
## 14   DEPs =~  Q20_8   0.598 0.034  17.798  0.000    0.532    0.664
## 15    PRO =~  Q23_3   0.420 0.044   9.552  0.000    0.334    0.506
## 16    PRO =~  Q23_8   0.771 0.029  26.822  0.000    0.715    0.828
## 17    PRO =~  Q23_9   0.849 0.027  31.825  0.000    0.797    0.902
## 18  ASSMs =~  Q41_1   0.674 0.041  16.513  0.000    0.594    0.754
## 19  ASSMs =~  Q41_2   0.869 0.042  20.875  0.000    0.787    0.950
## 20  ASSMs =~  Q41_4   0.406 0.046   8.778  0.000    0.316    0.497
## 21  TEFFs =~  Q44_1   0.782 0.022  36.294  0.000    0.739    0.824
## 22  TEFFs =~  Q44_2   0.890 0.015  60.024  0.000    0.860    0.919
## 23  TEFFs =~  Q44_3   0.880 0.015  57.289  0.000    0.850    0.910
## 24  TEFFs =~  Q44_4   0.695 0.027  25.454  0.000    0.641    0.748
## 25     LV =~  Q15_4   0.627 0.032  19.376  0.000    0.564    0.691
## 26     LV =~    Q21   0.757 0.024  30.948  0.000    0.709    0.805
## 27     LV =~    Q25   0.833 0.020  41.687  0.000    0.793    0.872
## 28     LV =~    Q29   0.460 0.041  11.291  0.000    0.380    0.540
## 29     LV =~  Q41_3   0.447 0.041  10.819  0.000    0.366    0.528
## 30  Q17_1 ~~  Q17_1   0.690 0.045  15.455  0.000    0.602    0.777
## 31  Q17_3 ~~  Q17_3   0.581 0.047  12.476  0.000    0.490    0.672
## 32  Q17_5 ~~  Q17_5   0.411 0.049   8.459  0.000    0.316    0.507
## 33  Q19_1 ~~  Q19_1   0.305 0.029  10.543  0.000    0.248    0.361
## 34  Q19_2 ~~  Q19_2   0.428 0.035  12.399  0.000    0.360    0.495
## 35  Q19_3 ~~  Q19_3   0.260 0.027   9.787  0.000    0.208    0.312
## 36  Q19_4 ~~  Q19_4   0.374 0.032  11.598  0.000    0.311    0.437
## 37  Q19_5 ~~  Q19_5   0.472 0.036  13.085  0.000    0.402    0.543
## 38  Q20_2 ~~  Q20_2   0.361 0.034  10.764  0.000    0.295    0.426
## 39  Q20_3 ~~  Q20_3   0.538 0.039  13.754  0.000    0.461    0.615
## 40  Q20_5 ~~  Q20_5   0.608 0.040  15.177  0.000    0.529    0.686
## 41  Q20_6 ~~  Q20_6   0.484 0.038  12.786  0.000    0.409    0.558
## 42  Q20_7 ~~  Q20_7   0.384 0.034  11.147  0.000    0.316    0.451
## 43  Q20_8 ~~  Q20_8   0.643 0.040  16.012  0.000    0.564    0.721
## 44  Q23_3 ~~  Q23_3   0.823 0.037  22.268  0.000    0.751    0.896
## 45  Q23_8 ~~  Q23_8   0.405 0.044   9.137  0.000    0.318    0.492
## 46  Q23_9 ~~  Q23_9   0.279 0.045   6.149  0.000    0.190    0.368
## 47  Q41_1 ~~  Q41_1   0.546 0.055   9.934  0.000    0.438    0.654
## 48  Q41_2 ~~  Q41_2   0.246 0.072   3.398  0.001    0.104    0.387
## 49  Q41_4 ~~  Q41_4   0.835 0.038  22.211  0.000    0.761    0.909
## 50  Q44_1 ~~  Q44_1   0.389 0.034  11.560  0.000    0.323    0.455
## 51  Q44_2 ~~  Q44_2   0.209 0.026   7.919  0.000    0.157    0.260
## 52  Q44_3 ~~  Q44_3   0.226 0.027   8.371  0.000    0.173    0.279
## 53  Q44_4 ~~  Q44_4   0.517 0.038  13.644  0.000    0.443    0.592
## 54  Q15_4 ~~  Q15_4   0.607 0.041  14.933  0.000    0.527    0.686
## 55    Q21 ~~    Q21   0.427 0.037  11.513  0.000    0.354    0.499
## 56    Q25 ~~    Q25   0.307 0.033   9.224  0.000    0.242    0.372
## 57    Q29 ~~    Q29   0.788 0.037  21.035  0.000    0.715    0.862
## 58  Q41_3 ~~  Q41_3   0.800 0.037  21.690  0.000    0.728    0.873
## 59 Teachs ~~ Teachs   1.000 0.000      NA     NA    1.000    1.000
## 60   ANXs ~~   ANXs   1.000 0.000      NA     NA    1.000    1.000
## 61   DEPs ~~   DEPs   1.000 0.000      NA     NA    1.000    1.000
## 62    PRO ~~    PRO   1.000 0.000      NA     NA    1.000    1.000
## 63  ASSMs ~~  ASSMs   1.000 0.000      NA     NA    1.000    1.000
## 64  TEFFs ~~  TEFFs   1.000 0.000      NA     NA    1.000    1.000
## 65     LV ~~     LV   1.000 0.000      NA     NA    1.000    1.000
## 66 Teachs ~~   ANXs  -0.403 0.052  -7.820  0.000   -0.505   -0.302
## 67 Teachs ~~   DEPs  -0.379 0.054  -7.056  0.000   -0.484   -0.274
## 68 Teachs ~~    PRO   0.501 0.051   9.761  0.000    0.401    0.602
## 69 Teachs ~~  ASSMs   0.035 0.062   0.567  0.571   -0.087    0.157
## 70 Teachs ~~  TEFFs   0.484 0.048  10.012  0.000    0.389    0.579
## 71 Teachs ~~     LV  -0.676 0.042 -16.136  0.000   -0.759   -0.594
## 72   ANXs ~~   DEPs   0.829 0.022  37.867  0.000    0.786    0.872
## 73   ANXs ~~    PRO  -0.418 0.048  -8.784  0.000   -0.511   -0.325
## 74   ANXs ~~  ASSMs   0.266 0.053   5.035  0.000    0.163    0.370
## 75   ANXs ~~  TEFFs  -0.148 0.051  -2.877  0.004   -0.249   -0.047
## 76   ANXs ~~     LV   0.673 0.034  19.726  0.000    0.606    0.740
## 77   DEPs ~~    PRO  -0.349 0.051  -6.832  0.000   -0.450   -0.249
## 78   DEPs ~~  ASSMs   0.282 0.054   5.246  0.000    0.176    0.387
## 79   DEPs ~~  TEFFs  -0.180 0.052  -3.463  0.001   -0.282   -0.078
## 80   DEPs ~~     LV   0.626 0.038  16.457  0.000    0.552    0.701
## 81    PRO ~~  ASSMs  -0.178 0.058  -3.091  0.002   -0.291   -0.065
## 82    PRO ~~  TEFFs   0.187 0.054   3.465  0.001    0.081    0.292
## 83    PRO ~~     LV  -0.711 0.036 -19.885  0.000   -0.781   -0.641
## 84  ASSMs ~~  TEFFs   0.085 0.055   1.535  0.125   -0.023    0.193
## 85  ASSMs ~~     LV   0.362 0.053   6.818  0.000    0.258    0.466
## 86  TEFFs ~~     LV  -0.278 0.051  -5.416  0.000   -0.378   -0.177
residuals(fitE2, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##       Q17_1  Q17_3  Q17_5  Q19_1  Q19_2  Q19_3  Q19_4  Q19_5  Q20_2  Q20_3 
## Q17_1  0.000                                                               
## Q17_3  0.062  0.000                                                        
## Q17_5 -0.026 -0.008  0.000                                                 
## Q19_1 -0.003 -0.038  0.029  0.000                                          
## Q19_2 -0.003 -0.065  0.035  0.011  0.000                                   
## Q19_3  0.044 -0.037  0.068 -0.012  0.044  0.000                            
## Q19_4 -0.060 -0.094 -0.026 -0.026 -0.024  0.025  0.000                     
## Q19_5 -0.065 -0.065  0.075  0.007 -0.025 -0.012 -0.010  0.000              
## Q20_2 -0.025  0.008  0.020  0.027 -0.079 -0.039  0.045  0.098  0.000       
## Q20_3  0.040 -0.024  0.032  0.034  0.045  0.051  0.025  0.048 -0.017  0.000
## Q20_5  0.001  0.002  0.018 -0.004 -0.032 -0.006  0.048  0.000 -0.039  0.072
## Q20_6 -0.110 -0.061 -0.073  0.035 -0.079 -0.075 -0.032  0.034  0.049 -0.043
## Q20_7 -0.013 -0.018  0.039  0.005 -0.019  0.000  0.009  0.016 -0.016 -0.016
## Q20_8  0.034  0.027  0.066  0.017 -0.106 -0.057 -0.037  0.040  0.001 -0.027
## Q23_3  0.058  0.061  0.064 -0.064  0.033  0.017 -0.030 -0.063 -0.151  0.011
## Q23_8 -0.036 -0.017 -0.075 -0.024 -0.007  0.049  0.006  0.020  0.007  0.015
## Q23_9 -0.016  0.031  0.030 -0.030 -0.020  0.020  0.005 -0.002 -0.018 -0.008
## Q41_1  0.029 -0.032 -0.050 -0.042 -0.044 -0.044  0.067 -0.085 -0.001 -0.024
## Q41_2  0.060  0.010  0.010  0.007  0.033 -0.016  0.045 -0.016 -0.037  0.027
## Q41_4  0.006 -0.064 -0.125  0.010  0.019  0.008  0.018  0.013  0.069  0.056
## Q44_1 -0.030 -0.026  0.107  0.025  0.032  0.045 -0.021  0.024 -0.001  0.052
## Q44_2 -0.032 -0.085  0.019 -0.016  0.028 -0.017 -0.043 -0.030 -0.056  0.016
## Q44_3 -0.002 -0.054  0.012 -0.002  0.064  0.030 -0.001  0.014 -0.067  0.025
## Q44_4 -0.013  0.011  0.086 -0.063 -0.026 -0.029 -0.041 -0.044 -0.084  0.015
## Q15_4 -0.030  0.010 -0.059 -0.034 -0.033 -0.083 -0.056 -0.045 -0.036 -0.012
## Q21    0.007 -0.020  0.000  0.132  0.094  0.047  0.066  0.067  0.098  0.047
## Q25    0.044  0.008  0.015 -0.034 -0.024 -0.073 -0.012 -0.058 -0.019 -0.049
## Q29   -0.033 -0.041 -0.157 -0.030  0.022 -0.003  0.058 -0.029 -0.022 -0.061
## Q41_3  0.095  0.098  0.069  0.053  0.028  0.049  0.075  0.025  0.041  0.014
##       Q20_5  Q20_6  Q20_7  Q20_8  Q23_3  Q23_8  Q23_9  Q41_1  Q41_2  Q41_4 
## Q17_1                                                                      
## Q17_3                                                                      
## Q17_5                                                                      
## Q19_1                                                                      
## Q19_2                                                                      
## Q19_3                                                                      
## Q19_4                                                                      
## Q19_5                                                                      
## Q20_2                                                                      
## Q20_3                                                                      
## Q20_5  0.000                                                               
## Q20_6  0.006  0.000                                                        
## Q20_7  0.001 -0.009  0.000                                                 
## Q20_8 -0.034 -0.003  0.081  0.000                                          
## Q23_3 -0.028 -0.143  0.024 -0.039  0.000                                   
## Q23_8 -0.052  0.040  0.078  0.060  0.069  0.000                            
## Q23_9 -0.067 -0.013  0.033  0.004 -0.055  0.003  0.000                     
## Q41_1  0.062 -0.022 -0.062 -0.045 -0.045 -0.022 -0.027  0.000              
## Q41_2  0.046  0.004  0.022 -0.032 -0.001  0.002  0.029  0.001  0.000       
## Q41_4 -0.009  0.036  0.012  0.006 -0.036 -0.023 -0.078 -0.004 -0.001  0.000
## Q44_1  0.004  0.034  0.058  0.058 -0.066 -0.096 -0.058 -0.007  0.105 -0.015
## Q44_2 -0.015 -0.022  0.043  0.014  0.011 -0.010  0.024 -0.080  0.017 -0.029
## Q44_3 -0.016 -0.024  0.052  0.047 -0.010 -0.020  0.006 -0.103  0.027 -0.070
## Q44_4 -0.012 -0.045  0.008  0.019  0.053  0.064  0.108 -0.064 -0.008 -0.123
## Q15_4  0.019  0.008 -0.044 -0.031 -0.032  0.016  0.032  0.041 -0.026  0.070
## Q21    0.073  0.082  0.043  0.005  0.008  0.119  0.042  0.014 -0.038  0.040
## Q25   -0.017 -0.014 -0.059 -0.050 -0.061 -0.066 -0.107  0.005 -0.084  0.049
## Q29    0.008  0.013 -0.045 -0.051  0.093  0.149  0.066 -0.005 -0.102  0.008
## Q41_3  0.030  0.077  0.009  0.030 -0.005  0.077  0.099  0.315  0.424  0.226
##       Q44_1  Q44_2  Q44_3  Q44_4  Q15_4  Q21    Q25    Q29    Q41_3 
## Q17_1                                                               
## Q17_3                                                               
## Q17_5                                                               
## Q19_1                                                               
## Q19_2                                                               
## Q19_3                                                               
## Q19_4                                                               
## Q19_5                                                               
## Q20_2                                                               
## Q20_3                                                               
## Q20_5                                                               
## Q20_6                                                               
## Q20_7                                                               
## Q20_8                                                               
## Q23_3                                                               
## Q23_8                                                               
## Q23_9                                                               
## Q41_1                                                               
## Q41_2                                                               
## Q41_4                                                               
## Q44_1  0.000                                                        
## Q44_2  0.011  0.000                                                 
## Q44_3 -0.016  0.004  0.000                                          
## Q44_4 -0.007 -0.017  0.014  0.000                                   
## Q15_4  0.056  0.040  0.037 -0.051  0.000                            
## Q21    0.031  0.036  0.020 -0.080  0.002  0.000                     
## Q25    0.054  0.009  0.021 -0.110  0.014  0.003  0.000              
## Q29   -0.200 -0.215 -0.244 -0.272 -0.007 -0.044  0.041  0.000       
## Q41_3  0.134  0.100  0.095  0.037  0.052 -0.012 -0.066  0.031  0.000
semPaths(fitE2, "par", edge.label.cex = 1.2, fade = FALSE, exoCov = FALSE)

library(bannerCommenter)
TeachAlpha<-dplyr:: select(teacher2, Q17_1, Q17_3, Q17_5)
GOVSAlpha<- dplyr:: select(teacher2, Q23_5, Q23_6, Q23_7)
PROSAlpha<- dplyr::select(teacher2,  Q23_3, Q23_8, Q23_9, Q23_10)
COMSAlpha<- dplyr::select(teacher2, Q23_1, Q23_2, Q23_4)
ASAlpha<- dplyr::select(teacher2, Q41_1, Q41_2, Q41_4)
TEFFAlpha<- dplyr::select(teacher2, Q44_1, Q44_2, Q44_3, Q44_4)

TotalAlpha<-dplyr:: select(teacher2, Q17_1, Q17_3, Q17_5,
                            Q23_5, Q23_6, Q23_7,
                           Q23_3, Q23_8, Q23_9,
                            Q23_1, Q23_2, Q23_4,
                           Q41_1, Q41_2, Q41_4,
                           Q44_1, Q44_2, Q44_3, Q44_4) 


banner("Teacher Identity")
## 
## ##################################################################
## ##                       Teacher Identity                       ##
## ##################################################################
omega(TeachAlpha)

## Omega 
## Call: omegah(m = m, nfactors = nfactors, fm = fm, key = key, flip = flip, 
##     digits = digits, title = title, sl = sl, labels = labels, 
##     plot = plot, n.obs = n.obs, rotate = rotate, Phi = Phi, option = option, 
##     covar = covar)
## Alpha:                 0.67 
## G.6:                   0.59 
## Omega Hierarchical:    0.06 
## Omega H asymptotic:    0.09 
## Omega Total            0.69 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##           g  F1*   F2*   F3*   h2   u2   p2
## Q17_1       0.49             0.29 0.71 0.12
## Q17_3  0.22 0.71             0.56 0.44 0.09
## Q17_5       0.65             0.46 0.54 0.06
## 
## With eigenvalues of:
##    g  F1*  F2*  F3* 
## 0.11 1.17 0.03 0.00 
## 
## general/max  0.09   max/min =   Inf
## mean percent general =  0.09    with sd =  0.03 and cv of  0.33 
## Explained Common Variance of the general factor =  0.08 
## 
## The degrees of freedom are -3  and the fit is  0 
## The number of observations was  679  with Chi Square =  0  with prob <  NA
## The root mean square of the residuals is  0 
## The df corrected root mean square of the residuals is  NA
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 0  and the fit is  0.4 
## The number of observations was  679  with Chi Square =  271.32  with prob <  NA
## The root mean square of the residuals is  0.38 
## The df corrected root mean square of the residuals is  NA 
## 
## Measures of factor score adequacy             
##                                                   g  F1*   F2* F3*
## Correlation of scores with factors             0.25 0.81  0.20   0
## Multiple R square of scores with factors       0.06 0.65  0.04   0
## Minimum correlation of factor score estimates -0.88 0.31 -0.92  -1
## 
##  Total, General and Subset omega for each subset
##                                                  g  F1* F2* F3*
## Omega total for total scores and subscales    0.69 0.69  NA  NA
## Omega general for total scores and subscales  0.06 0.06  NA  NA
## Omega group for total scores and subscales    0.63 0.63  NA  NA
banner("Government Support")
## 
## ##################################################################
## ##                      Government Support                      ##
## ##################################################################
omega(GOVSAlpha)

## Omega 
## Call: omegah(m = m, nfactors = nfactors, fm = fm, key = key, flip = flip, 
##     digits = digits, title = title, sl = sl, labels = labels, 
##     plot = plot, n.obs = n.obs, rotate = rotate, Phi = Phi, option = option, 
##     covar = covar)
## Alpha:                 0.82 
## G.6:                   0.77 
## Omega Hierarchical:    0.02 
## Omega H asymptotic:    0.02 
## Omega Total            0.84 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##           g  F1*   F2*   F3*   h2   u2   p2
## Q23_5       0.80             0.67 0.33 0.02
## Q23_6       0.90             0.84 0.16 0.03
## Q23_7       0.61             0.41 0.59 0.03
## 
## With eigenvalues of:
##    g  F1*  F2*  F3* 
## 0.05 1.83 0.03 0.00 
## 
## general/max  0.03   max/min =   Inf
## mean percent general =  0.03    with sd =  0.01 and cv of  0.22 
## Explained Common Variance of the general factor =  0.02 
## 
## The degrees of freedom are -3  and the fit is  0 
## The number of observations was  679  with Chi Square =  0  with prob <  NA
## The root mean square of the residuals is  0 
## The df corrected root mean square of the residuals is  NA
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 0  and the fit is  1.14 
## The number of observations was  679  with Chi Square =  769.39  with prob <  NA
## The root mean square of the residuals is  0.59 
## The df corrected root mean square of the residuals is  NA 
## 
## Measures of factor score adequacy             
##                                                   g  F1*   F2* F3*
## Correlation of scores with factors             0.15 0.93  0.27   0
## Multiple R square of scores with factors       0.02 0.86  0.07   0
## Minimum correlation of factor score estimates -0.95 0.73 -0.85  -1
## 
##  Total, General and Subset omega for each subset
##                                                  g  F1* F2* F3*
## Omega total for total scores and subscales    0.84 0.83  NA  NA
## Omega general for total scores and subscales  0.02 0.02  NA  NA
## Omega group for total scores and subscales    0.81 0.81  NA  NA
banner("Professional Support")
## 
## ##################################################################
## ##                     Professional Support                     ##
## ##################################################################
omega(PROSAlpha)

## Omega 
## Call: omegah(m = m, nfactors = nfactors, fm = fm, key = key, flip = flip, 
##     digits = digits, title = title, sl = sl, labels = labels, 
##     plot = plot, n.obs = n.obs, rotate = rotate, Phi = Phi, option = option, 
##     covar = covar)
## Alpha:                 0.77 
## G.6:                   0.76 
## Omega Hierarchical:    0.66 
## Omega H asymptotic:    0.79 
## Omega Total            0.83 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##           g   F1*   F2*   F3*   h2   u2   p2
## Q23_3  0.36        0.39       0.29 0.71 0.45
## Q23_8  0.70        0.34       0.64 0.36 0.77
## Q23_9  0.79  0.45             0.84 0.16 0.75
## Q23_10 0.64  0.51             0.67 0.33 0.61
## 
## With eigenvalues of:
##    g  F1*  F2*  F3* 
## 1.66 0.47 0.27 0.03 
## 
## general/max  3.52   max/min =   18.01
## mean percent general =  0.64    with sd =  0.15 and cv of  0.23 
## Explained Common Variance of the general factor =  0.68 
## 
## The degrees of freedom are -3  and the fit is  0 
## The number of observations was  679  with Chi Square =  0  with prob <  NA
## The root mean square of the residuals is  0 
## The df corrected root mean square of the residuals is  NA
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 2  and the fit is  0.22 
## The number of observations was  679  with Chi Square =  145.88  with prob <  2.1e-32
## The root mean square of the residuals is  0.11 
## The df corrected root mean square of the residuals is  0.19 
## 
## RMSEA index =  0.326  and the 10 % confidence intervals are  0.282 0.372
## BIC =  132.84 
## 
## Measures of factor score adequacy             
##                                                  g   F1*   F2*   F3*
## Correlation of scores with factors            0.84  0.58  0.51  0.25
## Multiple R square of scores with factors      0.71  0.33  0.26  0.06
## Minimum correlation of factor score estimates 0.41 -0.33 -0.47 -0.88
## 
##  Total, General and Subset omega for each subset
##                                                  g  F1*  F2* F3*
## Omega total for total scores and subscales    0.83 0.86 0.61  NA
## Omega general for total scores and subscales  0.66 0.60 0.41  NA
## Omega group for total scores and subscales    0.15 0.26 0.20  NA
banner("Community Support")
## 
## #################################################################
## ##                      Community Support                      ##
## #################################################################
omega(COMSAlpha)

## Omega 
## Call: omegah(m = m, nfactors = nfactors, fm = fm, key = key, flip = flip, 
##     digits = digits, title = title, sl = sl, labels = labels, 
##     plot = plot, n.obs = n.obs, rotate = rotate, Phi = Phi, option = option, 
##     covar = covar)
## Alpha:                 0.81 
## G.6:                   0.75 
## Omega Hierarchical:    0.02 
## Omega H asymptotic:    0.02 
## Omega Total            0.82 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##           g  F1*   F2*   F3*   h2   u2   p2
## Q23_1       0.74             0.57 0.43 0.01
## Q23_2       0.87             0.76 0.24 0.02
## Q23_4       0.68             0.49 0.51 0.03
## 
## With eigenvalues of:
##    g  F1*  F2*  F3* 
## 0.04 1.76 0.03 0.00 
## 
## general/max  0.02   max/min =   Inf
## mean percent general =  0.02    with sd =  0.01 and cv of  0.5 
## Explained Common Variance of the general factor =  0.02 
## 
## The degrees of freedom are -3  and the fit is  0 
## The number of observations was  679  with Chi Square =  0  with prob <  NA
## The root mean square of the residuals is  0 
## The df corrected root mean square of the residuals is  NA
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 0  and the fit is  1 
## The number of observations was  679  with Chi Square =  673.48  with prob <  NA
## The root mean square of the residuals is  0.58 
## The df corrected root mean square of the residuals is  NA 
## 
## Measures of factor score adequacy             
##                                                   g  F1*   F2* F3*
## Correlation of scores with factors             0.13 0.91  0.25   0
## Multiple R square of scores with factors       0.02 0.83  0.06   0
## Minimum correlation of factor score estimates -0.96 0.66 -0.88  -1
## 
##  Total, General and Subset omega for each subset
##                                                  g  F1* F2* F3*
## Omega total for total scores and subscales    0.82 0.82  NA  NA
## Omega general for total scores and subscales  0.02 0.02  NA  NA
## Omega group for total scores and subscales    0.80 0.80  NA  NA
banner("Assessment")
## 
## ##################################################################
## ##                          Assessment                          ##
## ##################################################################
omega(ASAlpha)

## Omega 
## Call: omegah(m = m, nfactors = nfactors, fm = fm, key = key, flip = flip, 
##     digits = digits, title = title, sl = sl, labels = labels, 
##     plot = plot, n.obs = n.obs, rotate = rotate, Phi = Phi, option = option, 
##     covar = covar)
## Alpha:                 0.65 
## G.6:                   0.58 
## Omega Hierarchical:    0.03 
## Omega H asymptotic:    0.04 
## Omega Total            0.69 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##           g  F1*   F2*   F3*   h2   u2   p2
## Q41_1       0.71             0.53 0.47 0.02
## Q41_2       0.79             0.65 0.35 0.04
## Q41_4       0.38             0.18 0.82 0.06
## 
## With eigenvalues of:
##    g  F1*  F2*  F3* 
## 0.05 1.26 0.05 0.00 
## 
## general/max  0.04   max/min =   Inf
## mean percent general =  0.04    with sd =  0.02 and cv of  0.5 
## Explained Common Variance of the general factor =  0.04 
## 
## The degrees of freedom are -3  and the fit is  0 
## The number of observations was  679  with Chi Square =  0  with prob <  NA
## The root mean square of the residuals is  0 
## The df corrected root mean square of the residuals is  NA
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 0  and the fit is  0.47 
## The number of observations was  679  with Chi Square =  317.93  with prob <  NA
## The root mean square of the residuals is  0.39 
## The df corrected root mean square of the residuals is  NA 
## 
## Measures of factor score adequacy             
##                                                   g  F1*   F2* F3*
## Correlation of scores with factors             0.17 0.85  0.27   0
## Multiple R square of scores with factors       0.03 0.73  0.07   0
## Minimum correlation of factor score estimates -0.94 0.46 -0.86  -1
## 
##  Total, General and Subset omega for each subset
##                                                  g  F1* F2* F3*
## Omega total for total scores and subscales    0.69 0.69  NA  NA
## Omega general for total scores and subscales  0.03 0.03  NA  NA
## Omega group for total scores and subscales    0.66 0.66  NA  NA
banner("Teaching Efficacy")
## 
## #################################################################
## ##                      Teaching Efficacy                      ##
## #################################################################
banner("Total")
## 
## #################################################################
## ##                            Total                            ##
## #################################################################
omega(TotalAlpha)

## Omega 
## Call: omegah(m = m, nfactors = nfactors, fm = fm, key = key, flip = flip, 
##     digits = digits, title = title, sl = sl, labels = labels, 
##     plot = plot, n.obs = n.obs, rotate = rotate, Phi = Phi, option = option, 
##     covar = covar)
## Alpha:                 0.84 
## G.6:                   0.89 
## Omega Hierarchical:    0.43 
## Omega H asymptotic:    0.48 
## Omega Total            0.88 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##           g   F1* F2*   F3*   h2   u2   p2
## Q17_1  0.24  0.35           0.19 0.81 0.31
## Q17_3  0.27  0.42           0.25 0.75 0.30
## Q17_5  0.47  0.40           0.38 0.62 0.59
## Q23_5        0.64           0.44 0.56 0.05
## Q23_6        0.70           0.51 0.49 0.03
## Q23_7        0.59           0.37 0.63 0.05
## Q23_3        0.31           0.12 0.88 0.09
## Q23_8        0.50           0.27 0.73 0.02
## Q23_9        0.66           0.46 0.54 0.03
## Q23_1  0.48  0.43           0.43 0.57 0.55
## Q23_2  0.39  0.55           0.45 0.55 0.34
## Q23_4  0.37  0.60           0.50 0.50 0.28
## Q41_1-                -0.67 0.45 0.55 0.00
## Q41_2                  0.84 0.70 0.30 0.01
## Q41_4-                -0.36 0.18 0.82 0.00
## Q44_1  0.80                 0.65 0.35 0.99
## Q44_2  0.85                 0.71 0.29 1.01
## Q44_3  0.86                 0.74 0.26 1.01
## Q44_4  0.70                 0.50 0.50 0.98
## 
## With eigenvalues of:
##   g F1* F2* F3* 
## 3.6 3.4 0.0 1.3 
## 
## general/max  1.06   max/min =   Inf
## mean percent general =  0.35    with sd =  0.39 and cv of  1.11 
## Explained Common Variance of the general factor =  0.43 
## 
## The degrees of freedom are 117  and the fit is  1.55 
## The number of observations was  679  with Chi Square =  1037.41  with prob <  2.5e-147
## The root mean square of the residuals is  0.06 
## The df corrected root mean square of the residuals is  0.07
## RMSEA index =  0.108  and the 10 % confidence intervals are  0.102 0.114
## BIC =  274.5
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 152  and the fit is  4.55 
## The number of observations was  679  with Chi Square =  3050.99  with prob <  0
## The root mean square of the residuals is  0.19 
## The df corrected root mean square of the residuals is  0.21 
## 
## RMSEA index =  0.168  and the 10 % confidence intervals are  0.163 0.173
## BIC =  2059.86 
## 
## Measures of factor score adequacy             
##                                                  g  F1* F2*  F3*
## Correlation of scores with factors            0.95 0.93   0 0.89
## Multiple R square of scores with factors      0.90 0.86   0 0.79
## Minimum correlation of factor score estimates 0.80 0.73  -1 0.59
## 
##  Total, General and Subset omega for each subset
##                                                  g  F1* F2*  F3*
## Omega total for total scores and subscales    0.88 0.87  NA 0.61
## Omega general for total scores and subscales  0.43 0.29  NA 0.60
## Omega group for total scores and subscales    0.42 0.57  NA 0.01
itemdesc<- 
teacher2%>%
dplyr::select(Q17_1, Q17_3, Q17_5,
              Q19_1, Q19_2, Q19_3, Q19_4, Q19_5, 
              Q20_2, Q20_3, Q20_5, Q20_7, Q20_8,
              Q23_3, Q23_8, Q23_9,
              Q41_1, Q41_2, Q41_3, Q41_4, 
              Q44_1, Q44_2, Q44_3, Q44_4, 
              Q15_4, Q21, Q25, Q29)

itemsdescr<- describe(itemdesc)
write.csv(itemsdescr, "discrimination.csv")
itemsdescr
##       vars   n mean   sd median trimmed  mad min max range  skew kurtosis   se
## Q17_1    1 623 3.45 0.71      4    3.57 0.00   1   4     3 -1.28     1.53 0.03
## Q17_3    2 624 2.98 0.77      3    3.03 0.00   1   4     3 -0.53     0.08 0.03
## Q17_5    3 624 2.88 0.78      3    2.90 1.48   1   4     3 -0.30    -0.35 0.03
## Q19_1    4 623 2.83 0.92      3    2.90 1.48   1   4     3 -0.36    -0.72 0.04
## Q19_2    5 625 3.12 0.86      3    3.22 1.48   1   4     3 -0.73    -0.20 0.03
## Q19_3    6 622 2.91 0.88      3    2.99 1.48   1   4     3 -0.48    -0.49 0.04
## Q19_4    7 623 2.84 0.88      3    2.89 1.48   1   4     3 -0.32    -0.65 0.04
## Q19_5    8 624 2.43 0.93      2    2.41 1.48   1   4     3  0.15    -0.85 0.04
## Q20_2    9 623 2.30 0.87      2    2.26 1.48   1   4     3  0.16    -0.70 0.03
## Q20_3   10 622 2.77 0.93      3    2.84 1.48   1   4     3 -0.34    -0.73 0.04
## Q20_5   11 622 2.67 0.90      3    2.71 1.48   1   4     3 -0.20    -0.73 0.04
## Q20_7   12 622 2.53 0.90      3    2.53 1.48   1   4     3 -0.06    -0.77 0.04
## Q20_8   13 621 1.87 0.80      2    1.78 1.48   1   4     3  0.79     0.37 0.03
## Q23_3   14 605 3.06 0.70      3    3.11 0.00   1   4     3 -0.60     0.69 0.03
## Q23_8   15 604 2.55 0.99      3    2.57 1.48   1   4     3 -0.22    -1.00 0.04
## Q23_9   16 604 2.10 0.93      2    2.05 1.48   1   4     3  0.27    -1.01 0.04
## Q41_1   17 551 3.33 0.81      4    3.46 0.00   1   4     3 -1.10     0.59 0.03
## Q41_2   18 547 3.12 0.77      3    3.17 1.48   1   4     3 -0.44    -0.51 0.03
## Q41_3   19 548 2.59 0.91      3    2.62 1.48   1   4     3  0.08    -0.86 0.04
## Q41_4   20 552 3.25 0.66      3    3.32 0.00   1   4     3 -0.44    -0.29 0.03
## Q44_1   21 530 2.94 0.70      3    2.97 0.00   1   4     3 -0.55     0.63 0.03
## Q44_2   22 529 3.09 0.59      3    3.12 0.00   1   4     3 -0.19     0.45 0.03
## Q44_3   23 530 2.99 0.67      3    3.01 0.00   1   4     3 -0.33     0.23 0.03
## Q44_4   24 522 2.86 0.68      3    2.87 0.00   1   4     3 -0.47     0.51 0.03
## Q15_4   25 594 2.84 1.10      3    2.93 1.48   1   4     3 -0.49    -1.10 0.05
## Q21     26 620 2.70 0.96      3    2.75 1.48   1   4     3 -0.33    -0.84 0.04
## Q25     27 597 2.95 0.87      3    3.01 1.48   1   4     3 -0.50    -0.43 0.04
## Q29     28 574 2.56 0.87      3    2.57 1.48   1   4     3 -0.09    -0.66 0.04
mentalSEM<- 
  
  '
ANXs=~ Q19_1 + Q19_2 + Q19_3 + Q19_4 + Q19_5
DEPs=~ Q20_1 + Q20_2 + Q20_3 + Q20_4 + Q20_5 + Q20_6 + Q20_7 + Q20_8
LV=~  Q15_4 + Q21 + Q25 + Q29 + Q41_3

LV ~ ANXs
LV ~ DEPs

  
 '

fithealth<- sem(mentalSEM, data=teacher2)



summary(fithealth, fit.measures=TRUE, standardized = TRUE, rsquare = T)
## lavaan 0.6-12 ended normally after 39 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        39
## 
##                                                   Used       Total
##   Number of observations                           475         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                               374.897
##   Degrees of freedom                               132
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              4570.783
##   Degrees of freedom                               153
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.945
##   Tucker-Lewis Index (TLI)                       0.936
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -9037.860
##   Loglikelihood unrestricted model (H1)      -8850.412
##                                                       
##   Akaike (AIC)                               18153.721
##   Bayesian (BIC)                             18316.090
##   Sample-size adjusted Bayesian (BIC)        18192.310
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.062
##   90 Percent confidence interval - lower         0.055
##   90 Percent confidence interval - upper         0.070
##   P-value RMSEA <= 0.05                          0.003
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.042
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   ANXs =~                                                               
##     Q19_1             1.000                               0.765    0.832
##     Q19_2             0.851    0.045   18.933    0.000    0.651    0.762
##     Q19_3             0.993    0.044   22.490    0.000    0.759    0.858
##     Q19_4             0.935    0.046   20.371    0.000    0.715    0.802
##     Q19_5             0.875    0.051   17.223    0.000    0.669    0.711
##   DEPs =~                                                               
##     Q20_1             1.000                               0.648    0.769
##     Q20_2             1.097    0.058   18.800    0.000    0.711    0.820
##     Q20_3             0.985    0.064   15.435    0.000    0.639    0.692
##     Q20_4             0.828    0.055   15.158    0.000    0.537    0.681
##     Q20_5             0.890    0.061   14.519    0.000    0.577    0.656
##     Q20_6             0.985    0.062   15.856    0.000    0.639    0.709
##     Q20_7             1.049    0.060   17.367    0.000    0.681    0.766
##     Q20_8             0.705    0.056   12.599    0.000    0.457    0.577
##   LV =~                                                                 
##     Q15_4             1.000                               0.696    0.634
##     Q21               1.084    0.081   13.371    0.000    0.755    0.798
##     Q25               1.000    0.075   13.421    0.000    0.696    0.803
##     Q29               0.569    0.065    8.724    0.000    0.396    0.462
##     Q41_3             0.559    0.069    8.099    0.000    0.389    0.425
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   LV ~                                                                  
##     ANXs              0.440    0.081    5.426    0.000    0.483    0.483
##     DEPs              0.282    0.092    3.080    0.002    0.263    0.263
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   ANXs ~~                                                               
##     DEPs              0.402    0.037   11.006    0.000    0.810    0.810
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q19_1             0.261    0.021   12.214    0.000    0.261    0.309
##    .Q19_2             0.307    0.023   13.457    0.000    0.307    0.420
##    .Q19_3             0.208    0.018   11.442    0.000    0.208    0.265
##    .Q19_4             0.284    0.022   12.855    0.000    0.284    0.357
##    .Q19_5             0.439    0.031   13.972    0.000    0.439    0.495
##    .Q20_1             0.291    0.022   13.287    0.000    0.291    0.409
##    .Q20_2             0.247    0.020   12.387    0.000    0.247    0.328
##    .Q20_3             0.444    0.032   14.065    0.000    0.444    0.521
##    .Q20_4             0.333    0.024   14.144    0.000    0.333    0.536
##    .Q20_5             0.442    0.031   14.308    0.000    0.442    0.570
##    .Q20_6             0.405    0.029   13.933    0.000    0.405    0.498
##    .Q20_7             0.325    0.024   13.318    0.000    0.325    0.413
##    .Q20_8             0.418    0.028   14.682    0.000    0.418    0.667
##    .Q15_4             0.722    0.053   13.532    0.000    0.722    0.598
##    .Q21               0.326    0.031   10.353    0.000    0.326    0.364
##    .Q25               0.267    0.026   10.160    0.000    0.267    0.355
##    .Q29               0.579    0.039   14.663    0.000    0.579    0.787
##    .Q41_3             0.687    0.046   14.804    0.000    0.687    0.819
##     ANXs              0.585    0.054   10.869    0.000    1.000    1.000
##     DEPs              0.421    0.044    9.652    0.000    1.000    1.000
##    .LV                0.239    0.036    6.619    0.000    0.492    0.492
## 
## R-Square:
##                    Estimate
##     Q19_1             0.691
##     Q19_2             0.580
##     Q19_3             0.735
##     Q19_4             0.643
##     Q19_5             0.505
##     Q20_1             0.591
##     Q20_2             0.672
##     Q20_3             0.479
##     Q20_4             0.464
##     Q20_5             0.430
##     Q20_6             0.502
##     Q20_7             0.587
##     Q20_8             0.333
##     Q15_4             0.402
##     Q21               0.636
##     Q25               0.645
##     Q29               0.213
##     Q41_3             0.181
##     LV                0.508
semfit<- standardizedsolution(fithealth, type = "std.all")

write.csv(semfit, "anxSEMModel.csv")

semfit
##      lhs op   rhs est.std    se      z pvalue ci.lower ci.upper
## 1   ANXs =~ Q19_1   0.832 0.017 49.141  0.000    0.798    0.865
## 2   ANXs =~ Q19_2   0.762 0.022 35.087  0.000    0.719    0.804
## 3   ANXs =~ Q19_3   0.858 0.015 56.650  0.000    0.828    0.887
## 4   ANXs =~ Q19_4   0.802 0.019 42.229  0.000    0.764    0.839
## 5   ANXs =~ Q19_5   0.711 0.025 28.413  0.000    0.662    0.760
## 6   DEPs =~ Q20_1   0.769 0.021 36.037  0.000    0.727    0.811
## 7   DEPs =~ Q20_2   0.820 0.018 45.983  0.000    0.785    0.855
## 8   DEPs =~ Q20_3   0.692 0.026 26.324  0.000    0.641    0.744
## 9   DEPs =~ Q20_4   0.681 0.027 25.264  0.000    0.628    0.734
## 10  DEPs =~ Q20_5   0.656 0.028 23.018  0.000    0.600    0.712
## 11  DEPs =~ Q20_6   0.709 0.025 28.048  0.000    0.659    0.758
## 12  DEPs =~ Q20_7   0.766 0.021 35.667  0.000    0.724    0.809
## 13  DEPs =~ Q20_8   0.577 0.033 17.566  0.000    0.513    0.642
## 14    LV =~ Q15_4   0.634 0.032 19.729  0.000    0.571    0.697
## 15    LV =~   Q21   0.798 0.023 34.170  0.000    0.752    0.843
## 16    LV =~   Q25   0.803 0.023 34.823  0.000    0.758    0.848
## 17    LV =~   Q29   0.462 0.040 11.474  0.000    0.383    0.541
## 18    LV =~ Q41_3   0.425 0.042 10.189  0.000    0.343    0.507
## 19    LV  ~  ANXs   0.483 0.081  5.975  0.000    0.325    0.642
## 20    LV  ~  DEPs   0.263 0.083  3.178  0.001    0.101    0.425
## 21 Q19_1 ~~ Q19_1   0.309 0.028 10.966  0.000    0.253    0.364
## 22 Q19_2 ~~ Q19_2   0.420 0.033 12.705  0.000    0.355    0.485
## 23 Q19_3 ~~ Q19_3   0.265 0.026 10.196  0.000    0.214    0.316
## 24 Q19_4 ~~ Q19_4   0.357 0.030 11.743  0.000    0.298    0.417
## 25 Q19_5 ~~ Q19_5   0.495 0.036 13.913  0.000    0.425    0.564
## 26 Q20_1 ~~ Q20_1   0.409 0.033 12.470  0.000    0.345    0.473
## 27 Q20_2 ~~ Q20_2   0.328 0.029 11.202  0.000    0.270    0.385
## 28 Q20_3 ~~ Q20_3   0.521 0.036 14.318  0.000    0.450    0.592
## 29 Q20_4 ~~ Q20_4   0.536 0.037 14.594  0.000    0.464    0.608
## 30 Q20_5 ~~ Q20_5   0.570 0.037 15.258  0.000    0.497    0.643
## 31 Q20_6 ~~ Q20_6   0.498 0.036 13.910  0.000    0.428    0.568
## 32 Q20_7 ~~ Q20_7   0.413 0.033 12.526  0.000    0.348    0.477
## 33 Q20_8 ~~ Q20_8   0.667 0.038 17.586  0.000    0.593    0.741
## 34 Q15_4 ~~ Q15_4   0.598 0.041 14.691  0.000    0.518    0.678
## 35   Q21 ~~   Q21   0.364 0.037  9.770  0.000    0.291    0.437
## 36   Q25 ~~   Q25   0.355 0.037  9.574  0.000    0.282    0.427
## 37   Q29 ~~   Q29   0.787 0.037 21.137  0.000    0.714    0.859
## 38 Q41_3 ~~ Q41_3   0.819 0.035 23.103  0.000    0.750    0.889
## 39  ANXs ~~  ANXs   1.000 0.000     NA     NA    1.000    1.000
## 40  DEPs ~~  DEPs   1.000 0.000     NA     NA    1.000    1.000
## 41    LV ~~    LV   0.492 0.042 11.745  0.000    0.410    0.574
## 42  ANXs ~~  DEPs   0.810 0.021 38.034  0.000    0.768    0.852
semPaths(fithealth,  whatLabels = "std.all", structural = FALSE, edge.label.cex = .8, node.label.cex = .8, 
        label.prop=0.9, edge.label.color = "black", rotation = 4, 
        equalizeManifests = TRUE, optimizeLatRes = TRUE, node.width = 1.5, 
        edge.width = 0.5, shapeMan = "rectangle", shapeLat = "ellipse", 
        shapeInt = "triangle", sizeMan = 4, sizeInt = 2, sizeLat = 4, 
        curve=2, unCol = "#070b8c", title = FALSE, intercepts = FALSE, residuals = TRUE)

semPaths(fithealth,
        whatLabels = "std.all", structural = TRUE, edge.label.cex = 1, node.label.cex = 1.5, 
        label.prop=0.9, edge.label.color = "black", rotation = 2, 
        equalizeManifests = FALSE, optimizeLatRes = TRUE, node.width = 1.5, 
        edge.width = 0.5, shapeMan = "rectangle", shapeLat = "ellipse", 
        shapeInt = "triangle", sizeMan = 4, sizeInt = 2, sizeLat = 4, 
        curve=2, unCol = "#070b8c", title = FALSE, intercepts = FALSE, residuals = FALSE)

ANXAlpha<- dplyr:: select(teacher2, Q19_1, Q19_2, Q19_3, Q19_4, Q19_5)
DEPAlpha2<- dplyr:: select(teacher2,  Q20_1, Q20_2, Q20_3, Q20_4, Q20_5, Q20_7, Q20_8)
LeaveAlpha<-dplyr::select(teacher2, Q15_4, Q21, Q25, Q29, Q41_3) 

totalAlpha2<- dplyr:: select(teacher2, Q19_1, Q19_2, Q19_3, Q19_4, Q19_5, 
                             Q20_1, Q20_2, Q20_3, Q20_4, Q20_5, Q20_7, Q20_8,
                             Q15_4, Q21, Q25, Q29, Q41_3) 

bannerCommenter::banner("Anxiety Alpha and Omega")
## 
## #################################################################
## ##                   Anxiety Alpha and Omega                   ##
## #################################################################
omega(ANXAlpha)

## Omega 
## Call: omegah(m = m, nfactors = nfactors, fm = fm, key = key, flip = flip, 
##     digits = digits, title = title, sl = sl, labels = labels, 
##     plot = plot, n.obs = n.obs, rotate = rotate, Phi = Phi, option = option, 
##     covar = covar)
## Alpha:                 0.89 
## G.6:                   0.87 
## Omega Hierarchical:    0.87 
## Omega H asymptotic:    0.96 
## Omega Total            0.91 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##          g   F1*   F2*   F3*   h2   u2   p2
## Q19_1 0.85                   0.74 0.26 0.98
## Q19_2 0.79              0.20 0.66 0.34 0.96
## Q19_3 0.83        0.35       0.82 0.18 0.84
## Q19_4 0.74        0.30       0.64 0.36 0.85
## Q19_5 0.67                   0.51 0.49 0.90
## 
## With eigenvalues of:
##    g  F1*  F2*  F3* 
## 3.03 0.00 0.23 0.10 
## 
## general/max  13.12   max/min =   208.65
## mean percent general =  0.91    with sd =  0.06 and cv of  0.07 
## Explained Common Variance of the general factor =  0.9 
## 
## The degrees of freedom are -2  and the fit is  0 
## The number of observations was  679  with Chi Square =  0  with prob <  NA
## The root mean square of the residuals is  0 
## The df corrected root mean square of the residuals is  NA
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 5  and the fit is  0.07 
## The number of observations was  679  with Chi Square =  47.39  with prob <  4.7e-09
## The root mean square of the residuals is  0.04 
## The df corrected root mean square of the residuals is  0.06 
## 
## RMSEA index =  0.112  and the 10 % confidence intervals are  0.084 0.142
## BIC =  14.79 
## 
## Measures of factor score adequacy             
##                                                  g   F1*   F2*   F3*
## Correlation of scores with factors            0.94  0.04  0.56  0.46
## Multiple R square of scores with factors      0.88  0.00  0.31  0.21
## Minimum correlation of factor score estimates 0.77 -1.00 -0.38 -0.58
## 
##  Total, General and Subset omega for each subset
##                                                  g F1*  F2*  F3*
## Omega total for total scores and subscales    0.91  NA 0.84 0.82
## Omega general for total scores and subscales  0.87  NA 0.72 0.82
## Omega group for total scores and subscales    0.02  NA 0.12 0.00
bannerCommenter::banner("Depression Alpha and Omega")
## 
## ##################################################################
## ##                  Depression Alpha and Omega                  ##
## ##################################################################
omega(DEPAlpha2)

## Omega 
## Call: omegah(m = m, nfactors = nfactors, fm = fm, key = key, flip = flip, 
##     digits = digits, title = title, sl = sl, labels = labels, 
##     plot = plot, n.obs = n.obs, rotate = rotate, Phi = Phi, option = option, 
##     covar = covar)
## Alpha:                 0.88 
## G.6:                   0.88 
## Omega Hierarchical:    0.76 
## Omega H asymptotic:    0.83 
## Omega Total            0.92 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##          g   F1*   F2*   F3*   h2   u2   p2
## Q20_1 0.72  0.21  0.21       0.62 0.38 0.85
## Q20_2 0.86        0.50       1.00 0.00 0.75
## Q20_3 0.63  0.36             0.54 0.46 0.74
## Q20_4 0.62  0.52             0.65 0.35 0.58
## Q20_5 0.58  0.40             0.51 0.49 0.67
## Q20_7 0.68  0.22        0.25 0.58 0.42 0.79
## Q20_8 0.58              0.60 0.70 0.30 0.48
## 
## With eigenvalues of:
##    g  F1*  F2*  F3* 
## 3.18 0.66 0.30 0.45 
## 
## general/max  4.84   max/min =   2.19
## mean percent general =  0.69    with sd =  0.13 and cv of  0.18 
## Explained Common Variance of the general factor =  0.69 
## 
## The degrees of freedom are 3  and the fit is  0.01 
## The number of observations was  679  with Chi Square =  4  with prob <  0.26
## The root mean square of the residuals is  0.01 
## The df corrected root mean square of the residuals is  0.02
## RMSEA index =  0.022  and the 10 % confidence intervals are  0 0.072
## BIC =  -15.56
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 14  and the fit is  0.33 
## The number of observations was  679  with Chi Square =  219.32  with prob <  6.1e-39
## The root mean square of the residuals is  0.1 
## The df corrected root mean square of the residuals is  0.12 
## 
## RMSEA index =  0.147  and the 10 % confidence intervals are  0.13 0.165
## BIC =  128.03 
## 
## Measures of factor score adequacy             
##                                                  g   F1*   F2*  F3*
## Correlation of scores with factors            0.91  0.70  0.68 0.72
## Multiple R square of scores with factors      0.83  0.49  0.46 0.52
## Minimum correlation of factor score estimates 0.65 -0.01 -0.07 0.04
## 
##  Total, General and Subset omega for each subset
##                                                  g  F1*  F2*  F3*
## Omega total for total scores and subscales    0.92 0.83 1.00 0.75
## Omega general for total scores and subscales  0.76 0.62 0.75 0.51
## Omega group for total scores and subscales    0.11 0.21 0.25 0.24
bannerCommenter::banner("Quitting")
## 
## ##################################################################
## ##                           Quitting                           ##
## ##################################################################
omega(LeaveAlpha)

## Omega 
## Call: omegah(m = m, nfactors = nfactors, fm = fm, key = key, flip = flip, 
##     digits = digits, title = title, sl = sl, labels = labels, 
##     plot = plot, n.obs = n.obs, rotate = rotate, Phi = Phi, option = option, 
##     covar = covar)
## Alpha:                 0.76 
## G.6:                   0.73 
## Omega Hierarchical:    0.74 
## Omega H asymptotic:    0.94 
## Omega Total            0.79 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##          g   F1*   F2*   F3*   h2   u2   p2
## Q15_4 0.66        0.20       0.49 0.51 0.90
## Q21   0.72                   0.53 0.47 0.98
## Q25   0.87                   0.77 0.23 0.99
## Q29   0.45              0.34 0.32 0.68 0.64
## Q41_3 0.36        0.35       0.28 0.72 0.46
## 
## With eigenvalues of:
##    g  F1*  F2*  F3* 
## 2.05 0.00 0.20 0.15 
## 
## general/max  10.44   max/min =   Inf
## mean percent general =  0.79    with sd =  0.23 and cv of  0.3 
## Explained Common Variance of the general factor =  0.85 
## 
## The degrees of freedom are -2  and the fit is  0 
## The number of observations was  679  with Chi Square =  0  with prob <  NA
## The root mean square of the residuals is  0 
## The df corrected root mean square of the residuals is  NA
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 5  and the fit is  0.03 
## The number of observations was  679  with Chi Square =  23.01  with prob <  0.00034
## The root mean square of the residuals is  0.04 
## The df corrected root mean square of the residuals is  0.05 
## 
## RMSEA index =  0.073  and the 10 % confidence intervals are  0.044 0.104
## BIC =  -9.59 
## 
## Measures of factor score adequacy             
##                                                  g F1*   F2*   F3*
## Correlation of scores with factors            0.92   0  0.52  0.41
## Multiple R square of scores with factors      0.85   0  0.27  0.17
## Minimum correlation of factor score estimates 0.70  -1 -0.46 -0.67
## 
##  Total, General and Subset omega for each subset
##                                                  g F1*  F2*  F3*
## Omega total for total scores and subscales    0.79  NA 0.78 0.32
## Omega general for total scores and subscales  0.74  NA 0.75 0.20
## Omega group for total scores and subscales    0.03  NA 0.03 0.12
bannerCommenter::banner("Total")
## 
## #################################################################
## ##                            Total                            ##
## #################################################################
omega(totalAlpha2)

## Omega 
## Call: omegah(m = m, nfactors = nfactors, fm = fm, key = key, flip = flip, 
##     digits = digits, title = title, sl = sl, labels = labels, 
##     plot = plot, n.obs = n.obs, rotate = rotate, Phi = Phi, option = option, 
##     covar = covar)
## Alpha:                 0.92 
## G.6:                   0.93 
## Omega Hierarchical:    0.78 
## Omega H asymptotic:    0.83 
## Omega Total            0.94 
## 
## Schmid Leiman Factor loadings greater than  0.2 
##          g   F1*   F2*   F3*   h2   u2   p2
## Q19_1 0.72        0.36       0.67 0.33 0.78
## Q19_2 0.65        0.44       0.63 0.37 0.68
## Q19_3 0.74        0.48       0.78 0.22 0.71
## Q19_4 0.71        0.33       0.62 0.38 0.80
## Q19_5 0.63        0.26       0.48 0.52 0.82
## Q20_1 0.65  0.49             0.68 0.32 0.63
## Q20_2 0.71  0.41             0.68 0.32 0.75
## Q20_3 0.64  0.30             0.53 0.47 0.77
## Q20_4 0.62  0.30             0.48 0.52 0.79
## Q20_5 0.57  0.33             0.44 0.56 0.75
## Q20_7 0.67  0.36             0.58 0.42 0.76
## Q20_8 0.50  0.33             0.35 0.65 0.69
## Q15_4 0.44              0.52 0.46 0.54 0.41
## Q21   0.62              0.44 0.59 0.41 0.65
## Q25   0.54              0.60 0.66 0.34 0.45
## Q29   0.30              0.37 0.24 0.76 0.39
## Q41_3 0.33              0.25 0.18 0.82 0.61
## 
## With eigenvalues of:
##    g  F1*  F2*  F3* 
## 6.20 0.99 0.81 1.04 
## 
## general/max  5.94   max/min =   1.29
## mean percent general =  0.67    with sd =  0.14 and cv of  0.2 
## Explained Common Variance of the general factor =  0.68 
## 
## The degrees of freedom are 88  and the fit is  0.42 
## The number of observations was  679  with Chi Square =  278.26  with prob <  1.3e-21
## The root mean square of the residuals is  0.03 
## The df corrected root mean square of the residuals is  0.03
## RMSEA index =  0.056  and the 10 % confidence intervals are  0.049 0.064
## BIC =  -295.56
## 
## Compare this with the adequacy of just a general factor and no group factors
## The degrees of freedom for just the general factor are 119  and the fit is  1.77 
## The number of observations was  679  with Chi Square =  1188.47  with prob <  9.8e-176
## The root mean square of the residuals is  0.1 
## The df corrected root mean square of the residuals is  0.1 
## 
## RMSEA index =  0.115  and the 10 % confidence intervals are  0.109 0.121
## BIC =  412.52 
## 
## Measures of factor score adequacy             
##                                                  g   F1*   F2*  F3*
## Correlation of scores with factors            0.89  0.68  0.67 0.78
## Multiple R square of scores with factors      0.80  0.46  0.44 0.61
## Minimum correlation of factor score estimates 0.60 -0.08 -0.11 0.21
## 
##  Total, General and Subset omega for each subset
##                                                  g  F1*  F2*  F3*
## Omega total for total scores and subscales    0.94 0.88 0.89 0.77
## Omega general for total scores and subscales  0.78 0.66 0.68 0.39
## Omega group for total scores and subscales    0.11 0.22 0.20 0.37
matrix<- dplyr::select(teacher2, anx, Dep2, Leave)
matrix2<-na.omit(matrix)

apa.cor.table(matrix, filename = "correlation2.doc")
## 
## 
## Means, standard deviations, and correlations with confidence intervals
##  
## 
##   Variable M     SD   1          2         
##   1. anx   14.13 3.72                      
##                                            
##   2. Dep2  19.72 5.28 .74**                
##                       [.71, .78]           
##                                            
##   3. Leave 13.63 3.35 .58**      .53**     
##                       [.51, .63] [.47, .59]
##                                            
## 
## Note. M and SD are used to represent mean and standard deviation, respectively.
## Values in square brackets indicate the 95% confidence interval.
## The confidence interval is a plausible range of population correlations 
## that could have caused the sample correlation (Cumming, 2014).
##  * indicates p < .05. ** indicates p < .01.
## 
TeachModel2a<- 
  
  '
Teachs=~Q17_1 +  Q17_3 +  Q17_5
GOVa=~ Q23_5 + Q23_6 + Q23_7
PROa=~ Q23_3 + Q23_8 + Q23_9 + Q23_10
COMa=~ Q23_1 + Q23_2 + Q23_4
ASSMs=~ Q41_1 + Q41_2 + Q41_4
TEFFs=~ Q44_1 + Q44_2 + Q44_3 + Q44_4
 '

fitE<- cfa(TeachModel2a, data=teacher2)



summary(fitE, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-12 ended normally after 84 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        55
## 
##                                                   Used       Total
##   Number of observations                           494         679
## 
## Model Test User Model:
##                                                       
##   Test statistic                               399.146
##   Degrees of freedom                               155
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              4406.553
##   Degrees of freedom                               190
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.942
##   Tucker-Lewis Index (TLI)                       0.929
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -9425.359
##   Loglikelihood unrestricted model (H1)      -9225.786
##                                                       
##   Akaike (AIC)                               18960.718
##   Bayesian (BIC)                             19191.857
##   Sample-size adjusted Bayesian (BIC)        19017.286
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.056
##   90 Percent confidence interval - lower         0.050
##   90 Percent confidence interval - upper         0.063
##   P-value RMSEA <= 0.05                          0.058
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.055
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Teachs =~                                                             
##     Q17_1             1.000                               0.354    0.524
##     Q17_3             1.333    0.146    9.155    0.000    0.472    0.621
##     Q17_5             1.737    0.176    9.848    0.000    0.615    0.787
##   GOVa =~                                                               
##     Q23_5             1.000                               0.632    0.802
##     Q23_6             1.180    0.062   18.946    0.000    0.746    0.897
##     Q23_7             0.884    0.061   14.504    0.000    0.559    0.646
##   PROa =~                                                               
##     Q23_3             1.000                               0.248    0.346
##     Q23_8             2.762    0.384    7.202    0.000    0.686    0.704
##     Q23_9             3.375    0.451    7.491    0.000    0.838    0.903
##     Q23_10            2.899    0.393    7.370    0.000    0.720    0.785
##   COMa =~                                                               
##     Q23_1             1.000                               0.597    0.746
##     Q23_2             1.071    0.065   16.370    0.000    0.639    0.813
##     Q23_4             0.982    0.063   15.502    0.000    0.586    0.756
##   ASSMs =~                                                              
##     Q41_1             1.000                               0.556    0.683
##     Q41_2             1.175    0.142    8.300    0.000    0.654    0.853
##     Q41_4             0.493    0.063    7.804    0.000    0.274    0.414
##   TEFFs =~                                                              
##     Q44_1             1.000                               0.554    0.784
##     Q44_2             0.928    0.045   20.650    0.000    0.514    0.864
##     Q44_3             1.070    0.051   21.004    0.000    0.593    0.879
##     Q44_4             0.885    0.053   16.581    0.000    0.490    0.718
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Teachs ~~                                                             
##     GOVa              0.090    0.016    5.772    0.000    0.402    0.402
##     PROa              0.044    0.009    5.119    0.000    0.501    0.501
##     COMa              0.134    0.018    7.282    0.000    0.633    0.633
##     ASSMs             0.004    0.012    0.311    0.756    0.018    0.018
##     TEFFs             0.104    0.015    6.879    0.000    0.528    0.528
##   GOVa ~~                                                               
##     PROa              0.088    0.015    5.930    0.000    0.563    0.563
##     COMa              0.209    0.025    8.383    0.000    0.553    0.553
##     ASSMs            -0.062    0.020   -3.050    0.002   -0.175   -0.175
##     TEFFs             0.076    0.019    4.076    0.000    0.216    0.216
##   PROa ~~                                                               
##     COMa              0.076    0.013    5.670    0.000    0.510    0.510
##     ASSMs            -0.021    0.008   -2.572    0.010   -0.153   -0.153
##     TEFFs             0.029    0.008    3.575    0.000    0.210    0.210
##   COMa ~~                                                               
##     ASSMs            -0.020    0.019   -1.077    0.281   -0.061   -0.061
##     TEFFs             0.173    0.021    8.192    0.000    0.522    0.522
##   ASSMs ~~                                                              
##     TEFFs             0.031    0.017    1.873    0.061    0.102    0.102
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q17_1             0.331    0.024   13.947    0.000    0.331    0.725
##    .Q17_3             0.354    0.028   12.673    0.000    0.354    0.614
##    .Q17_5             0.232    0.029    7.909    0.000    0.232    0.380
##    .Q23_5             0.221    0.021   10.614    0.000    0.221    0.356
##    .Q23_6             0.134    0.022    5.981    0.000    0.134    0.194
##    .Q23_7             0.437    0.031   14.018    0.000    0.437    0.583
##    .Q23_3             0.453    0.029   15.436    0.000    0.453    0.880
##    .Q23_8             0.478    0.036   13.460    0.000    0.478    0.504
##    .Q23_9             0.159    0.026    6.183    0.000    0.159    0.184
##    .Q23_10            0.323    0.028   11.692    0.000    0.323    0.384
##    .Q23_1             0.283    0.024   12.008    0.000    0.283    0.443
##    .Q23_2             0.210    0.021    9.969    0.000    0.210    0.340
##    .Q23_4             0.258    0.022   11.778    0.000    0.258    0.429
##    .Q41_1             0.353    0.041    8.596    0.000    0.353    0.533
##    .Q41_2             0.160    0.048    3.298    0.001    0.160    0.272
##    .Q41_4             0.364    0.025   14.644    0.000    0.364    0.829
##    .Q44_1             0.192    0.015   12.940    0.000    0.192    0.385
##    .Q44_2             0.090    0.009   10.418    0.000    0.090    0.254
##    .Q44_3             0.104    0.011    9.659    0.000    0.104    0.227
##    .Q44_4             0.226    0.016   13.896    0.000    0.226    0.485
##     Teachs            0.125    0.023    5.499    0.000    1.000    1.000
##     GOVa              0.400    0.040    9.997    0.000    1.000    1.000
##     PROa              0.062    0.016    3.738    0.000    1.000    1.000
##     COMa              0.356    0.040    9.015    0.000    1.000    1.000
##     ASSMs             0.310    0.050    6.243    0.000    1.000    1.000
##     TEFFs             0.307    0.031   10.062    0.000    1.000    1.000
parameterEstimates(fitE, standardized=TRUE) %>% 
  filter(op == "=~") %>% 
  dplyr::select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all) %>% 
  kable(digits = 3, format="pandoc", caption="Factor Loadings")
Factor Loadings
Latent Factor Indicator B SE Z p-value Beta
Teachs Q17_1 1.000 0.000 NA NA 0.524
Teachs Q17_3 1.333 0.146 9.155 0 0.621
Teachs Q17_5 1.737 0.176 9.848 0 0.787
GOVa Q23_5 1.000 0.000 NA NA 0.802
GOVa Q23_6 1.180 0.062 18.946 0 0.897
GOVa Q23_7 0.884 0.061 14.504 0 0.646
PROa Q23_3 1.000 0.000 NA NA 0.346
PROa Q23_8 2.762 0.384 7.202 0 0.704
PROa Q23_9 3.375 0.451 7.491 0 0.903
PROa Q23_10 2.899 0.393 7.370 0 0.785
COMa Q23_1 1.000 0.000 NA NA 0.746
COMa Q23_2 1.071 0.065 16.370 0 0.813
COMa Q23_4 0.982 0.063 15.502 0 0.756
ASSMs Q41_1 1.000 0.000 NA NA 0.683
ASSMs Q41_2 1.175 0.142 8.300 0 0.853
ASSMs Q41_4 0.493 0.063 7.804 0 0.414
TEFFs Q44_1 1.000 0.000 NA NA 0.784
TEFFs Q44_2 0.928 0.045 20.650 0 0.864
TEFFs Q44_3 1.070 0.051 21.004 0 0.879
TEFFs Q44_4 0.885 0.053 16.581 0 0.718
CFAStand<-standardizedsolution(fitE, type = "std.all")
write.csv(CFAStand, "CFAStand.csv")
CFAStand
##       lhs op    rhs est.std    se      z pvalue ci.lower ci.upper
## 1  Teachs =~  Q17_1   0.524 0.040 13.146  0.000    0.446    0.602
## 2  Teachs =~  Q17_3   0.621 0.036 17.264  0.000    0.551    0.692
## 3  Teachs =~  Q17_5   0.787 0.031 25.048  0.000    0.726    0.849
## 4    GOVa =~  Q23_5   0.802 0.022 36.076  0.000    0.759    0.846
## 5    GOVa =~  Q23_6   0.897 0.019 47.486  0.000    0.860    0.935
## 6    GOVa =~  Q23_7   0.646 0.030 21.503  0.000    0.587    0.704
## 7    PROa =~  Q23_3   0.346 0.043  8.139  0.000    0.263    0.429
## 8    PROa =~  Q23_8   0.704 0.027 26.559  0.000    0.652    0.756
## 9    PROa =~  Q23_9   0.903 0.017 52.202  0.000    0.869    0.937
## 10   PROa =~ Q23_10   0.785 0.022 35.310  0.000    0.741    0.828
## 11   COMa =~  Q23_1   0.746 0.026 29.267  0.000    0.697    0.796
## 12   COMa =~  Q23_2   0.813 0.022 36.501  0.000    0.769    0.856
## 13   COMa =~  Q23_4   0.756 0.025 30.213  0.000    0.707    0.805
## 14  ASSMs =~  Q41_1   0.683 0.045 15.211  0.000    0.595    0.771
## 15  ASSMs =~  Q41_2   0.853 0.049 17.491  0.000    0.758    0.949
## 16  ASSMs =~  Q41_4   0.414 0.045  9.232  0.000    0.326    0.501
## 17  TEFFs =~  Q44_1   0.784 0.020 38.420  0.000    0.744    0.824
## 18  TEFFs =~  Q44_2   0.864 0.016 55.614  0.000    0.834    0.894
## 19  TEFFs =~  Q44_3   0.879 0.015 59.751  0.000    0.850    0.908
## 20  TEFFs =~  Q44_4   0.718 0.025 29.189  0.000    0.670    0.766
## 21  Q17_1 ~~  Q17_1   0.725 0.042 17.367  0.000    0.644    0.807
## 22  Q17_3 ~~  Q17_3   0.614 0.045 13.732  0.000    0.526    0.702
## 23  Q17_5 ~~  Q17_5   0.380 0.049  7.679  0.000    0.283    0.477
## 24  Q23_5 ~~  Q23_5   0.356 0.036  9.980  0.000    0.286    0.426
## 25  Q23_6 ~~  Q23_6   0.194 0.034  5.733  0.000    0.128    0.261
## 26  Q23_7 ~~  Q23_7   0.583 0.039 15.051  0.000    0.507    0.659
## 27  Q23_3 ~~  Q23_3   0.880 0.029 29.906  0.000    0.823    0.938
## 28  Q23_8 ~~  Q23_8   0.504 0.037 13.501  0.000    0.431    0.577
## 29  Q23_9 ~~  Q23_9   0.184 0.031  5.902  0.000    0.123    0.246
## 30 Q23_10 ~~ Q23_10   0.384 0.035 11.006  0.000    0.316    0.452
## 31  Q23_1 ~~  Q23_1   0.443 0.038 11.626  0.000    0.368    0.517
## 32  Q23_2 ~~  Q23_2   0.340 0.036  9.382  0.000    0.269    0.410
## 33  Q23_4 ~~  Q23_4   0.429 0.038 11.333  0.000    0.355    0.503
## 34  Q41_1 ~~  Q41_1   0.533 0.061  8.682  0.000    0.413    0.653
## 35  Q41_2 ~~  Q41_2   0.272 0.083  3.265  0.001    0.109    0.435
## 36  Q41_4 ~~  Q41_4   0.829 0.037 22.359  0.000    0.756    0.902
## 37  Q44_1 ~~  Q44_1   0.385 0.032 12.037  0.000    0.323    0.448
## 38  Q44_2 ~~  Q44_2   0.254 0.027  9.445  0.000    0.201    0.306
## 39  Q44_3 ~~  Q44_3   0.227 0.026  8.796  0.000    0.177    0.278
## 40  Q44_4 ~~  Q44_4   0.485 0.035 13.734  0.000    0.416    0.554
## 41 Teachs ~~ Teachs   1.000 0.000     NA     NA    1.000    1.000
## 42   GOVa ~~   GOVa   1.000 0.000     NA     NA    1.000    1.000
## 43   PROa ~~   PROa   1.000 0.000     NA     NA    1.000    1.000
## 44   COMa ~~   COMa   1.000 0.000     NA     NA    1.000    1.000
## 45  ASSMs ~~  ASSMs   1.000 0.000     NA     NA    1.000    1.000
## 46  TEFFs ~~  TEFFs   1.000 0.000     NA     NA    1.000    1.000
## 47 Teachs ~~   GOVa   0.402 0.050  8.021  0.000    0.303    0.500
## 48 Teachs ~~   PROa   0.501 0.046 10.826  0.000    0.410    0.591
## 49 Teachs ~~   COMa   0.633 0.042 14.919  0.000    0.550    0.716
## 50 Teachs ~~  ASSMs   0.018 0.059  0.311  0.756   -0.098    0.135
## 51 Teachs ~~  TEFFs   0.528 0.044 11.922  0.000    0.441    0.615
## 52   GOVa ~~   PROa   0.563 0.038 14.865  0.000    0.488    0.637
## 53   GOVa ~~   COMa   0.553 0.040 13.785  0.000    0.474    0.632
## 54   GOVa ~~  ASSMs  -0.175 0.053 -3.291  0.001   -0.279   -0.071
## 55   GOVa ~~  TEFFs   0.216 0.049  4.419  0.000    0.120    0.311
## 56   PROa ~~   COMa   0.510 0.042 12.217  0.000    0.429    0.592
## 57   PROa ~~  ASSMs  -0.153 0.053 -2.879  0.004   -0.257   -0.049
## 58   PROa ~~  TEFFs   0.210 0.049  4.306  0.000    0.114    0.305
## 59   COMa ~~  ASSMs  -0.061 0.056 -1.087  0.277   -0.170    0.049
## 60   COMa ~~  TEFFs   0.522 0.040 12.913  0.000    0.443    0.601
## 61  ASSMs ~~  TEFFs   0.102 0.053  1.925  0.054   -0.002    0.206
residuals(fitE, type = "cor")
## $type
## [1] "cor.bollen"
## 
## $cov
##        Q17_1  Q17_3  Q17_5  Q23_5  Q23_6  Q23_7  Q23_3  Q23_8  Q23_9  Q23_10
## Q17_1   0.000                                                               
## Q17_3   0.063  0.000                                                        
## Q17_5  -0.032  0.001  0.000                                                 
## Q23_5   0.047  0.020 -0.036  0.000                                          
## Q23_6   0.025  0.068 -0.056  0.008  0.000                                   
## Q23_7   0.038  0.067  0.032 -0.038  0.003  0.000                            
## Q23_3   0.092  0.112  0.102 -0.085 -0.044  0.039  0.000                     
## Q23_8  -0.011  0.040 -0.026 -0.125 -0.052  0.030  0.147  0.000              
## Q23_9  -0.022 -0.004 -0.017 -0.057 -0.032  0.069 -0.024  0.023  0.000       
## Q23_10  0.005  0.044  0.011  0.121  0.100  0.134 -0.070 -0.060  0.003  0.000
## Q23_1   0.033 -0.023  0.053 -0.022 -0.092 -0.028  0.029 -0.079 -0.085  0.025
## Q23_2   0.011 -0.084 -0.048  0.013 -0.023  0.020  0.058 -0.028 -0.031  0.052
## Q23_4   0.060  0.013  0.037  0.133  0.035  0.089  0.120  0.011  0.039  0.132
## Q41_1   0.027 -0.044 -0.047 -0.024 -0.030 -0.007 -0.094 -0.015 -0.029 -0.007
## Q41_2   0.074  0.016  0.013  0.012  0.040 -0.004 -0.043 -0.014  0.025  0.063
## Q41_4  -0.011 -0.038 -0.117 -0.138 -0.083 -0.103 -0.056 -0.028 -0.104 -0.103
## Q44_1  -0.055 -0.058  0.088 -0.006 -0.055 -0.010 -0.063 -0.105 -0.098  0.033
## Q44_2  -0.029 -0.090  0.024  0.009 -0.037  0.052  0.025  0.007 -0.021  0.067
## Q44_3  -0.033 -0.063  0.021  0.003  0.004  0.038  0.000 -0.001 -0.021  0.057
## Q44_4  -0.028  0.005  0.075  0.028  0.057  0.087  0.070  0.054  0.063  0.117
##        Q23_1  Q23_2  Q23_4  Q41_1  Q41_2  Q41_4  Q44_1  Q44_2  Q44_3  Q44_4 
## Q17_1                                                                       
## Q17_3                                                                       
## Q17_5                                                                       
## Q23_5                                                                       
## Q23_6                                                                       
## Q23_7                                                                       
## Q23_3                                                                       
## Q23_8                                                                       
## Q23_9                                                                       
## Q23_10                                                                      
## Q23_1   0.000                                                               
## Q23_2   0.038  0.000                                                        
## Q23_4  -0.052  0.000  0.000                                                 
## Q41_1   0.009 -0.035 -0.085  0.000                                          
## Q41_2   0.079  0.027 -0.021  0.002  0.000                                   
## Q41_4  -0.020 -0.083 -0.121 -0.005 -0.004  0.000                            
## Q44_1   0.092 -0.051 -0.009 -0.017  0.094  0.002  0.000                     
## Q44_2   0.069 -0.066 -0.015 -0.077  0.022 -0.040  0.011  0.000              
## Q44_3   0.066 -0.043 -0.024 -0.094  0.033 -0.059 -0.013  0.005  0.000       
## Q44_4   0.047  0.048  0.012 -0.056 -0.007 -0.095 -0.012 -0.017  0.014  0.000
semPaths(fitE, "par", edge.label.cex = 1.2, fade = FALSE, exoCov = FALSE)

supportSEM<- 
  
  '
TI=~ Q17_1 + Q17_3 + Q17_5 
GS=~ Q23_5 + Q23_6 + Q23_7
PS=~ Q23_3 + Q23_8 + Q23_9 + Q23_10
CS=~ Q23_1 + Q23_2 + Q23_4
AS=~ Q41_1 + Q41_2 +  Q41_4
TE=~ Q44_1 + Q44_2 + Q44_3 + Q44_4
LV=~  Q15_4

LV ~ TI
LV ~ GS
LV ~ PS
LV ~ CS
LV ~ AS
LV ~ TE



  
 '

fit<- sem(supportSEM, data=teacher2, ordered = "LV")



summary(fit, fit.measures=TRUE, standardized = TRUE, rsquare = T)
## lavaan 0.6-12 ended normally after 113 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                        83
## 
##                                                   Used       Total
##   Number of observations                           461         679
## 
## Model Test User Model:
##                                               Standard      Robust
##   Test Statistic                               209.052     345.562
##   Degrees of freedom                               169         169
##   P-value (Chi-square)                           0.020       0.000
##   Scaling correction factor                                  0.760
##   Shift parameter                                           70.449
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                              6324.372    2296.079
##   Degrees of freedom                               210         210
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.931
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.993       0.915
##   Tucker-Lewis Index (TLI)                       0.992       0.895
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.023       0.048
##   90 Percent confidence interval - lower         0.010       0.040
##   90 Percent confidence interval - upper         0.032       0.055
##   P-value RMSEA <= 0.05                          1.000       0.696
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.046       0.046
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   TI =~                                                                 
##     Q17_1             1.000                               0.336    0.523
##     Q17_3             1.415    0.169    8.357    0.000    0.475    0.633
##     Q17_5             1.768    0.208    8.493    0.000    0.593    0.787
##   GS =~                                                                 
##     Q23_5             1.000                               0.618    0.784
##     Q23_6             1.145    0.064   17.990    0.000    0.708    0.845
##     Q23_7             0.986    0.075   13.111    0.000    0.610    0.705
##   PS =~                                                                 
##     Q23_3             1.000                               0.274    0.388
##     Q23_8             2.282    0.326    6.992    0.000    0.625    0.645
##     Q23_9             2.889    0.431    6.708    0.000    0.791    0.851
##     Q23_10            2.868    0.438    6.554    0.000    0.785    0.851
##   CS =~                                                                 
##     Q23_1             1.000                               0.562    0.703
##     Q23_2             1.033    0.072   14.274    0.000    0.580    0.754
##     Q23_4             1.132    0.091   12.382    0.000    0.636    0.826
##   AS =~                                                                 
##     Q41_1             1.000                               0.550    0.681
##     Q41_2             1.001    0.130    7.706    0.000    0.551    0.727
##     Q41_4             0.612    0.109    5.614    0.000    0.337    0.509
##   TE =~                                                                 
##     Q44_1             1.000                               0.530    0.748
##     Q44_2             0.932    0.075   12.397    0.000    0.494    0.836
##     Q44_3             1.098    0.083   13.171    0.000    0.582    0.863
##     Q44_4             1.017    0.085   11.938    0.000    0.539    0.787
##   LV =~                                                                 
##     Q15_4             1.000                               1.091    1.000
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   LV ~                                                                  
##     TI               -1.450    0.336   -4.311    0.000   -0.446   -0.446
##     GS               -0.097    0.126   -0.771    0.441   -0.055   -0.055
##     PS               -0.627    0.312   -2.008    0.045   -0.157   -0.157
##     CS                0.212    0.166    1.279    0.201    0.109    0.109
##     AS                0.416    0.121    3.434    0.001    0.210    0.210
##     TE                0.078    0.147    0.534    0.593    0.038    0.038
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   TI ~~                                                                 
##     GS                0.091    0.016    5.719    0.000    0.440    0.440
##     PS                0.048    0.011    4.466    0.000    0.520    0.520
##     CS                0.116    0.018    6.339    0.000    0.617    0.617
##     AS               -0.001    0.014   -0.053    0.958   -0.004   -0.004
##     TE                0.088    0.019    4.742    0.000    0.494    0.494
##   GS ~~                                                                 
##     PS                0.101    0.019    5.282    0.000    0.598    0.598
##     CS                0.196    0.027    7.323    0.000    0.564    0.564
##     AS               -0.089    0.022   -4.118    0.000   -0.261   -0.261
##     TE                0.076    0.020    3.833    0.000    0.231    0.231
##   PS ~~                                                                 
##     CS                0.085    0.017    4.896    0.000    0.553    0.553
##     AS               -0.032    0.011   -2.847    0.004   -0.213   -0.213
##     TE                0.034    0.010    3.400    0.001    0.235    0.235
##   CS ~~                                                                 
##     AS               -0.036    0.020   -1.793    0.073   -0.118   -0.118
##     TE                0.154    0.026    6.012    0.000    0.518    0.518
##   AS ~~                                                                 
##     TE                0.014    0.018    0.743    0.457    0.047    0.047
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q17_1             3.499    0.030  117.124    0.000    3.499    5.455
##    .Q17_3             3.002    0.035   85.905    0.000    3.002    4.001
##    .Q17_5             2.879    0.035   82.019    0.000    2.879    3.820
##    .Q23_5             1.751    0.037   47.641    0.000    1.751    2.219
##    .Q23_6             2.052    0.039   52.600    0.000    2.052    2.450
##    .Q23_7             2.377    0.040   59.000    0.000    2.377    2.748
##    .Q23_3             3.063    0.033   93.171    0.000    3.063    4.339
##    .Q23_8             2.570    0.045   57.020    0.000    2.570    2.656
##    .Q23_9             2.126    0.043   49.150    0.000    2.126    2.289
##    .Q23_10            2.089    0.043   48.626    0.000    2.089    2.265
##    .Q23_1             2.777    0.037   74.572    0.000    2.777    3.473
##    .Q23_2             2.534    0.036   70.649    0.000    2.534    3.290
##    .Q23_4             2.401    0.036   66.956    0.000    2.401    3.118
##    .Q41_1             3.343    0.038   88.896    0.000    3.343    4.140
##    .Q41_2             3.113    0.035   88.200    0.000    3.113    4.108
##    .Q41_4             3.215    0.031  104.227    0.000    3.215    4.854
##    .Q44_1             2.928    0.033   88.797    0.000    2.928    4.136
##    .Q44_2             3.098    0.028  112.557    0.000    3.098    5.242
##    .Q44_3             2.993    0.031   95.357    0.000    2.993    4.441
##    .Q44_4             2.876    0.032   90.135    0.000    2.876    4.198
##    .Q15_4             2.883    0.051   56.727    0.000    2.883    2.642
##     TI                0.000                               0.000    0.000
##     GS                0.000                               0.000    0.000
##     PS                0.000                               0.000    0.000
##     CS                0.000                               0.000    0.000
##     AS                0.000                               0.000    0.000
##     TE                0.000                               0.000    0.000
##    .LV                0.000                               0.000    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q17_1             0.299    0.030   10.086    0.000    0.299    0.726
##    .Q17_3             0.337    0.032   10.645    0.000    0.337    0.599
##    .Q17_5             0.216    0.034    6.368    0.000    0.216    0.380
##    .Q23_5             0.240    0.026    9.209    0.000    0.240    0.386
##    .Q23_6             0.200    0.033    6.005    0.000    0.200    0.286
##    .Q23_7             0.376    0.040    9.332    0.000    0.376    0.503
##    .Q23_3             0.423    0.036   11.698    0.000    0.423    0.850
##    .Q23_8             0.547    0.048   11.293    0.000    0.547    0.584
##    .Q23_9             0.237    0.038    6.200    0.000    0.237    0.275
##    .Q23_10            0.234    0.040    5.910    0.000    0.234    0.276
##    .Q23_1             0.324    0.031   10.530    0.000    0.324    0.506
##    .Q23_2             0.256    0.027    9.595    0.000    0.256    0.432
##    .Q23_4             0.188    0.028    6.663    0.000    0.188    0.318
##    .Q41_1             0.349    0.072    4.822    0.000    0.349    0.536
##    .Q41_2             0.271    0.047    5.764    0.000    0.271    0.472
##    .Q41_4             0.325    0.035    9.176    0.000    0.325    0.741
##    .Q44_1             0.221    0.026    8.355    0.000    0.221    0.440
##    .Q44_2             0.105    0.018    5.840    0.000    0.105    0.301
##    .Q44_3             0.116    0.023    5.139    0.000    0.116    0.255
##    .Q44_4             0.179    0.027    6.562    0.000    0.179    0.381
##    .Q15_4             0.000                               0.000    0.000
##     TI                0.113    0.025    4.572    0.000    1.000    1.000
##     GS                0.382    0.043    8.890    0.000    1.000    1.000
##     PS                0.075    0.022    3.424    0.001    1.000    1.000
##     CS                0.316    0.043    7.273    0.000    1.000    1.000
##     AS                0.303    0.055    5.536    0.000    1.000    1.000
##     TE                0.281    0.041    6.845    0.000    1.000    1.000
##    .LV                0.830    0.060   13.889    0.000    0.697    0.697
## 
## R-Square:
##                    Estimate
##     Q17_1             0.274
##     Q17_3             0.401
##     Q17_5             0.620
##     Q23_5             0.614
##     Q23_6             0.714
##     Q23_7             0.497
##     Q23_3             0.150
##     Q23_8             0.416
##     Q23_9             0.725
##     Q23_10            0.724
##     Q23_1             0.494
##     Q23_2             0.568
##     Q23_4             0.682
##     Q41_1             0.464
##     Q41_2             0.528
##     Q41_4             0.259
##     Q44_1             0.560
##     Q44_2             0.699
##     Q44_3             0.745
##     Q44_4             0.619
##     Q15_4             1.000
##     LV                0.303
semfit<- standardizedsolution(fit, type = "std.all")

write.csv(semfit, "SEMModel.csv")

semfit
##       lhs op    rhs est.std    se      z pvalue ci.lower ci.upper
## 1      TI =~  Q17_1   0.523 0.050 10.458  0.000    0.425    0.621
## 2      TI =~  Q17_3   0.633 0.038 16.641  0.000    0.558    0.708
## 3      TI =~  Q17_5   0.787 0.039 20.411  0.000    0.712    0.863
## 4      GS =~  Q23_5   0.784 0.029 27.053  0.000    0.727    0.841
## 5      GS =~  Q23_6   0.845 0.029 29.359  0.000    0.789    0.902
## 6      GS =~  Q23_7   0.705 0.037 19.030  0.000    0.633    0.778
## 7      PS =~  Q23_3   0.388 0.053  7.308  0.000    0.284    0.492
## 8      PS =~  Q23_8   0.645 0.039 16.750  0.000    0.570    0.721
## 9      PS =~  Q23_9   0.851 0.026 32.583  0.000    0.800    0.903
## 10     PS =~ Q23_10   0.851 0.028 30.289  0.000    0.796    0.906
## 11     CS =~  Q23_1   0.703 0.036 19.794  0.000    0.633    0.772
## 12     CS =~  Q23_2   0.754 0.030 24.734  0.000    0.694    0.813
## 13     CS =~  Q23_4   0.826 0.030 27.934  0.000    0.768    0.884
## 14     AS =~  Q41_1   0.681 0.066 10.332  0.000    0.552    0.811
## 15     AS =~  Q41_2   0.727 0.056 12.890  0.000    0.616    0.837
## 16     AS =~  Q41_4   0.509 0.066  7.671  0.000    0.379    0.638
## 17     TE =~  Q44_1   0.748 0.037 20.082  0.000    0.675    0.821
## 18     TE =~  Q44_2   0.836 0.032 26.135  0.000    0.773    0.899
## 19     TE =~  Q44_3   0.863 0.030 28.891  0.000    0.805    0.922
## 20     TE =~  Q44_4   0.787 0.037 20.980  0.000    0.713    0.860
## 21     LV =~  Q15_4   1.000 0.000     NA     NA    1.000    1.000
## 22     LV  ~     TI  -0.446 0.085 -5.231  0.000   -0.613   -0.279
## 23     LV  ~     GS  -0.055 0.072 -0.771  0.441   -0.196    0.085
## 24     LV  ~     PS  -0.157 0.076 -2.080  0.038   -0.306   -0.009
## 25     LV  ~     CS   0.109 0.085  1.290  0.197   -0.057    0.275
## 26     LV  ~     AS   0.210 0.058  3.621  0.000    0.096    0.323
## 27     LV  ~     TE   0.038 0.071  0.534  0.594   -0.102    0.178
## 28  Q17_1 ~~  Q17_1   0.726 0.052 13.872  0.000    0.624    0.829
## 29  Q17_3 ~~  Q17_3   0.599 0.048 12.446  0.000    0.505    0.694
## 30  Q17_5 ~~  Q17_5   0.380 0.061  6.261  0.000    0.261    0.499
## 31  Q23_5 ~~  Q23_5   0.386 0.045  8.487  0.000    0.297    0.475
## 32  Q23_6 ~~  Q23_6   0.286 0.049  5.872  0.000    0.190    0.381
## 33  Q23_7 ~~  Q23_7   0.503 0.052  9.622  0.000    0.400    0.605
## 34  Q23_3 ~~  Q23_3   0.850 0.041 20.642  0.000    0.769    0.930
## 35  Q23_8 ~~  Q23_8   0.584 0.050 11.741  0.000    0.486    0.681
## 36  Q23_9 ~~  Q23_9   0.275 0.045  6.178  0.000    0.188    0.362
## 37 Q23_10 ~~ Q23_10   0.276 0.048  5.761  0.000    0.182    0.369
## 38  Q23_1 ~~  Q23_1   0.506 0.050 10.146  0.000    0.408    0.604
## 39  Q23_2 ~~  Q23_2   0.432 0.046  9.412  0.000    0.342    0.522
## 40  Q23_4 ~~  Q23_4   0.318 0.049  6.498  0.000    0.222    0.413
## 41  Q41_1 ~~  Q41_1   0.536 0.090  5.964  0.000    0.360    0.712
## 42  Q41_2 ~~  Q41_2   0.472 0.082  5.758  0.000    0.311    0.632
## 43  Q41_4 ~~  Q41_4   0.741 0.067 10.998  0.000    0.609    0.874
## 44  Q44_1 ~~  Q44_1   0.440 0.056  7.891  0.000    0.331    0.549
## 45  Q44_2 ~~  Q44_2   0.301 0.053  5.626  0.000    0.196    0.406
## 46  Q44_3 ~~  Q44_3   0.255 0.052  4.933  0.000    0.153    0.356
## 47  Q44_4 ~~  Q44_4   0.381 0.059  6.462  0.000    0.266    0.497
## 48  Q15_4 ~~  Q15_4   0.000 0.000     NA     NA    0.000    0.000
## 49     TI ~~     TI   1.000 0.000     NA     NA    1.000    1.000
## 50     GS ~~     GS   1.000 0.000     NA     NA    1.000    1.000
## 51     PS ~~     PS   1.000 0.000     NA     NA    1.000    1.000
## 52     CS ~~     CS   1.000 0.000     NA     NA    1.000    1.000
## 53     AS ~~     AS   1.000 0.000     NA     NA    1.000    1.000
## 54     TE ~~     TE   1.000 0.000     NA     NA    1.000    1.000
## 55     LV ~~     LV   0.697 0.046 15.206  0.000    0.607    0.787
## 56     TI ~~     GS   0.440 0.052  8.550  0.000    0.339    0.541
## 57     TI ~~     PS   0.520 0.053  9.805  0.000    0.416    0.624
## 58     TI ~~     CS   0.617 0.048 12.846  0.000    0.523    0.711
## 59     TI ~~     AS  -0.004 0.075 -0.053  0.958   -0.150    0.143
## 60     TI ~~     TE   0.494 0.057  8.733  0.000    0.383    0.605
## 61     GS ~~     PS   0.598 0.046 13.037  0.000    0.508    0.688
## 62     GS ~~     CS   0.564 0.048 11.667  0.000    0.469    0.659
## 63     GS ~~     AS  -0.261 0.060 -4.381  0.000   -0.378   -0.144
## 64     GS ~~     TE   0.231 0.053  4.362  0.000    0.127    0.335
## 65     PS ~~     CS   0.553 0.046 11.912  0.000    0.462    0.644
## 66     PS ~~     AS  -0.213 0.063 -3.395  0.001   -0.336   -0.090
## 67     PS ~~     TE   0.235 0.053  4.436  0.000    0.131    0.339
## 68     CS ~~     AS  -0.118 0.064 -1.825  0.068   -0.244    0.009
## 69     CS ~~     TE   0.518 0.048 10.858  0.000    0.424    0.611
## 70     AS ~~     TE   0.047 0.063  0.746  0.455   -0.077    0.171
## 71  Q17_1 ~1          5.455 0.252 21.687  0.000    4.962    5.948
## 72  Q17_3 ~1          4.001 0.157 25.446  0.000    3.693    4.309
## 73  Q17_5 ~1          3.820 0.139 27.554  0.000    3.548    4.092
## 74  Q23_5 ~1          2.219 0.057 39.260  0.000    2.108    2.330
## 75  Q23_6 ~1          2.450 0.068 35.922  0.000    2.316    2.583
## 76  Q23_7 ~1          2.748 0.089 30.835  0.000    2.573    2.923
## 77  Q23_3 ~1          4.339 0.187 23.157  0.000    3.972    4.707
## 78  Q23_8 ~1          2.656 0.089 29.972  0.000    2.482    2.829
## 79  Q23_9 ~1          2.289 0.062 37.022  0.000    2.168    2.410
## 80 Q23_10 ~1          2.265 0.060 37.656  0.000    2.147    2.383
## 81  Q23_1 ~1          3.473 0.130 26.615  0.000    3.217    3.729
## 82  Q23_2 ~1          3.290 0.122 26.866  0.000    3.050    3.531
## 83  Q23_4 ~1          3.118 0.106 29.452  0.000    2.911    3.326
## 84  Q41_1 ~1          4.140 0.192 21.586  0.000    3.764    4.516
## 85  Q41_2 ~1          4.108 0.138 29.866  0.000    3.838    4.377
## 86  Q41_4 ~1          4.854 0.172 28.271  0.000    4.518    5.191
## 87  Q44_1 ~1          4.136 0.177 23.385  0.000    3.789    4.482
## 88  Q44_2 ~1          5.242 0.207 25.327  0.000    4.837    5.648
## 89  Q44_3 ~1          4.441 0.170 26.114  0.000    4.108    4.775
## 90  Q44_4 ~1          4.198 0.176 23.862  0.000    3.853    4.543
## 91  Q15_4 ~1          2.642 0.096 27.621  0.000    2.455    2.830
## 92     TI ~1          0.000 0.000     NA     NA    0.000    0.000
## 93     GS ~1          0.000 0.000     NA     NA    0.000    0.000
## 94     PS ~1          0.000 0.000     NA     NA    0.000    0.000
## 95     CS ~1          0.000 0.000     NA     NA    0.000    0.000
## 96     AS ~1          0.000 0.000     NA     NA    0.000    0.000
## 97     TE ~1          0.000 0.000     NA     NA    0.000    0.000
## 98     LV ~1          0.000 0.000     NA     NA    0.000    0.000
semPaths(fit,  whatLabels = "std.all", structural = FALSE, edge.label.cex = .8, node.label.cex = .8, 
        label.prop=0.9, edge.label.color = "black", rotation = 4, 
        equalizeManifests = TRUE, optimizeLatRes = TRUE, node.width = 1.5, 
        edge.width = 0.5, shapeMan = "rectangle", shapeLat = "ellipse", 
        shapeInt = "triangle", sizeMan = 4, sizeInt = 2, sizeLat = 4, 
        curve=2, unCol = "#070b8c", title = FALSE, intercepts = FALSE, residuals = FALSE, exoCov = FALSE)

semPaths(fit,
        whatLabels = "std.all", structural = TRUE, edge.label.cex = 1, node.label.cex = 1.5, 
        label.prop=0.9, edge.label.color = "black", rotation = 2, 
        equalizeManifests = FALSE, optimizeLatRes = TRUE, node.width = 1.5, 
        edge.width = 0.5, shapeMan = "rectangle", shapeLat = "ellipse", 
        shapeInt = "triangle", sizeMan = 4, sizeInt = 2, sizeLat = 4, 
        curve=2, unCol = "#070b8c", title = FALSE, intercepts = FALSE, residuals = FALSE, exoCov = FALSE)