library(lavaan)
## This is lavaan 0.5-18
## lavaan is BETA software! Please report any bugs.
library(semPlot)
library(dplyr)
## 
## Attaching package: 'dplyr'
## 
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(GPArotation)
library(psych)
library(car)
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:psych':
## 
##     logit
library(ggplot2)
## 
## Attaching package: 'ggplot2'
## 
## The following object is masked from 'package:psych':
## 
##     %+%
library(GGally)
## 
## Attaching package: 'GGally'
## 
## The following object is masked from 'package:dplyr':
## 
##     nasa

loadthedata

data <- read.csv("~/Psychometric_study_data/allsurveysT1.csv")
data<-tbl_df(data)
LET<-select(data, LET_1,    LET_2,  LET_3,  LET_4,  LET_5,  LET_6)
LET$LET_1  <-  6- LET$LET_1
LET$LET_3  <-  6- LET$LET_3
LET$LET_5  <-  6- LET$LET_5

LET<-tbl_df(LET)
LET
## Source: local data frame [757 x 6]
## 
##    LET_1 LET_2 LET_3 LET_4 LET_5 LET_6
## 1      4     4     4     5     5     5
## 2      3     3     4     4     4     5
## 3      3     4     3     4     4     5
## 4      1     4     4     4     4     4
## 5      3     2     3     4     2     4
## 6      5     5     5     5     5     4
## 7      3     4     2     3     3     5
## 8      3     4     3     4     4     5
## 9      5     4     5     5     5     5
## 10     3     3     5     5     5     5
## ..   ...   ...   ...   ...   ...   ...

Create the Models

As only one factor

one.factor = 'LET =~ LET_1 +  LET_2  + LET_3  + LET_4 + LET_5 + LET_6
' 

Two Factor, Positive and Nagative Model

first.model= ' Negative =~ LET_1 +  LET_3  + LET_5   
             Positive =~   LET_2 + LET_4 + LET_6
' 

Second order models

second.model = ' Negative =~ LET_1 +  LET_3  + LET_5   
              Positive =~   LET_2 + LET_4 + LET_6
              LET =~ NA*Positive + Negative
'

alternative.model  = 'Negative =~ LET_1 +  LET_3  + LET_5   
              Positive =~ LET_2 + LET_4 + LET_6
              LET =~ NA*Positive + Negative
              LET~~1*LET
'

Bifactor Models (similar to Models 6, 7 & 8 in Marsh, Scalas & Nagengast, 2010)

bifactor.model = 'Negative =~ LET_1 +  LET_3  + LET_5   
              Positive =~   LET_2 + LET_4 + LET_6
              Life Satisfaction =~ LET_1 +  LET_2  + LET_3 + LET_4 + LET_5 + LET_6
'

Bifactor only with Negative questions protioned out (like model 7 in Marsh, Scalas & Nagengast, 2010)

bifactor.negative.model = 'Negative =~ LET_1 +  LET_3  + LET_5   
                        LET =~ LET_1 +  LET_2  + LET_3 + LET_4 + LET_5 + LET_6
'

Bifactor only with Positive questions protioned out (like model 8 in Marsh, Scalas & Nagengast, 2010)

bifactor.positive.model = 'Positive =~   LET_2 + LET_4 + LET_6
                        LET =~ LET_1 +  LET_2  + LET_3 + LET_4 + LET_5 + LET_6
'

Alternative method of writing bifactor model

bifactor.model1 = 'LET =~ LET_1 +  LET_2  + LET_3 + LET_4 + LET_5 + LET_6
                Negative =~ LET_1 +  LET_3  + LET_5   
                Positive =~   LET_2 + LET_4 + LET_6
                LET ~~ 0*Negative
                LET ~~ 0*Positive
                Negative~~0*Positive
'

Running the models

one.fit=cfa(one.factor, data=LET, std.lv = T)
two.fit=cfa(first.model, data=LET, std.lv = T)
second.fit=cfa(second.model, data=LET, std.lv = T)
## Warning in lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, : lavaan WARNING: could not compute standard errors!
##   lavaan NOTE: this may be a symptom that the model is not identified.
alt.fit=cfa(alternative.model, data=LET, std.lv = T)
## Warning in lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, : lavaan WARNING: could not compute standard errors!
##   lavaan NOTE: this may be a symptom that the model is not identified.
bifactor.fit=cfa(bifactor.model, data=LET, orthogonal = TRUE, std.lv = T)
## Warning in lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, : lavaan WARNING: could not compute standard errors!
##   lavaan NOTE: this may be a symptom that the model is not identified.
bifactor.fit1=cfa(bifactor.model1, data=LET, orthogonal = TRUE, std.lv = T)
## Warning in lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, : lavaan WARNING: could not compute standard errors!
##   lavaan NOTE: this may be a symptom that the model is not identified.
bifactor.negative.fit=cfa(bifactor.negative.model, data=LET, orthogonal = TRUE, std.lv = T)
bifactor.positive.fit=cfa(bifactor.positive.model, data=LET, orthogonal = TRUE, std.lv = T)

Create pictures of models

#One Factor
semPaths(one.fit, whatLabels = "std", layout = "tree", title=T)

#Two Factors Positive and Nagative
semPaths(two.fit, whatLabels = "std", layout = "tree")

#Second order factors
semPaths(second.fit, whatLabels = "std", layout = "tree")

semPaths(alt.fit, whatLabels = "std", layout = "tree")

#Bifactor Models (similar to Models 6, 7 & 8 in Marsh, Scalas & Nagengast, 2010)
semPaths(bifactor.fit, whatLabels = "std", layout = "tree")

semPaths(bifactor.fit1, whatLabels = "std", layout = "tree")

#Bifactor only with Negative questions protioned out (like model 7 in Marsh, Scalas & Nagengast, 2010)
semPaths(bifactor.negative.fit, whatLabels = "std", layout = "tree")

#Bifactor only with Negative questions protioned out (like model 7 in Marsh, Scalas & Nagengast, 2010)
semPaths(bifactor.positive.fit, whatLabels = "std", layout = "tree")

Summaries

summary(one.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after  23 iterations
## 
##                                                   Used       Total
##   Number of observations                           474         757
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              294.824
##   Degrees of freedom                                 9
##   P-value (Chi-square)                           0.000
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   LET =~
##     LET_1             0.985    0.067   14.669    0.000    0.985    0.638
##     LET_2            -0.095    0.063   -1.513    0.130   -0.095   -0.073
##     LET_3             1.397    0.060   23.205    0.000    1.397    0.927
##     LET_4            -0.112    0.056   -2.002    0.045   -0.112   -0.097
##     LET_5             1.233    0.063   19.461    0.000    1.233    0.808
##     LET_6             0.410    0.051    7.995    0.000    0.410    0.374
## 
## Variances:
##     LET_1             1.410    0.102                      1.410    0.593
##     LET_2             1.669    0.109                      1.669    0.995
##     LET_3             0.321    0.086                      0.321    0.141
##     LET_4             1.323    0.086                      1.323    0.991
##     LET_5             0.808    0.084                      0.808    0.347
##     LET_6             1.037    0.069                      1.037    0.860
##     LET               1.000                               1.000    1.000
## 
## R-Square:
## 
##     LET_1             0.407
##     LET_2             0.005
##     LET_3             0.859
##     LET_4             0.009
##     LET_5             0.653
##     LET_6             0.140
summary(two.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after  24 iterations
## 
##                                                   Used       Total
##   Number of observations                           474         757
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              163.816
##   Degrees of freedom                                 8
##   P-value (Chi-square)                           0.000
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   Negative =~
##     LET_1             0.987    0.068   14.609    0.000    0.987    0.639
##     LET_3             1.396    0.062   22.456    0.000    1.396    0.926
##     LET_5             1.231    0.065   19.006    0.000    1.231    0.806
##   Positive =~
##     LET_2             0.795    0.083    9.533    0.000    0.795    0.614
##     LET_4             0.967    0.089   10.903    0.000    0.967    0.837
##     LET_6             0.424    0.059    7.140    0.000    0.424    0.386
## 
## Covariances:
##   Negative ~~
##     Positive         -0.069    0.056   -1.245    0.213   -0.069   -0.069
## 
## Variances:
##     LET_1             1.407    0.103                      1.407    0.591
##     LET_3             0.322    0.096                      0.322    0.142
##     LET_5             0.814    0.090                      0.814    0.350
##     LET_2             1.046    0.122                      1.046    0.623
##     LET_4             0.400    0.153                      0.400    0.300
##     LET_6             1.025    0.073                      1.025    0.851
##     Negative          1.000                               1.000    1.000
##     Positive          1.000                               1.000    1.000
## 
## R-Square:
## 
##     LET_1             0.409
##     LET_3             0.858
##     LET_5             0.650
##     LET_2             0.377
##     LET_4             0.700
##     LET_6             0.149
summary(second.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after  25 iterations
## 
##                                                   Used       Total
##   Number of observations                           474         757
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              163.816
##   Degrees of freedom                                 7
##   P-value (Chi-square)                           0.000
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   Negative =~
##     LET_1             0.786                               0.987    0.639
##     LET_3             1.112                               1.396    0.926
##     LET_5             0.980                               1.231    0.806
##   Positive =~
##     LET_2             0.790                               0.795    0.614
##     LET_4             0.961                               0.967    0.837
##     LET_6             0.421                               0.424    0.386
##   LET =~
##     Positive         -0.115                              -0.115   -0.115
##     Negative          0.759                               0.605    0.605
## 
## Variances:
##     LET_1             1.407                               1.407    0.591
##     LET_3             0.322                               0.322    0.142
##     LET_5             0.814                               0.814    0.350
##     LET_2             1.046                               1.046    0.623
##     LET_4             0.400                               0.400    0.300
##     LET_6             1.025                               1.025    0.851
##     Negative          1.000                               0.634    0.634
##     Positive          1.000                               0.987    0.987
##     LET               1.000                               1.000    1.000
## 
## R-Square:
## 
##     LET_1             0.409
##     LET_3             0.858
##     LET_5             0.650
##     LET_2             0.377
##     LET_4             0.700
##     LET_6             0.149
##     Negative          0.366
##     Positive          0.013
summary(alt.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after  25 iterations
## 
##                                                   Used       Total
##   Number of observations                           474         757
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              163.816
##   Degrees of freedom                                 7
##   P-value (Chi-square)                           0.000
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   Negative =~
##     LET_1             0.786                               0.987    0.639
##     LET_3             1.112                               1.396    0.926
##     LET_5             0.980                               1.231    0.806
##   Positive =~
##     LET_2             0.790                               0.795    0.614
##     LET_4             0.961                               0.967    0.837
##     LET_6             0.421                               0.424    0.386
##   LET =~
##     Positive         -0.115                              -0.115   -0.115
##     Negative          0.759                               0.605    0.605
## 
## Variances:
##     LET               1.000                               1.000    1.000
##     LET_1             1.407                               1.407    0.591
##     LET_3             0.322                               0.322    0.142
##     LET_5             0.814                               0.814    0.350
##     LET_2             1.046                               1.046    0.623
##     LET_4             0.400                               0.400    0.300
##     LET_6             1.025                               1.025    0.851
##     Negative          1.000                               0.634    0.634
##     Positive          1.000                               0.987    0.987
## 
## R-Square:
## 
##     LET_1             0.409
##     LET_3             0.858
##     LET_5             0.650
##     LET_2             0.377
##     LET_4             0.700
##     LET_6             0.149
##     Negative          0.366
##     Positive          0.013
summary(bifactor.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after  32 iterations
## 
##                                                   Used       Total
##   Number of observations                           474         757
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic               46.231
##   Degrees of freedom                                 3
##   P-value (Chi-square)                           0.000
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   Negative =~
##     LET_1             1.123                               1.123    0.728
##     LET_3             0.974                               0.974    0.646
##     LET_5             0.819                               0.819    0.537
##   Positive =~
##     LET_2             0.807                               0.807    0.623
##     LET_4             0.796                               0.796    0.689
##     LET_6             0.689                               0.689    0.627
##   LifeSatisfaction =~
##     LET_1             0.305                               0.305    0.198
##     LET_2            -0.411                              -0.411   -0.317
##     LET_3             0.938                               0.938    0.622
##     LET_4            -0.294                              -0.294   -0.255
##     LET_5             0.979                               0.979    0.642
##     LET_6             0.460                               0.460    0.419
## 
## Covariances:
##   Negative ~~
##     Positive          0.000                               0.000    0.000
##     LifeSatisfctn     0.000                               0.000    0.000
##   Positive ~~
##     LifeSatisfctn     0.000                               0.000    0.000
## 
## Variances:
##     LET_1             1.027                               1.027    0.431
##     LET_3             0.443                               0.443    0.195
##     LET_5             0.698                               0.698    0.300
##     LET_2             0.859                               0.859    0.512
##     LET_4             0.616                               0.616    0.461
##     LET_6             0.519                               0.519    0.431
##     Negative          1.000                               1.000    1.000
##     Positive          1.000                               1.000    1.000
##     LifeSatisfctn     1.000                               1.000    1.000
## 
## R-Square:
## 
##     LET_1             0.569
##     LET_3             0.805
##     LET_5             0.700
##     LET_2             0.488
##     LET_4             0.539
##     LET_6             0.569
summary(bifactor.fit1, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after  32 iterations
## 
##                                                   Used       Total
##   Number of observations                           474         757
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic               46.231
##   Degrees of freedom                                 3
##   P-value (Chi-square)                           0.000
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   LET =~
##     LET_1             0.305                               0.305    0.198
##     LET_2            -0.411                              -0.411   -0.317
##     LET_3             0.938                               0.938    0.622
##     LET_4            -0.294                              -0.294   -0.255
##     LET_5             0.979                               0.979    0.642
##     LET_6             0.460                               0.460    0.419
##   Negative =~
##     LET_1             1.123                               1.123    0.728
##     LET_3             0.974                               0.974    0.646
##     LET_5             0.819                               0.819    0.537
##   Positive =~
##     LET_2             0.807                               0.807    0.623
##     LET_4             0.796                               0.796    0.689
##     LET_6             0.689                               0.689    0.627
## 
## Covariances:
##   LET ~~
##     Negative          0.000                               0.000    0.000
##     Positive          0.000                               0.000    0.000
##   Negative ~~
##     Positive          0.000                               0.000    0.000
## 
## Variances:
##     LET_1             1.027                               1.027    0.431
##     LET_2             0.859                               0.859    0.512
##     LET_3             0.443                               0.443    0.195
##     LET_4             0.616                               0.616    0.461
##     LET_5             0.698                               0.698    0.300
##     LET_6             0.519                               0.519    0.431
##     LET               1.000                               1.000    1.000
##     Negative          1.000                               1.000    1.000
##     Positive          1.000                               1.000    1.000
## 
## R-Square:
## 
##     LET_1             0.569
##     LET_2             0.488
##     LET_3             0.805
##     LET_4             0.539
##     LET_5             0.700
##     LET_6             0.569
summary(bifactor.negative.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after  27 iterations
## 
##                                                   Used       Total
##   Number of observations                           474         757
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              124.100
##   Degrees of freedom                                 6
##   P-value (Chi-square)                           0.000
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   Negative =~
##     LET_1             1.036    0.066   15.812    0.000    1.036    0.671
##     LET_3             1.360    0.061   22.310    0.000    1.360    0.903
##     LET_5             1.247    0.063   19.830    0.000    1.247    0.817
##   LET =~
##     LET_1             0.328    0.083    3.964    0.000    0.328    0.212
##     LET_2             1.030    0.080   12.950    0.000    1.030    0.795
##     LET_3            -0.090    0.081   -1.102    0.270   -0.090   -0.060
##     LET_4             0.756    0.066   11.449    0.000    0.756    0.654
##     LET_5            -0.225    0.082   -2.737    0.006   -0.225   -0.147
##     LET_6             0.384    0.058    6.637    0.000    0.384    0.350
## 
## Covariances:
##   Negative ~~
##     LET               0.000                               0.000    0.000
## 
## Variances:
##     LET_1             1.200    0.096                      1.200    0.504
##     LET_3             0.413    0.086                      0.413    0.182
##     LET_5             0.723    0.085                      0.723    0.311
##     LET_2             0.618    0.135                      0.618    0.368
##     LET_4             0.764    0.086                      0.764    0.572
##     LET_6             1.058    0.073                      1.058    0.878
##     Negative          1.000                               1.000    1.000
##     LET               1.000                               1.000    1.000
## 
## R-Square:
## 
##     LET_1             0.496
##     LET_3             0.818
##     LET_5             0.689
##     LET_2             0.632
##     LET_4             0.428
##     LET_6             0.122
summary(bifactor.positive.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after  25 iterations
## 
##                                                   Used       Total
##   Number of observations                           474         757
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic               64.749
##   Degrees of freedom                                 6
##   P-value (Chi-square)                           0.000
## 
## Parameter estimates:
## 
##   Information                                 Expected
##   Standard Errors                             Standard
## 
##                    Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
## Latent variables:
##   Positive =~
##     LET_2             0.813    0.073   11.111    0.000    0.813    0.628
##     LET_4             0.921    0.072   12.818    0.000    0.921    0.797
##     LET_6             0.506    0.054    9.327    0.000    0.506    0.461
##   LET =~
##     LET_1             0.979    0.067   14.590    0.000    0.979    0.634
##     LET_2            -0.107    0.063   -1.711    0.087   -0.107   -0.083
##     LET_3             1.393    0.060   23.386    0.000    1.393    0.924
##     LET_4            -0.128    0.056   -2.291    0.022   -0.128   -0.111
##     LET_5             1.238    0.063   19.703    0.000    1.238    0.811
##     LET_6             0.418    0.051    8.152    0.000    0.418    0.381
## 
## Covariances:
##   Positive ~~
##     LET               0.000                               0.000    0.000
## 
## Variances:
##     LET_2             1.006    0.105                      1.006    0.599
##     LET_4             0.470    0.110                      0.470    0.352
##     LET_6             0.774    0.061                      0.774    0.642
##     LET_1             1.422    0.102                      1.422    0.597
##     LET_3             0.331    0.082                      0.331    0.146
##     LET_5             0.796    0.082                      0.796    0.342
##     Positive          1.000                               1.000    1.000
##     LET               1.000                               1.000    1.000
## 
## R-Square:
## 
##     LET_2             0.401
##     LET_4             0.648
##     LET_6             0.358
##     LET_1             0.403
##     LET_3             0.854
##     LET_5             0.658

Residual correlations

correl.1 = residuals(one.fit, type="cor")
correl.1
## $type
## [1] "cor.bollen"
## 
## $cor
##       LET_1  LET_2  LET_3  LET_4  LET_5  LET_6 
## LET_1  0.000                                   
## LET_2  0.213  0.000                            
## LET_3  0.002 -0.007  0.000                     
## LET_4  0.138  0.502 -0.026  0.000              
## LET_5  0.002 -0.112 -0.003 -0.041  0.000       
## LET_6  0.030  0.285  0.002  0.361  0.005  0.000
## 
## $mean
## LET_1 LET_2 LET_3 LET_4 LET_5 LET_6 
##     0     0     0     0     0     0
#View(correl.1$cor)
correl = residuals(two.fit, type="cor")
correl
## $type
## [1] "cor.bollen"
## 
## $cor
##       LET_1  LET_3  LET_5  LET_2  LET_4  LET_6 
## LET_1  0.000                                   
## LET_3  0.001  0.000                            
## LET_5  0.002 -0.001  0.000                     
## LET_2  0.194 -0.035 -0.137  0.000              
## LET_4  0.113 -0.062 -0.073 -0.004  0.000       
## LET_6  0.286  0.373  0.329  0.020  0.002  0.000
## 
## $mean
## LET_1 LET_3 LET_5 LET_2 LET_4 LET_6 
##     0     0     0     0     0     0
#View(correl$cor)
correl1 = residuals(second.fit, type="cor")
correl1
## $type
## [1] "cor.bollen"
## 
## $cor
##       LET_1  LET_3  LET_5  LET_2  LET_4  LET_6 
## LET_1  0.000                                   
## LET_3  0.001  0.000                            
## LET_5  0.002 -0.001  0.000                     
## LET_2  0.194 -0.035 -0.137  0.000              
## LET_4  0.113 -0.062 -0.073 -0.004  0.000       
## LET_6  0.286  0.373  0.329  0.020  0.002  0.000
## 
## $mean
## LET_1 LET_3 LET_5 LET_2 LET_4 LET_6 
##     0     0     0     0     0     0
#View(correl1$cor)
correl2 = residuals(alt.fit, type="cor")
correl2
## $type
## [1] "cor.bollen"
## 
## $cor
##       LET_1  LET_3  LET_5  LET_2  LET_4  LET_6 
## LET_1  0.000                                   
## LET_3  0.001  0.000                            
## LET_5  0.002 -0.001  0.000                     
## LET_2  0.194 -0.035 -0.137  0.000              
## LET_4  0.113 -0.062 -0.073 -0.004  0.000       
## LET_6  0.286  0.373  0.329  0.020  0.002  0.000
## 
## $mean
## LET_1 LET_3 LET_5 LET_2 LET_4 LET_6 
##     0     0     0     0     0     0
#View(correl2$cor)
correl3 = residuals(bifactor.fit, type="cor")
correl3
## $type
## [1] "cor.bollen"
## 
## $cor
##       LET_1 LET_3 LET_5 LET_2 LET_4 LET_6
## LET_1 0.000                              
## LET_3 0.000 0.000                        
## LET_5 0.000 0.000 0.000                  
## LET_2 0.229 0.123 0.032 0.000            
## LET_4 0.126 0.042 0.044 0.000 0.000      
## LET_6 0.186 0.088 0.039 0.000 0.000 0.000
## 
## $mean
## LET_1 LET_3 LET_5 LET_2 LET_4 LET_6 
##     0     0     0     0     0     0
#View(correl3$cor)
correl4 = residuals(bifactor.fit1, type="cor")
correl4
## $type
## [1] "cor.bollen"
## 
## $cor
##       LET_1 LET_2 LET_3 LET_4 LET_5 LET_6
## LET_1 0.000                              
## LET_2 0.229 0.000                        
## LET_3 0.000 0.123 0.000                  
## LET_4 0.126 0.000 0.042 0.000            
## LET_5 0.000 0.032 0.000 0.044 0.000      
## LET_6 0.186 0.000 0.088 0.000 0.039 0.000
## 
## $mean
## LET_1 LET_2 LET_3 LET_4 LET_5 LET_6 
##     0     0     0     0     0     0
#View(correl4$cor)
correl5 = residuals(bifactor.negative.fit, type="cor")
correl5
## $type
## [1] "cor.bollen"
## 
## $cor
##       LET_1  LET_3  LET_5  LET_2  LET_4  LET_6 
## LET_1  0.000                                   
## LET_3  0.000  0.000                            
## LET_5  0.000  0.000  0.000                     
## LET_2 -0.002 -0.027 -0.054  0.000              
## LET_4 -0.063 -0.077 -0.023 -0.011  0.000       
## LET_6  0.194  0.369  0.359 -0.020  0.097  0.000
## 
## $mean
## LET_1 LET_3 LET_5 LET_2 LET_4 LET_6 
##     0     0     0     0     0     0
#View(correl5$cor)
correl6 = residuals(bifactor.positive.fit, type="cor")
correl6
## $type
## [1] "cor.bollen"
## 
## $cor
##       LET_2  LET_4  LET_6  LET_1  LET_3  LET_5 
## LET_2  0.000                                   
## LET_4  0.000  0.000                            
## LET_6  0.000  0.000  0.000                     
## LET_1  0.219  0.146  0.027  0.000              
## LET_3  0.002 -0.013 -0.004  0.007  0.000       
## LET_5 -0.104 -0.029 -0.002  0.003 -0.004  0.000
## 
## $mean
## LET_2 LET_4 LET_6 LET_1 LET_3 LET_5 
##     0     0     0     0     0     0
#View(correl6$cor)

zscore correlation anything over 1.96 is going to be statistically significant at the .05 level

zcorrels10 = residuals(one.fit, type = "standardized")
zcorrels10$cov
##       LET_1  LET_2  LET_3  LET_4  LET_5  LET_6 
## LET_1     NA                                   
## LET_2  6.156  0.000                            
## LET_3  0.503 -0.691  0.000                     
## LET_4  4.071  9.811 -2.606     NA              
## LET_5  0.182 -4.479     NA -1.704  0.000       
## LET_6  0.954  6.525  0.221  8.118  0.265     NA
zcorrels = residuals(two.fit, type = "standardized")
zcorrels$cov
##       LET_1  LET_3  LET_5  LET_2  LET_4  LET_6 
## LET_1  0.000                                   
## LET_3  0.618     NA                            
## LET_5  0.705     NA     NA                     
## LET_2  4.735 -1.066 -3.677     NA              
## LET_4  3.232 -3.882 -2.723     NA     NA       
## LET_6  6.287  8.447  7.372  2.973  0.822     NA
#zcorrels1 = residuals(second.fit, type = "standardized")
#zcorrels1$cov
#zcorrels2 = residuals(alt.fit, type = "standardized")
#zcorrels2$cov
#zcorrels3 = residuals(bifactor.fit, type = "standardized")
#zcorrels3$cov
#zcorrels4 = residuals(bifactor1.fit, type = "standardized")
#zcorrels4$cov
zcorrels5 = residuals(bifactor.negative.fit, type = "standardized")
zcorrels5$cov
##       LET_1  LET_3  LET_5  LET_2  LET_4  LET_6 
## LET_1  0.000                                   
## LET_3  0.000  0.000                            
## LET_5  0.000  0.000  0.000                     
## LET_2 -0.164 -1.664 -3.272     NA              
## LET_4 -2.429 -2.609 -0.815     NA     NA       
## LET_6  4.617  8.257  8.265 -2.000  4.104  0.000
zcorrels6 = residuals(bifactor.positive.fit, type = "standardized")
zcorrels6$cov
##       LET_2  LET_4  LET_6  LET_1  LET_3  LET_5 
## LET_2     NA                                   
## LET_4     NA     NA                            
## LET_6     NA     NA     NA                     
## LET_1  6.316  4.323  0.856     NA              
## LET_3  0.225 -1.361 -0.508  1.239     NA       
## LET_5 -4.230 -1.244 -0.075  0.255     NA  0.000

Modification indicies

modindices(one.fit, sort. = TRUE, minimum.value = 3.84)
##     lhs op   rhs      mi    epc sepc.lv sepc.all sepc.nox
## 1 LET_2 ~~ LET_4 121.652  0.754   0.754    0.503    0.503
## 2 LET_4 ~~ LET_6  74.152  0.468   0.468    0.369    0.369
## 3 LET_2 ~~ LET_6  45.901  0.413   0.413    0.291    0.291
## 4 LET_1 ~~ LET_2  39.681  0.463   0.463    0.232    0.232
## 5 LET_2 ~~ LET_5  21.979 -0.283  -0.283   -0.143   -0.143
## 6 LET_1 ~~ LET_4  16.635  0.267   0.267    0.150    0.150
## 7 LET_3 ~~ LET_4   7.648 -0.149  -0.149   -0.086   -0.086
## 8 LET_3 ~~ LET_5   6.441 -0.611  -0.611   -0.266   -0.266
modindices(two.fit, sort. = TRUE, minimum.value = 3.84)
##         lhs op   rhs     mi     epc sepc.lv sepc.all sepc.nox
## 1     LET_2 ~~ LET_4 88.629 -12.462 -12.462   -8.323   -8.323
## 2  Negative =~ LET_6 88.623   0.479   0.479    0.436    0.436
## 3  Positive =~ LET_1 27.610   0.344   0.344    0.223    0.223
## 4     LET_3 ~~ LET_5 27.610  -8.613  -8.613   -3.745   -3.745
## 5     LET_1 ~~ LET_2 23.908   0.306   0.306    0.153    0.153
## 6     LET_5 ~~ LET_2 20.623  -0.232  -0.232   -0.118   -0.118
## 7     LET_3 ~~ LET_6 16.732   0.182   0.182    0.110    0.110
## 8     LET_2 ~~ LET_6 16.118   1.255   1.255    0.882    0.882
## 9  Negative =~ LET_4 16.118  -0.250  -0.250   -0.217   -0.217
## 10    LET_3 ~~ LET_4  8.872  -0.129  -0.129   -0.074   -0.074
## 11    LET_5 ~~ LET_6  5.708   0.114   0.114    0.068    0.068
## 12 Positive =~ LET_5  4.799  -0.118  -0.118   -0.078   -0.078
## 13    LET_1 ~~ LET_3  4.799   1.905   1.905    0.819    0.819
#modindices(second.fit, sort. = TRUE, minimum.value = 3.84)
#modindices(alt.fit, sort. = TRUE, minimum.value = 3.84)
#modindices(bifactor.fit, sort. = TRUE, minimum.value = 3.84)
#modindices(bifactor.fit1, sort. = TRUE, minimum.value = 3.84)
modindices(bifactor.negative.fit, sort. = TRUE, minimum.value = 3.84)
##         lhs op   rhs     mi    epc sepc.lv sepc.all sepc.nox
## 1  Negative =~ LET_6 82.067  0.469   0.469    0.427    0.427
## 2     LET_4 ~~ LET_6 21.157  0.294   0.294    0.232    0.232
## 3     LET_2 ~~ LET_4 17.479 -1.080  -1.080   -0.721   -0.721
## 4     LET_3 ~~ LET_6 15.070  0.176   0.176    0.106    0.106
## 5     LET_5 ~~ LET_2 14.469 -0.254  -0.254   -0.129   -0.129
## 6     LET_5 ~~ LET_6 11.719  0.166   0.166    0.099    0.099
## 7     LET_3 ~~ LET_4  6.160 -0.111  -0.111   -0.064   -0.064
## 8     LET_1 ~~ LET_2  5.834  0.231   0.231    0.116    0.116
## 9  Negative =~ LET_4  5.074 -0.114  -0.114   -0.099   -0.099
## 10 Negative =~ LET_2  4.670 -0.143  -0.143   -0.110   -0.110
## 11    LET_5 ~~ LET_4  4.501  0.108   0.108    0.061    0.061
modindices(bifactor.positive.fit, sort. = TRUE, minimum.value = 3.84)
##        lhs op   rhs     mi    epc sepc.lv sepc.all sepc.nox
## 1 Positive =~ LET_1 27.331  0.348   0.348    0.225    0.225
## 2    LET_2 ~~ LET_1 26.451  0.324   0.324    0.162    0.162
## 3    LET_2 ~~ LET_5 20.366 -0.233  -0.233   -0.118   -0.118
## 4    LET_3 ~~ LET_5  8.792 -0.595  -0.595   -0.259   -0.259
## 5 Positive =~ LET_5  5.264 -0.125  -0.125   -0.082   -0.082

Fit Measures

fitmeasures(one.fit)
##                npar                fmin               chisq 
##              12.000               0.311             294.824 
##                  df              pvalue      baseline.chisq 
##               9.000               0.000             967.563 
##         baseline.df     baseline.pvalue                 cfi 
##              15.000               0.000               0.700 
##                 tli                nnfi                 rfi 
##               0.500               0.500               0.492 
##                 nfi                pnfi                 ifi 
##               0.695               0.417               0.702 
##                 rni                logl   unrestricted.logl 
##               0.700           -4534.928           -4387.516 
##                 aic                 bic              ntotal 
##            9093.856            9143.791             474.000 
##                bic2               rmsea      rmsea.ci.lower 
##            9105.705               0.259               0.234 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.285               0.000               0.243 
##          rmr_nomean                srmr        srmr_bentler 
##               0.243               0.161               0.161 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.161               0.161               0.161 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.161               0.161              28.201 
##               cn_01                 gfi                agfi 
##              35.833               0.819               0.578 
##                pgfi                 mfi                ecvi 
##               0.351               0.740               0.673
fitmeasures(two.fit)
##                npar                fmin               chisq 
##              13.000               0.173             163.816 
##                  df              pvalue      baseline.chisq 
##               8.000               0.000             967.563 
##         baseline.df     baseline.pvalue                 cfi 
##              15.000               0.000               0.836 
##                 tli                nnfi                 rfi 
##               0.693               0.693               0.683 
##                 nfi                pnfi                 ifi 
##               0.831               0.443               0.838 
##                 rni                logl   unrestricted.logl 
##               0.836           -4469.424           -4387.516 
##                 aic                 bic              ntotal 
##            8964.848            9018.944             474.000 
##                bic2               rmsea      rmsea.ci.lower 
##            8977.684               0.203               0.176 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.230               0.000               0.241 
##          rmr_nomean                srmr        srmr_bentler 
##               0.241               0.140               0.140 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.140               0.140               0.140 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.140               0.140              45.870 
##               cn_01                 gfi                agfi 
##              59.131               0.906               0.754 
##                pgfi                 mfi                ecvi 
##               0.345               0.848               0.400
fitmeasures(second.fit)
##                npar                fmin               chisq 
##              14.000               0.173             163.816 
##                  df              pvalue      baseline.chisq 
##               7.000               0.000             967.563 
##         baseline.df     baseline.pvalue                 cfi 
##              15.000               0.000               0.835 
##                 tli                nnfi                 rfi 
##               0.647               0.647               0.637 
##                 nfi                pnfi                 ifi 
##               0.831               0.388               0.837 
##                 rni                logl   unrestricted.logl 
##               0.835           -4469.424           -4387.516 
##                 aic                 bic              ntotal 
##            8966.848            9025.105             474.000 
##                bic2               rmsea      rmsea.ci.lower 
##            8980.671               0.217               0.189 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.247               0.000               0.241 
##          rmr_nomean                srmr        srmr_bentler 
##               0.241               0.140               0.140 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.140               0.140               0.140 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.140               0.140              41.703 
##               cn_01                 gfi                agfi 
##              54.458               0.906               0.719 
##                pgfi                 mfi                ecvi 
##               0.302               0.848               0.405
fitmeasures(alt.fit)
##                npar                fmin               chisq 
##              14.000               0.173             163.816 
##                  df              pvalue      baseline.chisq 
##               7.000               0.000             967.563 
##         baseline.df     baseline.pvalue                 cfi 
##              15.000               0.000               0.835 
##                 tli                nnfi                 rfi 
##               0.647               0.647               0.637 
##                 nfi                pnfi                 ifi 
##               0.831               0.388               0.837 
##                 rni                logl   unrestricted.logl 
##               0.835           -4469.424           -4387.516 
##                 aic                 bic              ntotal 
##            8966.848            9025.105             474.000 
##                bic2               rmsea      rmsea.ci.lower 
##            8980.671               0.217               0.189 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.247               0.000               0.241 
##          rmr_nomean                srmr        srmr_bentler 
##               0.241               0.140               0.140 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.140               0.140               0.140 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.140               0.140              41.703 
##               cn_01                 gfi                agfi 
##              54.458               0.906               0.719 
##                pgfi                 mfi                ecvi 
##               0.302               0.848               0.405
fitmeasures(bifactor.fit)
##                npar                fmin               chisq 
##              18.000               0.049              46.231 
##                  df              pvalue      baseline.chisq 
##               3.000               0.000             967.563 
##         baseline.df     baseline.pvalue                 cfi 
##              15.000               0.000               0.955 
##                 tli                nnfi                 rfi 
##               0.773               0.773               0.761 
##                 nfi                pnfi                 ifi 
##               0.952               0.190               0.955 
##                 rni                logl   unrestricted.logl 
##               0.955           -4410.632           -4387.516 
##                 aic                 bic              ntotal 
##            8857.264            8932.166             474.000 
##                bic2               rmsea      rmsea.ci.lower 
##            8875.036               0.174               0.132 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.220               0.000               0.148 
##          rmr_nomean                srmr        srmr_bentler 
##               0.148               0.079               0.079 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.079               0.079               0.079 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.079               0.079              81.123 
##               cn_01                 gfi                agfi 
##             117.317               0.970               0.788 
##                pgfi                 mfi                ecvi 
##               0.139               0.955               0.173
fitmeasures(bifactor.fit1)
##                npar                fmin               chisq 
##              18.000               0.049              46.231 
##                  df              pvalue      baseline.chisq 
##               3.000               0.000             967.563 
##         baseline.df     baseline.pvalue                 cfi 
##              15.000               0.000               0.955 
##                 tli                nnfi                 rfi 
##               0.773               0.773               0.761 
##                 nfi                pnfi                 ifi 
##               0.952               0.190               0.955 
##                 rni                logl   unrestricted.logl 
##               0.955           -4410.632           -4387.516 
##                 aic                 bic              ntotal 
##            8857.264            8932.166             474.000 
##                bic2               rmsea      rmsea.ci.lower 
##            8875.036               0.174               0.132 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.220               0.000               0.148 
##          rmr_nomean                srmr        srmr_bentler 
##               0.148               0.079               0.079 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.079               0.079               0.079 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.079               0.079              81.123 
##               cn_01                 gfi                agfi 
##             117.317               0.970               0.788 
##                pgfi                 mfi                ecvi 
##               0.139               0.955               0.173
fitmeasures(bifactor.negative.fit)
##                npar                fmin               chisq 
##              15.000               0.131             124.100 
##                  df              pvalue      baseline.chisq 
##               6.000               0.000             967.563 
##         baseline.df     baseline.pvalue                 cfi 
##              15.000               0.000               0.876 
##                 tli                nnfi                 rfi 
##               0.690               0.690               0.679 
##                 nfi                pnfi                 ifi 
##               0.872               0.349               0.877 
##                 rni                logl   unrestricted.logl 
##               0.876           -4449.566           -4387.516 
##                 aic                 bic              ntotal 
##            8929.133            8991.551             474.000 
##                bic2               rmsea      rmsea.ci.lower 
##            8943.943               0.204               0.173 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.236               0.000               0.208 
##          rmr_nomean                srmr        srmr_bentler 
##               0.208               0.125               0.125 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.125               0.125               0.125 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.125               0.125              49.094 
##               cn_01                 gfi                agfi 
##              65.213               0.929               0.752 
##                pgfi                 mfi                ecvi 
##               0.265               0.883               0.325
fitmeasures(bifactor.positive.fit)
##                npar                fmin               chisq 
##              15.000               0.068              64.749 
##                  df              pvalue      baseline.chisq 
##               6.000               0.000             967.563 
##         baseline.df     baseline.pvalue                 cfi 
##              15.000               0.000               0.938 
##                 tli                nnfi                 rfi 
##               0.846               0.846               0.833 
##                 nfi                pnfi                 ifi 
##               0.933               0.373               0.939 
##                 rni                logl   unrestricted.logl 
##               0.938           -4419.891           -4387.516 
##                 aic                 bic              ntotal 
##            8869.781            8932.199             474.000 
##                bic2               rmsea      rmsea.ci.lower 
##            8884.592               0.144               0.113 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.176               0.000               0.121 
##          rmr_nomean                srmr        srmr_bentler 
##               0.121               0.062               0.062 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.062               0.062               0.062 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.062               0.062              93.178 
##               cn_01                 gfi                agfi 
##             124.073               0.959               0.857 
##                pgfi                 mfi                ecvi 
##               0.274               0.940               0.200