1. I live one day at a time and don’t really think about the future. (rs)
  2. I tend to focus on the present, because the future always brings me problems. (rs)
  3. My daily activities often seem trivial and unimportant to me. (rs)
  4. I don’t have a good sense of what it is that I am trying to accomplish in my life. (rs)
  5. I used to set goals for myself, but that now seems a waste of time. (rs)
  6. I enjoy making plans for the future and working to make them a reality.
  7. I am an active person in carrying out the plans I set for myself.
  8. Some people wander aimlessly through life, but I am not one of them.
  9. I sometimes feel as if I’ve done all there is to do in life. (rs)

library(lavaan)
## This is lavaan 0.5-20
## 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)
## Warning: package 'car' was built under R version 3.2.3
## 
## Attaching package: 'car'
## The following object is masked from 'package:psych':
## 
##     logit
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.2.3
## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
library(GGally)
## Warning: package 'GGally' was built under R version 3.2.3
## 
## Attaching package: 'GGally'
## The following object is masked from 'package:dplyr':
## 
##     nasa
library(xtable) 

data preparation

data <- read.csv("~/Dropbox/Git/stats/allsurveysYT1_Jan2016.csv", header=T)
 PWB<-select(data,  PWB_1,  PWB_2,  PWB_3,  PWB_4,  PWB_5,  PWB_6, PWB_7,  PWB_8,  PWB_9)
PWB$PWB_1  <-  7- PWB$PWB_1
PWB$PWB_2  <-  7- PWB$PWB_2
PWB$PWB_3  <-  7- PWB$PWB_3
PWB$PWB_4  <-  7- PWB$PWB_4
PWB$PWB_9  <-  7- PWB$PWB_9
 PWB<- data.frame(apply(PWB,2, as.numeric))
str(PWB)
## 'data.frame':    1288 obs. of  9 variables:
##  $ PWB_1: num  4 2 2 5 3 1 3 1 5 2 ...
##  $ PWB_2: num  6 2 3 2 3 2 4 2 5 2 ...
##  $ PWB_3: num  5 4 3 5 3 2 3 1 5 2 ...
##  $ PWB_4: num  3 4 2 5 3 2 4 1 5 2 ...
##  $ PWB_5: num  5 6 5 3 4 4 3 6 1 5 ...
##  $ PWB_6: num  4 1 4 5 4 4 3 6 5 5 ...
##  $ PWB_7: num  3 2 6 4 4 4 4 2 5 5 ...
##  $ PWB_8: num  5 4 6 4 4 4 3 6 5 5 ...
##  $ PWB_9: num  1 3 2 6 3 2 4 1 5 2 ...
colnames(PWB) <- c("1","2", "3", "4", "5", "6", "7", "8", "9")
 PWB<- PWB[complete.cases(PWB[,]),]

EFA

number of factors

parallal analysis and scree plot

parallel<-fa.parallel(PWB, fm="ml",fa="fa")

## Parallel analysis suggests that the number of factors =  4  and the number of components =  NA
#two factors are greater than one Eigenvalue scree plot says there are two factors. Paralel analysis suggests 4 factors

eigenvalues (kaiser)

parallel$fa.values
## [1]  2.73344015  0.71182568  0.28802420  0.06142515 -0.02194723 -0.10593730
## [7] -0.18210012 -0.29494755 -0.47494233
#over 1=2, over .7=2

doign aprincipal components analysis to see how many factors there might be using that method

Deal with NA doing principle componant analysis.

princomp(na.omit(PWB), cor = TRUE)
## Call:
## princomp(x = na.omit(PWB), cor = TRUE)
## 
## Standard deviations:
##    Comp.1    Comp.2    Comp.3    Comp.4    Comp.5    Comp.6    Comp.7 
## 1.8271781 1.2556471 0.9950615 0.8300724 0.8048028 0.7172643 0.6810303 
##    Comp.8    Comp.9 
## 0.6407490 0.6075076 
## 
##  9  variables and  944 observations.
parallel2<-princomp(na.omit(PWB), cor = TRUE)
summary(parallel2)
## Importance of components:
##                           Comp.1    Comp.2    Comp.3     Comp.4    Comp.5
## Standard deviation     1.8271781 1.2556471 0.9950615 0.83007244 0.8048028
## Proportion of Variance 0.3709533 0.1751833 0.1100164 0.07655781 0.0719675
## Cumulative Proportion  0.3709533 0.5461366 0.6561530 0.73271081 0.8046783
##                            Comp.6     Comp.7    Comp.8     Comp.9
## Standard deviation     0.71726434 0.68103033 0.6407490 0.60750759
## Proportion of Variance 0.05716313 0.05153359 0.0456177 0.04100727
## Cumulative Proportion  0.86184143 0.91337502 0.9589927 1.00000000
plot(parallel2)##results show at least two factors

#simple structure

twofactor<-fa(PWB, nfactors=2, rotate="oblimin", fm="ml")
twofactor
## Factor Analysis using method =  ml
## Call: fa(r = PWB, nfactors = 2, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
##     ML1   ML2   h2   u2 com
## 1  0.67 -0.15 0.44 0.56 1.1
## 2  0.51  0.06 0.27 0.73 1.0
## 3  0.77 -0.02 0.59 0.41 1.0
## 4  0.51  0.26 0.38 0.62 1.5
## 5 -0.78  0.00 0.60 0.40 1.0
## 6  0.43  0.30 0.32 0.68 1.8
## 7 -0.03  0.87 0.75 0.25 1.0
## 8  0.04  0.59 0.36 0.64 1.0
## 9  0.46  0.02 0.21 0.79 1.0
## 
##                        ML1  ML2
## SS loadings           2.60 1.32
## Proportion Var        0.29 0.15
## Cumulative Var        0.29 0.44
## Proportion Explained  0.66 0.34
## Cumulative Proportion 0.66 1.00
## 
##  With factor correlations of 
##      ML1  ML2
## ML1 1.00 0.19
## ML2 0.19 1.00
## 
## Mean item complexity =  1.2
## Test of the hypothesis that 2 factors are sufficient.
## 
## The degrees of freedom for the null model are  36  and the objective function was  2.48 with Chi Square of  2325.18
## The degrees of freedom for the model are 19  and the objective function was  0.21 
## 
## The root mean square of the residuals (RMSR) is  0.05 
## The df corrected root mean square of the residuals is  0.07 
## 
## The harmonic number of observations is  944 with the empirical chi square  176.93  with prob <  1.2e-27 
## The total number of observations was  944  with MLE Chi Square =  195.13  with prob <  3.2e-31 
## 
## Tucker Lewis Index of factoring reliability =  0.854
## RMSEA index =  0.099  and the 90 % confidence intervals are  0.087 0.112
## BIC =  64.98
## Fit based upon off diagonal values = 0.97
## Measures of factor score adequacy             
##                                                 ML1  ML2
## Correlation of scores with factors             0.91 0.89
## Multiple R square of scores with factors       0.84 0.79
## Minimum correlation of possible factor scores  0.67 0.59
1-((twofactor$STATISTIC - twofactor$dof)/(twofactor$null.chisq- twofactor$null.dof))
## [1] 0.9230604
fa2latex(fa(PWB,2,rotate="oblimin", fm="ml"), heading="Table 1. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWB, 2, rotate = "oblimin", fm = "ml") % Called in the psych package  Table 1. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r r }
##  \multicolumn{ 5 }{l}{ Table 1. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   ML1  &  ML2  &  h2  &  u2  &  com \cr 
##   \hline 
## 1   &  \bf{ 0.67}  &  -0.15  &  0.44  &  0.56  &  1.10 \cr 
##  2   &  \bf{ 0.51}  &   0.06  &  0.27  &  0.73  &  1.03 \cr 
##  3   &  \bf{ 0.77}  &  -0.02  &  0.59  &  0.41  &  1.00 \cr 
##  4   &  \bf{ 0.51}  &   0.26  &  0.38  &  0.62  &  1.49 \cr 
##  5   &  \bf{-0.78}  &   0.00  &  0.60  &  0.40  &  1.00 \cr 
##  6   &  \bf{ 0.43}  &   0.30  &  0.32  &  0.68  &  1.79 \cr 
##  7   &  -0.03  &  \bf{ 0.87}  &  0.75  &  0.25  &  1.00 \cr 
##  8   &   0.04  &  \bf{ 0.59}  &  0.36  &  0.64  &  1.01 \cr 
##  9   &  \bf{ 0.46}  &   0.02  &  0.21  &  0.79  &  1.00 \cr 
## \hline \cr SS loadings & 2.6 &  1.32 &  \cr  
## \cr 
##             \hline \cr 
## ML1   & 1.00 & 0.19 \cr 
##  ML2   & 0.19 & 1.00 \cr 
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}
threefactor<-fa(PWB, nfactors=3, rotate="oblimin", fm="ml")
threefactor
## Factor Analysis using method =  ml
## Call: fa(r = PWB, nfactors = 3, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
##     ML1   ML2   ML3   h2   u2 com
## 1  0.54 -0.17  0.23 0.44 0.56 1.6
## 2  0.13  0.12  0.58 0.44 0.56 1.2
## 3  0.70 -0.07  0.15 0.59 0.41 1.1
## 4  0.27  0.29  0.38 0.42 0.58 2.7
## 5 -0.72  0.05 -0.15 0.61 0.39 1.1
## 6  0.69  0.23 -0.28 0.52 0.48 1.6
## 7 -0.04  0.84  0.05 0.70 0.30 1.0
## 8  0.03  0.61  0.02 0.38 0.62 1.0
## 9  0.13  0.07  0.48 0.32 0.68 1.2
## 
##                        ML1  ML2  ML3
## SS loadings           2.07 1.29 1.06
## Proportion Var        0.23 0.14 0.12
## Cumulative Var        0.23 0.37 0.49
## Proportion Explained  0.47 0.29 0.24
## Cumulative Proportion 0.47 0.76 1.00
## 
##  With factor correlations of 
##      ML1   ML2   ML3
## ML1 1.00  0.25  0.44
## ML2 0.25  1.00 -0.02
## ML3 0.44 -0.02  1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 3 factors are sufficient.
## 
## The degrees of freedom for the null model are  36  and the objective function was  2.48 with Chi Square of  2325.18
## The degrees of freedom for the model are 12  and the objective function was  0.07 
## 
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.04 
## 
## The harmonic number of observations is  944 with the empirical chi square  40.04  with prob <  7.1e-05 
## The total number of observations was  944  with MLE Chi Square =  69.45  with prob <  4.1e-10 
## 
## Tucker Lewis Index of factoring reliability =  0.925
## RMSEA index =  0.072  and the 90 % confidence intervals are  0.056 0.088
## BIC =  -12.76
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                 ML1  ML2  ML3
## Correlation of scores with factors             0.91 0.88 0.80
## Multiple R square of scores with factors       0.82 0.77 0.64
## Minimum correlation of possible factor scores  0.64 0.53 0.28
1-((threefactor$STATISTIC - threefactor$dof)/(threefactor$null.chisq- threefactor$null.dof))
## [1] 0.9749055
fa2latex(fa(PWB,3,rotate="oblimin", fm="ml"), heading="Table 2. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWB, 3, rotate = "oblimin", fm = "ml") % Called in the psych package  Table 2. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r r r }
##  \multicolumn{ 6 }{l}{ Table 2. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   ML1  &  ML2  &  ML3  &  h2  &  u2  &  com \cr 
##   \hline 
## 1   &  \bf{ 0.54}  &  -0.17  &   0.23  &  0.44  &  0.56  &  1.58 \cr 
##  2   &   0.13  &   0.12  &  \bf{ 0.58}  &  0.44  &  0.56  &  1.18 \cr 
##  3   &  \bf{ 0.70}  &  -0.07  &   0.15  &  0.59  &  0.41  &  1.11 \cr 
##  4   &   0.27  &   0.29  &  \bf{ 0.38}  &  0.42  &  0.58  &  2.72 \cr 
##  5   &  \bf{-0.72}  &   0.05  &  -0.15  &  0.61  &  0.39  &  1.09 \cr 
##  6   &  \bf{ 0.69}  &   0.23  &  -0.28  &  0.52  &  0.48  &  1.57 \cr 
##  7   &  -0.04  &  \bf{ 0.84}  &   0.05  &  0.70  &  0.30  &  1.01 \cr 
##  8   &   0.03  &  \bf{ 0.61}  &   0.02  &  0.38  &  0.62  &  1.01 \cr 
##  9   &   0.13  &   0.07  &  \bf{ 0.48}  &  0.32  &  0.68  &  1.19 \cr 
## \hline \cr SS loadings & 2.07 &  1.29 &  1.06 &  \cr  
## \cr 
##             \hline \cr 
## ML1   &  1.00 &  0.25 &  0.44 \cr 
##  ML2   &  0.25 &  1.00 & -0.02 \cr 
##  ML3   &  0.44 & -0.02 &  1.00 \cr 
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}
fourfactor<-fa(PWB, nfactors=4, rotate="oblimin", fm="ml")
fourfactor
## Factor Analysis using method =  ml
## Call: fa(r = PWB, nfactors = 4, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
##     ML1   ML2   ML4   ML3   h2   u2 com
## 1  0.13 -0.23  0.52  0.30 0.54 0.46 2.2
## 2 -0.01  0.09  0.75 -0.06 0.56 0.44 1.0
## 3  0.84 -0.05 -0.05  0.04 0.68 0.32 1.0
## 4  0.50  0.31  0.15 -0.15 0.45 0.55 2.1
## 5 -0.60  0.04 -0.13 -0.16 0.58 0.42 1.2
## 6  0.11  0.19  0.00  0.70 0.66 0.34 1.2
## 7 -0.02  0.79  0.01  0.08 0.65 0.35 1.0
## 8  0.01  0.60  0.01  0.09 0.40 0.60 1.0
## 9  0.31  0.07  0.32 -0.17 0.29 0.71 2.6
## 
##                        ML1  ML2  ML4  ML3
## SS loadings           1.68 1.22 1.15 0.75
## Proportion Var        0.19 0.14 0.13 0.08
## Cumulative Var        0.19 0.32 0.45 0.53
## Proportion Explained  0.35 0.25 0.24 0.16
## Cumulative Proportion 0.35 0.60 0.84 1.00
## 
##  With factor correlations of 
##      ML1  ML2  ML4  ML3
## ML1 1.00 0.14 0.63 0.48
## ML2 0.14 1.00 0.12 0.20
## ML4 0.63 0.12 1.00 0.19
## ML3 0.48 0.20 0.19 1.00
## 
## Mean item complexity =  1.5
## Test of the hypothesis that 4 factors are sufficient.
## 
## The degrees of freedom for the null model are  36  and the objective function was  2.48 with Chi Square of  2325.18
## The degrees of freedom for the model are 6  and the objective function was  0.01 
## 
## The root mean square of the residuals (RMSR) is  0.01 
## The df corrected root mean square of the residuals is  0.02 
## 
## The harmonic number of observations is  944 with the empirical chi square  2.69  with prob <  0.85 
## The total number of observations was  944  with MLE Chi Square =  4.93  with prob <  0.55 
## 
## Tucker Lewis Index of factoring reliability =  1.003
## RMSEA index =  0  and the 90 % confidence intervals are  NA 0.038
## BIC =  -36.17
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                 ML1  ML2  ML4  ML3
## Correlation of scores with factors             0.91 0.86 0.85 0.82
## Multiple R square of scores with factors       0.83 0.74 0.73 0.68
## Minimum correlation of possible factor scores  0.65 0.48 0.45 0.35
1-((fourfactor$STATISTIC - fourfactor$dof)/(fourfactor$null.chisq- fourfactor$null.dof))
## [1] 1.000468
fa2latex(fa(PWB,4,rotate="oblimin", fm="ml"), heading="Table 3. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWB, 4, rotate = "oblimin", fm = "ml") % Called in the psych package  Table 3. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r r r r }
##  \multicolumn{ 7 }{l}{ Table 3. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   ML1  &  ML2  &  ML4  &  ML3  &  h2  &  u2  &  com \cr 
##   \hline 
## 1   &   0.13  &  -0.23  &  \bf{ 0.52}  &   0.30  &  0.54  &  0.46  &  2.19 \cr 
##  2   &  -0.01  &   0.09  &  \bf{ 0.75}  &  -0.06  &  0.56  &  0.44  &  1.04 \cr 
##  3   &  \bf{ 0.84}  &  -0.05  &  -0.05  &   0.04  &  0.68  &  0.32  &  1.02 \cr 
##  4   &  \bf{ 0.50}  &  \bf{ 0.31}  &   0.15  &  -0.15  &  0.45  &  0.55  &  2.08 \cr 
##  5   &  \bf{-0.60}  &   0.04  &  -0.13  &  -0.16  &  0.58  &  0.42  &  1.24 \cr 
##  6   &   0.11  &   0.19  &   0.00  &  \bf{ 0.70}  &  0.66  &  0.34  &  1.20 \cr 
##  7   &  -0.02  &  \bf{ 0.79}  &   0.01  &   0.08  &  0.65  &  0.35  &  1.02 \cr 
##  8   &   0.01  &  \bf{ 0.60}  &   0.01  &   0.09  &  0.40  &  0.60  &  1.05 \cr 
##  9   &  \bf{ 0.31}  &   0.07  &  \bf{ 0.32}  &  -0.17  &  0.29  &  0.71  &  2.60 \cr 
## \hline \cr SS loadings & 1.68 &  1.22 &  1.15 &  0.75 &  \cr  
## \cr 
##             \hline \cr 
## ML1   & 1.00 & 0.14 & 0.63 & 0.48 \cr 
##  ML2   & 0.14 & 1.00 & 0.12 & 0.20 \cr 
##  ML4   & 0.63 & 0.12 & 1.00 & 0.19 \cr 
##  ML3   & 0.48 & 0.20 & 0.19 & 1.00 \cr 
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}

question 1,3,5,6,9 seems to be one factor and all talk about plans or lack of plans

 PWBWO15<-select(PWB,  1,3,5,6,9)
 PWBWO15<-tbl_df(PWBWO15)
 PWBWO15
## Source: local data frame [944 x 5]
## 
##        1     3     5     6     9
##    (dbl) (dbl) (dbl) (dbl) (dbl)
## 1      4     5     5     4     1
## 2      2     4     6     1     3
## 3      2     3     5     4     2
## 4      5     5     3     5     6
## 5      3     3     4     4     3
## 6      1     2     4     4     2
## 7      3     3     3     3     4
## 8      1     1     6     6     1
## 9      5     5     1     5     5
## 10     2     2     5     5     2
## ..   ...   ...   ...   ...   ...
twofactorWO15<-fa(PWBWO15, nfactors=1, rotate="oblimin", fm="ml")
twofactorWO15
## Factor Analysis using method =  ml
## Call: fa(r = PWBWO15, nfactors = 1, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
##     ML1   h2   u2 com
## 1  0.61 0.37 0.63   1
## 3  0.77 0.59 0.41   1
## 5 -0.81 0.65 0.35   1
## 6  0.51 0.26 0.74   1
## 9  0.42 0.18 0.82   1
## 
##                 ML1
## SS loadings    2.05
## Proportion Var 0.41
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  10  and the objective function was  1.23 with Chi Square of  1158.85
## The degrees of freedom for the model are 5  and the objective function was  0.03 
## 
## The root mean square of the residuals (RMSR) is  0.04 
## The df corrected root mean square of the residuals is  0.05 
## 
## The harmonic number of observations is  944 with the empirical chi square  26.66  with prob <  6.6e-05 
## The total number of observations was  944  with MLE Chi Square =  23.97  with prob <  0.00022 
## 
## Tucker Lewis Index of factoring reliability =  0.967
## RMSEA index =  0.064  and the 90 % confidence intervals are  0.039 0.09
## BIC =  -10.28
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                 ML1
## Correlation of scores with factors             0.90
## Multiple R square of scores with factors       0.82
## Minimum correlation of possible factor scores  0.63
fa2latex(fa(PWBWO15,3,rotate="oblimin", fm="ml"), heading="Table 4. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWBWO15, 3, rotate = "oblimin", fm = "ml") % Called in the psych package  Table 4. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r r r }
##  \multicolumn{ 6 }{l}{ Table 4. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   ML1  &  ML2  &  ML3  &  h2  &  u2  &  com \cr 
##   \hline 
## 1   &  -0.03  &  \bf{ 0.36}  &  \bf{ 0.37}  &  0.40  &  0.60  &  2.01 \cr 
##  3   &  -0.28  &  \bf{ 0.31}  &   0.27  &  0.56  &  0.44  &  2.97 \cr 
##  5   &  \bf{ 0.88}  &   0.00  &   0.00  &  0.76  &  0.24  &  1.00 \cr 
##  6   &  -0.04  &  \bf{ 0.64}  &  -0.06  &  0.42  &  0.58  &  1.03 \cr 
##  9   &  -0.06  &  -0.08  &  \bf{ 0.57}  &  0.34  &  0.66  &  1.06 \cr 
## \hline \cr SS loadings & 1.03 &  0.78 &  0.67 &  \cr  
## \cr 
##             \hline \cr 
## ML1   &  1.00 & -0.75 & -0.72 \cr 
##  ML2   & -0.75 &  1.00 &  0.40 \cr 
##  ML3   & -0.72 &  0.40 &  1.00 \cr 
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}

CFI, should be slightly higher than the TLI

1-((twofactorWO15$STATISTIC - twofactorWO15$dof)/(twofactorWO15$null.chisq- twofactorWO15$null.dof))
## [1] 0.9834837

question 7,8 seems to be one factor and all talk about being active or wondering aimlessly

 PWB78<-select(PWB,  7,8)
 PWB78<-tbl_df(PWB78)
 PWB78
## Source: local data frame [944 x 2]
## 
##        7     8
##    (dbl) (dbl)
## 1      3     5
## 2      2     4
## 3      6     6
## 4      4     4
## 5      4     4
## 6      4     4
## 7      4     3
## 8      2     6
## 9      5     5
## 10     5     5
## ..   ...   ...
twofactor78<-fa(PWB78, nfactors=1, rotate="oblimin", fm="ml")
twofactor78
## Factor Analysis using method =  ml
## Call: fa(r = PWB78, nfactors = 1, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
##    ML1  h2  u2 com
## 7 0.71 0.5 0.5   1
## 8 0.71 0.5 0.5   1
## 
##                 ML1
## SS loadings    1.01
## Proportion Var 0.50
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  1  and the objective function was  0.29 with Chi Square of  277.04
## The degrees of freedom for the model are -1  and the objective function was  0 
## 
## The root mean square of the residuals (RMSR) is  0 
## The df corrected root mean square of the residuals is  NA 
## 
## The harmonic number of observations is  944 with the empirical chi square  0  with prob <  NA 
## The total number of observations was  944  with MLE Chi Square =  0  with prob <  NA 
## 
## Tucker Lewis Index of factoring reliability =  1.004
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                 ML1
## Correlation of scores with factors             0.82
## Multiple R square of scores with factors       0.67
## Minimum correlation of possible factor scores  0.34
fa2latex(fa(PWB78,1,rotate="oblimin", fm="ml"), heading="Table 5. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWB78, 1, rotate = "oblimin", fm = "ml") % Called in the psych package  Table 5. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r }
##  \multicolumn{ 4 }{l}{ Table 5. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   ML1  &  ML1.1  &  ML1.2  &  com \cr 
##   \hline 
## 7   &  \bf{0.71}  &  0.5  &  0.5  &  1 \cr 
##  8   &  \bf{0.71}  &  0.5  &  0.5  &  1 \cr 
## \hline \cr SS loadings & 1.01 &  \cr  
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}

CFI, should be slightly higher than the TLI

1-((twofactor78$STATISTIC - twofactor78$dof)/(twofactor78$null.chisq- twofactor78$null.dof))
## [1] 0.9963773

question 2,8 seems to be one factor

 PWB29<-select(PWB, 2,8)
 PWB29<-tbl_df(PWB29)
 PWB29
## Source: local data frame [944 x 2]
## 
##        2     8
##    (dbl) (dbl)
## 1      6     5
## 2      2     4
## 3      3     6
## 4      2     4
## 5      3     4
## 6      2     4
## 7      4     3
## 8      2     6
## 9      5     5
## 10     2     5
## ..   ...   ...
twofactor29<-fa(PWB29, nfactors=1, rotate="oblimin", fm="ml")
twofactor29
## Factor Analysis using method =  ml
## Call: fa(r = PWB29, nfactors = 1, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
##    ML1   h2   u2 com
## 2 0.34 0.12 0.88   1
## 8 0.34 0.12 0.88   1
## 
##                 ML1
## SS loadings    0.24
## Proportion Var 0.12
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  1  and the objective function was  0.01 with Chi Square of  13.32
## The degrees of freedom for the model are -1  and the objective function was  0 
## 
## The root mean square of the residuals (RMSR) is  0 
## The df corrected root mean square of the residuals is  NA 
## 
## The harmonic number of observations is  944 with the empirical chi square  0  with prob <  NA 
## The total number of observations was  944  with MLE Chi Square =  0  with prob <  NA 
## 
## Tucker Lewis Index of factoring reliability =  1.081
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                  ML1
## Correlation of scores with factors              0.46
## Multiple R square of scores with factors        0.21
## Minimum correlation of possible factor scores  -0.58
fa2latex(fa(PWB29,1,rotate="oblimin", fm="ml"), heading="Table 6. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWB29, 1, rotate = "oblimin", fm = "ml") % Called in the psych package  Table 6. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r }
##  \multicolumn{ 4 }{l}{ Table 6. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   ML1  &  ML1.1  &  ML1.2  &  com \cr 
##   \hline 
## 2   &  \bf{0.34}  &  0.12  &  0.88  &  1 \cr 
##  8   &  \bf{0.34}  &  0.12  &  0.88  &  1 \cr 
## \hline \cr SS loadings & 0.24 &  \cr  
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}

CFI, should be slightly higher than the TLI

1-((twofactor29$STATISTIC - twofactor29$dof)/(twofactor29$null.chisq- twofactor29$null.dof))
## [1] 0.9187993

Finding Alpha

#alpha(PWB, na.rm = TRUE, check.keys=TRUE)

CFA in Lavaan

data <- read.csv("~/Dropbox/Git/stats/allsurveysYT1_Jan2016.csv", header=T)
data<-tbl_df(data)
PWB<-select(data, PWB_1, PWB_2, PWB_3, PWB_4, PWB_5, PWB_6,PWB_7, PWB_8, PWB_9)
PWB$PWB_1  <-  7- PWB$PWB_1
PWB$PWB_2  <-  7- PWB$PWB_2
PWB$PWB_3  <-  7- PWB$PWB_3
PWB$PWB_4  <-  7- PWB$PWB_4
PWB$PWB_9  <-  7- PWB$PWB_9
PWB<-tbl_df(PWB)
PWB
## Source: local data frame [1,288 x 9]
## 
##    PWB_1 PWB_2 PWB_3 PWB_4 PWB_5 PWB_6 PWB_7 PWB_8 PWB_9
##    (dbl) (dbl) (dbl) (dbl) (int) (int) (int) (int) (dbl)
## 1      4     6     5     3     5     4     3     5     1
## 2      2     2     4     4     6     1     2     4     3
## 3      2     3     3     2     5     4     6     6     2
## 4      5     2     5     5     3     5     4     4     6
## 5      3     3     3     3     4     4     4     4     3
## 6      1     2     2     2     4     4     4     4     2
## 7      3     4     3     4     3     3     4     3     4
## 8      1     2     1     1     6     6     2     6     1
## 9      5     5     5     5     1     5     5     5     5
## 10     2     2     2     2     5     5     5     5     2
## ..   ...   ...   ...   ...   ...   ...   ...   ...   ...

create plots

#ggpairs(PWB, columns = 1:15, title="Big 5 Marsh" )

create the models

two.model= ' Factor1  =~ PWB_1 +  PWB_3  + PWB_4 + PWB_5 + PWB_6 + PWB_9   
              Factor2 =~   PWB_2+ PWB_7 + PWB_8
'  #Models two factors:Positive and Negative     
              

one.model= 'PWB =~ PWB_1 +  PWB_2  + PWB_3 + PWB_4 + PWB_5 + PWB_6 + PWB_7 + PWB_8 + PWB_9' #Models as a single purpose factor

Second order models

second.model = '  Negative  =~  PWB_1 +  PWB_2  + PWB_3 + PWB_4 + PWB_5 + PWB_9 
                Positive =~   PWB_6 + PWB_7 + PWB_8
                Purpose =~ Negative + Positive 
' #Second order models as Purpose being the higher factor made up of Purpose and Positive

Bifactor (like model 7 in Marsh, Scalas & Nagengast, 2010)

bifactor.negative.model = 'Negative =~ PWB_1 +  PWB_2  + PWB_3 + PWB_4 + PWB_5 + PWB_9  
                                     PWB =~ PWB_1 +  PWB_2  + PWB_3 + PWB_4 + PWB_5 + PWB_6 + PWB_7 + PWB_8 + PWB_9 
'
#Models bifactor as the negatively worded item as a factor uncorolated with the main factor


bifactor.model1 = 'PWB =~ PWB_1 +  PWB_2  + PWB_3 + PWB_4 + PWB_5 + PWB_6 + PWB_7 + PWB_8 + PWB_9
                Negative  =~ PWB_1 +  PWB_2  + PWB_3 + PWB_4 + PWB_5 + PWB_9   
              Positive =~   PWB_6 + PWB_7 + PWB_8
                PWB ~~ 0*Negative
                PWB ~~ 0*Positive
                Negative~~0*Positive
'#Models bifactor with Positive and Purpose as factors uncorolated with the main factor

bifactor.model2 = 'PWB =~ PWB_1 +  PWB_2  + PWB_3 + PWB_4 + PWB_5 + PWB_6 + PWB_7 + PWB_8 + PWB_9
                F1  =~ PWB_1 +  PWB_3  + PWB_5 + PWB_6   
                F2 =~   PWB_4 + PWB_7 + PWB_8 
                F3 =~ PWB_2 + PWB_9 
                PWB ~~ 0*F1
                PWB ~~ 0*F2
                PWB ~~ 0*F3
                F1~~0*F2
                F1~~0*F3
                F2~~0*F3
'#Models bifactor with Positive and Purpose as factors uncorolated with the main factor

run the models

two.fit=cfa(two.model, data=PWB, missing = "fiml", std.lv = T)
## Warning in lav_data_full(data = data, group = group, group.label = group.label, : lavaan WARNING: some cases are empty and will be removed:
##   145 150 151 152 156 157 171 173 206 207 208 209 213 221 222 223 238 239 240 244 249 250 251 252 253 256 257 258 259 261 263 265 266 268 275 279 280 283 284 290 294 297 298 299 300 301 302 304 305 307 308 311 312 314 315 316 317 320 322 323 325 328 330 331 332 335 336 338 340 342 343 345 348 350 351 352 354 355 356 357 358 362 366 368 371 373 374 375 377 380 383 384 393 394 395 396 398 399 402 403 408 409 410 412 414 415 417 419 420 426 428 432 437 438 439 440 443 444 445 448 450 453 455 458 461 462 464 467 468 472 476 478 479 480 482 483 485 488 489 490 492 493 494 495 496 497 498 499 500 501 502 503 504 505 507 508 509 512 513 514 517 518 525 526 527 528 529 530 531 532 533 534 535 536 538 544 545 546 547 548 549 550 551 552 553 555 556 557 558 559 560 562 564 572 573 574 575 576 580 581 582 583 584 585 587 588 590 591 592 593 595 596 598 600 601 602 603 604 606 609 610 613 614 618 619 621 623 667 668 669 670 671 672 673 674 676 677 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 790 807 815 910 911 912 913 937 938 957 1031 1034 1035 1037 1039 1238 1240 1241 1242 1244 1245 1248 1249 1250 1253 1254 1256 1257 1258 1259 1260 1262 1264 1265 1266 1267 1268 1271 1273 1274 1275 1278 1279 1280 1282 1283 1287 1288
## Found more than one class "Model" in cache; using the first, from namespace 'lavaan'
one.fit=cfa(one.model, data=PWB, missing = "fiml", std.lv = T)
## Warning in lav_data_full(data = data, group = group, group.label = group.label, : lavaan WARNING: some cases are empty and will be removed:
##   145 150 151 152 156 157 171 173 206 207 208 209 213 221 222 223 238 239 240 244 249 250 251 252 253 256 257 258 259 261 263 265 266 268 275 279 280 283 284 290 294 297 298 299 300 301 302 304 305 307 308 311 312 314 315 316 317 320 322 323 325 328 330 331 332 335 336 338 340 342 343 345 348 350 351 352 354 355 356 357 358 362 366 368 371 373 374 375 377 380 383 384 393 394 395 396 398 399 402 403 408 409 410 412 414 415 417 419 420 426 428 432 437 438 439 440 443 444 445 448 450 453 455 458 461 462 464 467 468 472 476 478 479 480 482 483 485 488 489 490 492 493 494 495 496 497 498 499 500 501 502 503 504 505 507 508 509 512 513 514 517 518 525 526 527 528 529 530 531 532 533 534 535 536 538 544 545 546 547 548 549 550 551 552 553 555 556 557 558 559 560 562 564 572 573 574 575 576 580 581 582 583 584 585 587 588 590 591 592 593 595 596 598 600 601 602 603 604 606 609 610 613 614 618 619 621 623 667 668 669 670 671 672 673 674 676 677 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 790 807 815 910 911 912 913 937 938 957 1031 1034 1035 1037 1039 1238 1240 1241 1242 1244 1245 1248 1249 1250 1253 1254 1256 1257 1258 1259 1260 1262 1264 1265 1266 1267 1268 1271 1273 1274 1275 1278 1279 1280 1282 1283 1287 1288
second.fit=cfa(second.model, data=PWB, missing = "fiml", std.lv = T)
## Warning in lav_data_full(data = data, group = group, group.label = group.label, : lavaan WARNING: some cases are empty and will be removed:
##   145 150 151 152 156 157 171 173 206 207 208 209 213 221 222 223 238 239 240 244 249 250 251 252 253 256 257 258 259 261 263 265 266 268 275 279 280 283 284 290 294 297 298 299 300 301 302 304 305 307 308 311 312 314 315 316 317 320 322 323 325 328 330 331 332 335 336 338 340 342 343 345 348 350 351 352 354 355 356 357 358 362 366 368 371 373 374 375 377 380 383 384 393 394 395 396 398 399 402 403 408 409 410 412 414 415 417 419 420 426 428 432 437 438 439 440 443 444 445 448 450 453 455 458 461 462 464 467 468 472 476 478 479 480 482 483 485 488 489 490 492 493 494 495 496 497 498 499 500 501 502 503 504 505 507 508 509 512 513 514 517 518 525 526 527 528 529 530 531 532 533 534 535 536 538 544 545 546 547 548 549 550 551 552 553 555 556 557 558 559 560 562 564 572 573 574 575 576 580 581 582 583 584 585 587 588 590 591 592 593 595 596 598 600 601 602 603 604 606 609 610 613 614 618 619 621 623 667 668 669 670 671 672 673 674 676 677 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 790 807 815 910 911 912 913 937 938 957 1031 1034 1035 1037 1039 1238 1240 1241 1242 1244 1245 1248 1249 1250 1253 1254 1256 1257 1258 1259 1260 1262 1264 1265 1266 1267 1268 1271 1273 1274 1275 1278 1279 1280 1282 1283 1287 1288
bifactor1.fit=cfa(bifactor.model1, data=PWB, missing = "fiml", std.lv = T)
## Warning in lav_data_full(data = data, group = group, group.label = group.label, : lavaan WARNING: some cases are empty and will be removed:
##   145 150 151 152 156 157 171 173 206 207 208 209 213 221 222 223 238 239 240 244 249 250 251 252 253 256 257 258 259 261 263 265 266 268 275 279 280 283 284 290 294 297 298 299 300 301 302 304 305 307 308 311 312 314 315 316 317 320 322 323 325 328 330 331 332 335 336 338 340 342 343 345 348 350 351 352 354 355 356 357 358 362 366 368 371 373 374 375 377 380 383 384 393 394 395 396 398 399 402 403 408 409 410 412 414 415 417 419 420 426 428 432 437 438 439 440 443 444 445 448 450 453 455 458 461 462 464 467 468 472 476 478 479 480 482 483 485 488 489 490 492 493 494 495 496 497 498 499 500 501 502 503 504 505 507 508 509 512 513 514 517 518 525 526 527 528 529 530 531 532 533 534 535 536 538 544 545 546 547 548 549 550 551 552 553 555 556 557 558 559 560 562 564 572 573 574 575 576 580 581 582 583 584 585 587 588 590 591 592 593 595 596 598 600 601 602 603 604 606 609 610 613 614 618 619 621 623 667 668 669 670 671 672 673 674 676 677 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 790 807 815 910 911 912 913 937 938 957 1031 1034 1035 1037 1039 1238 1240 1241 1242 1244 1245 1248 1249 1250 1253 1254 1256 1257 1258 1259 1260 1262 1264 1265 1266 1267 1268 1271 1273 1274 1275 1278 1279 1280 1282 1283 1287 1288
bifactor2.fit=cfa(bifactor.model2, data=PWB, missing = "fiml", std.lv = T)
## Warning in lav_data_full(data = data, group = group, group.label = group.label, : lavaan WARNING: some cases are empty and will be removed:
##   145 150 151 152 156 157 171 173 206 207 208 209 213 221 222 223 238 239 240 244 249 250 251 252 253 256 257 258 259 261 263 265 266 268 275 279 280 283 284 290 294 297 298 299 300 301 302 304 305 307 308 311 312 314 315 316 317 320 322 323 325 328 330 331 332 335 336 338 340 342 343 345 348 350 351 352 354 355 356 357 358 362 366 368 371 373 374 375 377 380 383 384 393 394 395 396 398 399 402 403 408 409 410 412 414 415 417 419 420 426 428 432 437 438 439 440 443 444 445 448 450 453 455 458 461 462 464 467 468 472 476 478 479 480 482 483 485 488 489 490 492 493 494 495 496 497 498 499 500 501 502 503 504 505 507 508 509 512 513 514 517 518 525 526 527 528 529 530 531 532 533 534 535 536 538 544 545 546 547 548 549 550 551 552 553 555 556 557 558 559 560 562 564 572 573 574 575 576 580 581 582 583 584 585 587 588 590 591 592 593 595 596 598 600 601 602 603 604 606 609 610 613 614 618 619 621 623 667 668 669 670 671 672 673 674 676 677 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 790 807 815 910 911 912 913 937 938 957 1031 1034 1035 1037 1039 1238 1240 1241 1242 1244 1245 1248 1249 1250 1253 1254 1256 1257 1258 1259 1260 1262 1264 1265 1266 1267 1268 1271 1273 1274 1275 1278 1279 1280 1282 1283 1287 1288
bifactorneg.fit = cfa(bifactor.negative.model, data=PWB, missing = "fiml", std.lv = T)
## Warning in lav_data_full(data = data, group = group, group.label = group.label, : lavaan WARNING: some cases are empty and will be removed:
##   145 150 151 152 156 157 171 173 206 207 208 209 213 221 222 223 238 239 240 244 249 250 251 252 253 256 257 258 259 261 263 265 266 268 275 279 280 283 284 290 294 297 298 299 300 301 302 304 305 307 308 311 312 314 315 316 317 320 322 323 325 328 330 331 332 335 336 338 340 342 343 345 348 350 351 352 354 355 356 357 358 362 366 368 371 373 374 375 377 380 383 384 393 394 395 396 398 399 402 403 408 409 410 412 414 415 417 419 420 426 428 432 437 438 439 440 443 444 445 448 450 453 455 458 461 462 464 467 468 472 476 478 479 480 482 483 485 488 489 490 492 493 494 495 496 497 498 499 500 501 502 503 504 505 507 508 509 512 513 514 517 518 525 526 527 528 529 530 531 532 533 534 535 536 538 544 545 546 547 548 549 550 551 552 553 555 556 557 558 559 560 562 564 572 573 574 575 576 580 581 582 583 584 585 587 588 590 591 592 593 595 596 598 600 601 602 603 604 606 609 610 613 614 618 619 621 623 667 668 669 670 671 672 673 674 676 677 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 790 807 815 910 911 912 913 937 938 957 1031 1034 1035 1037 1039 1238 1240 1241 1242 1244 1245 1248 1249 1250 1253 1254 1256 1257 1258 1259 1260 1262 1264 1265 1266 1267 1268 1271 1273 1274 1275 1278 1279 1280 1282 1283 1287 1288
bifactor.negative.fit=cfa(bifactor.negative.model, data=PWB, missing = "fiml", std.lv = T)
## Warning in lav_data_full(data = data, group = group, group.label = group.label, : lavaan WARNING: some cases are empty and will be removed:
##   145 150 151 152 156 157 171 173 206 207 208 209 213 221 222 223 238 239 240 244 249 250 251 252 253 256 257 258 259 261 263 265 266 268 275 279 280 283 284 290 294 297 298 299 300 301 302 304 305 307 308 311 312 314 315 316 317 320 322 323 325 328 330 331 332 335 336 338 340 342 343 345 348 350 351 352 354 355 356 357 358 362 366 368 371 373 374 375 377 380 383 384 393 394 395 396 398 399 402 403 408 409 410 412 414 415 417 419 420 426 428 432 437 438 439 440 443 444 445 448 450 453 455 458 461 462 464 467 468 472 476 478 479 480 482 483 485 488 489 490 492 493 494 495 496 497 498 499 500 501 502 503 504 505 507 508 509 512 513 514 517 518 525 526 527 528 529 530 531 532 533 534 535 536 538 544 545 546 547 548 549 550 551 552 553 555 556 557 558 559 560 562 564 572 573 574 575 576 580 581 582 583 584 585 587 588 590 591 592 593 595 596 598 600 601 602 603 604 606 609 610 613 614 618 619 621 623 667 668 669 670 671 672 673 674 676 677 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 790 807 815 910 911 912 913 937 938 957 1031 1034 1035 1037 1039 1238 1240 1241 1242 1244 1245 1248 1249 1250 1253 1254 1256 1257 1258 1259 1260 1262 1264 1265 1266 1267 1268 1271 1273 1274 1275 1278 1279 1280 1282 1283 1287 1288

create pictures

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

semPaths(two.fit, intercepts = FALSE, residual = FALSE, layout = "tree2", sizeMan = 4, font = 3,
         sizeLat=4.3, bifactor = "Purpose",edge.color="black", nCharNodes = 6, mar = c(3, 1,3, 1))

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

semPaths(one.fit, intercepts = FALSE, residual = FALSE, layout = "tree2", sizeMan = 4, font = 3,
         sizeLat=4.3, bifactor = "Purpose",edge.color="black", nCharNodes = 6, mar = c(3, 1,3, 1))

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

semPaths(second.fit, intercepts = FALSE, residual = FALSE, layout = "tree2", sizeMan = 4, font = 3,
         sizeLat=4.3, bifactor = "Purpose",edge.color="black", nCharNodes = 6, mar = c(3, 1,3, 1))

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

semPaths(bifactor1.fit, intercepts = FALSE, residual = FALSE, layout = "tree2", sizeMan = 5, font = 3,
         sizeLat=4.3, bifactor = "Purpose",edge.color="black", nCharNodes = 6, mar = c(3, 1,3, 1))

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

semPaths(bifactor2.fit, intercepts = FALSE, residual = FALSE, layout = "tree2", sizeMan = 4, font = 3,
         sizeLat=4.3, bifactor = "Purpose",edge.color="black", nCharNodes = 6, mar = c(3, 1,3, 1))

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

semPaths(bifactorneg.fit, intercepts = FALSE, residual = FALSE, layout = "tree2", sizeMan = 4, font = 3,
         sizeLat=4.3, bifactor = "Purpose",edge.color="black", nCharNodes = 6, mar = c(3, 1,3, 1))

#summaries

summary(two.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-20) converged normally after  32 iterations
## 
##                                                   Used       Total
##   Number of observations                           944        1288
## 
##   Number of missing patterns                         1
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              587.190
##   Degrees of freedom                                26
##   P-value (Chi-square)                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Latent Variables:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   Factor1 =~                                                            
##     PWB_1             0.947    0.052   18.368    0.000    0.947    0.595
##     PWB_3             1.212    0.047   25.767    0.000    1.212    0.778
##     PWB_4             0.852    0.050   17.174    0.000    0.852    0.565
##     PWB_5            -1.254    0.048  -26.153    0.000   -1.254   -0.787
##     PWB_6             0.673    0.043   15.563    0.000    0.673    0.518
##     PWB_9             0.638    0.050   12.873    0.000    0.638    0.438
##   Factor2 =~                                                            
##     PWB_2             0.353    0.060    5.882    0.000    0.353    0.244
##     PWB_7             0.920    0.059   15.513    0.000    0.920    0.706
##     PWB_8             0.966    0.063   15.422    0.000    0.966    0.691
## 
## Covariances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   Factor1 ~~                                                            
##     Factor2           0.315    0.044    7.113    0.000    0.315    0.315
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             3.860    0.052   74.452    0.000    3.860    2.423
##     PWB_3             4.138    0.051   81.586    0.000    4.138    2.655
##     PWB_4             3.969    0.049   80.845    0.000    3.969    2.631
##     PWB_5             2.895    0.052   55.850    0.000    2.895    1.818
##     PWB_6             4.469    0.042  105.703    0.000    4.469    3.440
##     PWB_9             4.761    0.047  100.241    0.000    4.761    3.263
##     PWB_2             3.822    0.047   81.370    0.000    3.822    2.648
##     PWB_7             4.483    0.042  105.743    0.000    4.483    3.442
##     PWB_8             4.315    0.046   94.758    0.000    4.315    3.084
##     Factor1           0.000                               0.000    0.000
##     Factor2           0.000                               0.000    0.000
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             1.641    0.085   19.200    0.000    1.641    0.647
##     PWB_3             0.960    0.066   14.472    0.000    0.960    0.395
##     PWB_4             1.549    0.080   19.434    0.000    1.549    0.681
##     PWB_5             0.965    0.069   14.000    0.000    0.965    0.381
##     PWB_6             1.234    0.062   19.988    0.000    1.234    0.732
##     PWB_9             1.721    0.083   20.628    0.000    1.721    0.809
##     PWB_2             1.958    0.094   20.816    0.000    1.958    0.940
##     PWB_7             0.851    0.094    9.034    0.000    0.851    0.501
##     PWB_8             1.023    0.105    9.761    0.000    1.023    0.523
##     Factor1           1.000                               1.000    1.000
##     Factor2           1.000                               1.000    1.000
## 
## R-Square:
##                    Estimate
##     PWB_1             0.353
##     PWB_3             0.605
##     PWB_4             0.319
##     PWB_5             0.619
##     PWB_6             0.268
##     PWB_9             0.191
##     PWB_2             0.060
##     PWB_7             0.499
##     PWB_8             0.477
(xtable(parameterEstimates(two.fit, ci = F, standardized = T,  fmi = F, remove.eq = F, 
                   remove.ineq = F, remove.def = T)))
## % latex table generated in R 3.2.2 by xtable 1.8-0 package
## % Mon Jan 25 12:41:13 2016
## \begin{table}[ht]
## \centering
## \begin{tabular}{rlllrrrrrrr}
##   \hline
##  & lhs & op & rhs & est & se & z & pvalue & std.lv & std.all & std.nox \\ 
##   \hline
## 1 & Factor1 & =\~{} & PWB\_1 & 0.95 & 0.05 & 18.37 & 0.00 & 0.95 & 0.59 & 0.59 \\ 
##   2 & Factor1 & =\~{} & PWB\_3 & 1.21 & 0.05 & 25.77 & 0.00 & 1.21 & 0.78 & 0.78 \\ 
##   3 & Factor1 & =\~{} & PWB\_4 & 0.85 & 0.05 & 17.17 & 0.00 & 0.85 & 0.56 & 0.56 \\ 
##   4 & Factor1 & =\~{} & PWB\_5 & -1.25 & 0.05 & -26.15 & 0.00 & -1.25 & -0.79 & -0.79 \\ 
##   5 & Factor1 & =\~{} & PWB\_6 & 0.67 & 0.04 & 15.56 & 0.00 & 0.67 & 0.52 & 0.52 \\ 
##   6 & Factor1 & =\~{} & PWB\_9 & 0.64 & 0.05 & 12.87 & 0.00 & 0.64 & 0.44 & 0.44 \\ 
##   7 & Factor2 & =\~{} & PWB\_2 & 0.35 & 0.06 & 5.88 & 0.00 & 0.35 & 0.24 & 0.24 \\ 
##   8 & Factor2 & =\~{} & PWB\_7 & 0.92 & 0.06 & 15.51 & 0.00 & 0.92 & 0.71 & 0.71 \\ 
##   9 & Factor2 & =\~{} & PWB\_8 & 0.97 & 0.06 & 15.42 & 0.00 & 0.97 & 0.69 & 0.69 \\ 
##   10 & PWB\_1 & \~{}\~{} & PWB\_1 & 1.64 & 0.09 & 19.20 & 0.00 & 1.64 & 0.65 & 0.65 \\ 
##   11 & PWB\_3 & \~{}\~{} & PWB\_3 & 0.96 & 0.07 & 14.47 & 0.00 & 0.96 & 0.40 & 0.40 \\ 
##   12 & PWB\_4 & \~{}\~{} & PWB\_4 & 1.55 & 0.08 & 19.43 & 0.00 & 1.55 & 0.68 & 0.68 \\ 
##   13 & PWB\_5 & \~{}\~{} & PWB\_5 & 0.97 & 0.07 & 14.00 & 0.00 & 0.97 & 0.38 & 0.38 \\ 
##   14 & PWB\_6 & \~{}\~{} & PWB\_6 & 1.23 & 0.06 & 19.99 & 0.00 & 1.23 & 0.73 & 0.73 \\ 
##   15 & PWB\_9 & \~{}\~{} & PWB\_9 & 1.72 & 0.08 & 20.63 & 0.00 & 1.72 & 0.81 & 0.81 \\ 
##   16 & PWB\_2 & \~{}\~{} & PWB\_2 & 1.96 & 0.09 & 20.82 & 0.00 & 1.96 & 0.94 & 0.94 \\ 
##   17 & PWB\_7 & \~{}\~{} & PWB\_7 & 0.85 & 0.09 & 9.03 & 0.00 & 0.85 & 0.50 & 0.50 \\ 
##   18 & PWB\_8 & \~{}\~{} & PWB\_8 & 1.02 & 0.10 & 9.76 & 0.00 & 1.02 & 0.52 & 0.52 \\ 
##   19 & Factor1 & \~{}\~{} & Factor1 & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   20 & Factor2 & \~{}\~{} & Factor2 & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   21 & Factor1 & \~{}\~{} & Factor2 & 0.31 & 0.04 & 7.11 & 0.00 & 0.31 & 0.31 & 0.31 \\ 
##   22 & PWB\_1 & \~{}1 &  & 3.86 & 0.05 & 74.45 & 0.00 & 3.86 & 2.42 & 2.42 \\ 
##   23 & PWB\_3 & \~{}1 &  & 4.14 & 0.05 & 81.59 & 0.00 & 4.14 & 2.66 & 2.66 \\ 
##   24 & PWB\_4 & \~{}1 &  & 3.97 & 0.05 & 80.85 & 0.00 & 3.97 & 2.63 & 2.63 \\ 
##   25 & PWB\_5 & \~{}1 &  & 2.90 & 0.05 & 55.85 & 0.00 & 2.90 & 1.82 & 1.82 \\ 
##   26 & PWB\_6 & \~{}1 &  & 4.47 & 0.04 & 105.70 & 0.00 & 4.47 & 3.44 & 3.44 \\ 
##   27 & PWB\_9 & \~{}1 &  & 4.76 & 0.05 & 100.24 & 0.00 & 4.76 & 3.26 & 3.26 \\ 
##   28 & PWB\_2 & \~{}1 &  & 3.82 & 0.05 & 81.37 & 0.00 & 3.82 & 2.65 & 2.65 \\ 
##   29 & PWB\_7 & \~{}1 &  & 4.48 & 0.04 & 105.74 & 0.00 & 4.48 & 3.44 & 3.44 \\ 
##   30 & PWB\_8 & \~{}1 &  & 4.31 & 0.05 & 94.76 & 0.00 & 4.31 & 3.08 & 3.08 \\ 
##   31 & Factor1 & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   32 & Factor2 & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##    \hline
## \end{tabular}
## \end{table}
summary(one.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-20) converged normally after  24 iterations
## 
##                                                   Used       Total
##   Number of observations                           944        1288
## 
##   Number of missing patterns                         1
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              643.119
##   Degrees of freedom                                27
##   P-value (Chi-square)                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Latent Variables:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   PWB =~                                                                
##     PWB_1             0.975    0.051   19.048    0.000    0.975    0.612
##     PWB_2             0.752    0.048   15.616    0.000    0.752    0.521
##     PWB_3             1.181    0.047   25.135    0.000    1.181    0.758
##     PWB_4             0.885    0.049   18.010    0.000    0.885    0.587
##     PWB_5            -1.229    0.048  -25.725    0.000   -1.229   -0.772
##     PWB_6             0.655    0.043   15.100    0.000    0.655    0.504
##     PWB_7             0.272    0.047    5.796    0.000    0.272    0.209
##     PWB_8             0.288    0.050    5.746    0.000    0.288    0.206
##     PWB_9             0.675    0.049   13.718    0.000    0.675    0.463
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             3.860    0.052   74.452    0.000    3.860    2.423
##     PWB_2             3.822    0.047   81.370    0.000    3.822    2.648
##     PWB_3             4.138    0.051   81.586    0.000    4.138    2.655
##     PWB_4             3.969    0.049   80.845    0.000    3.969    2.631
##     PWB_5             2.895    0.052   55.850    0.000    2.895    1.818
##     PWB_6             4.469    0.042  105.703    0.000    4.469    3.440
##     PWB_7             4.483    0.042  105.743    0.000    4.483    3.442
##     PWB_8             4.315    0.046   94.758    0.000    4.315    3.084
##     PWB_9             4.761    0.047  100.241    0.000    4.761    3.263
##     PWB               0.000                               0.000    0.000
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             1.586    0.084   18.961    0.000    1.586    0.625
##     PWB_2             1.517    0.076   19.889    0.000    1.517    0.728
##     PWB_3             1.034    0.066   15.688    0.000    1.034    0.426
##     PWB_4             1.492    0.078   19.205    0.000    1.492    0.656
##     PWB_5             1.026    0.068   15.098    0.000    1.026    0.405
##     PWB_6             1.259    0.062   20.143    0.000    1.259    0.746
##     PWB_7             1.623    0.076   21.477    0.000    1.623    0.956
##     PWB_8             1.874    0.087   21.496    0.000    1.874    0.958
##     PWB_9             1.673    0.082   20.479    0.000    1.673    0.786
##     PWB               1.000                               1.000    1.000
## 
## R-Square:
##                    Estimate
##     PWB_1             0.375
##     PWB_2             0.272
##     PWB_3             0.574
##     PWB_4             0.344
##     PWB_5             0.595
##     PWB_6             0.254
##     PWB_7             0.044
##     PWB_8             0.042
##     PWB_9             0.214
(xtable(parameterEstimates(one.fit, ci = F, standardized = T,  fmi = F, remove.eq = F, 
                   remove.ineq = F, remove.def = T)))
## % latex table generated in R 3.2.2 by xtable 1.8-0 package
## % Mon Jan 25 12:41:13 2016
## \begin{table}[ht]
## \centering
## \begin{tabular}{rlllrrrrrrr}
##   \hline
##  & lhs & op & rhs & est & se & z & pvalue & std.lv & std.all & std.nox \\ 
##   \hline
## 1 & PWB & =\~{} & PWB\_1 & 0.98 & 0.05 & 19.05 & 0.00 & 0.98 & 0.61 & 0.61 \\ 
##   2 & PWB & =\~{} & PWB\_2 & 0.75 & 0.05 & 15.62 & 0.00 & 0.75 & 0.52 & 0.52 \\ 
##   3 & PWB & =\~{} & PWB\_3 & 1.18 & 0.05 & 25.13 & 0.00 & 1.18 & 0.76 & 0.76 \\ 
##   4 & PWB & =\~{} & PWB\_4 & 0.89 & 0.05 & 18.01 & 0.00 & 0.89 & 0.59 & 0.59 \\ 
##   5 & PWB & =\~{} & PWB\_5 & -1.23 & 0.05 & -25.73 & 0.00 & -1.23 & -0.77 & -0.77 \\ 
##   6 & PWB & =\~{} & PWB\_6 & 0.65 & 0.04 & 15.10 & 0.00 & 0.65 & 0.50 & 0.50 \\ 
##   7 & PWB & =\~{} & PWB\_7 & 0.27 & 0.05 & 5.80 & 0.00 & 0.27 & 0.21 & 0.21 \\ 
##   8 & PWB & =\~{} & PWB\_8 & 0.29 & 0.05 & 5.75 & 0.00 & 0.29 & 0.21 & 0.21 \\ 
##   9 & PWB & =\~{} & PWB\_9 & 0.68 & 0.05 & 13.72 & 0.00 & 0.68 & 0.46 & 0.46 \\ 
##   10 & PWB\_1 & \~{}\~{} & PWB\_1 & 1.59 & 0.08 & 18.96 & 0.00 & 1.59 & 0.63 & 0.63 \\ 
##   11 & PWB\_2 & \~{}\~{} & PWB\_2 & 1.52 & 0.08 & 19.89 & 0.00 & 1.52 & 0.73 & 0.73 \\ 
##   12 & PWB\_3 & \~{}\~{} & PWB\_3 & 1.03 & 0.07 & 15.69 & 0.00 & 1.03 & 0.43 & 0.43 \\ 
##   13 & PWB\_4 & \~{}\~{} & PWB\_4 & 1.49 & 0.08 & 19.21 & 0.00 & 1.49 & 0.66 & 0.66 \\ 
##   14 & PWB\_5 & \~{}\~{} & PWB\_5 & 1.03 & 0.07 & 15.10 & 0.00 & 1.03 & 0.40 & 0.40 \\ 
##   15 & PWB\_6 & \~{}\~{} & PWB\_6 & 1.26 & 0.06 & 20.14 & 0.00 & 1.26 & 0.75 & 0.75 \\ 
##   16 & PWB\_7 & \~{}\~{} & PWB\_7 & 1.62 & 0.08 & 21.48 & 0.00 & 1.62 & 0.96 & 0.96 \\ 
##   17 & PWB\_8 & \~{}\~{} & PWB\_8 & 1.87 & 0.09 & 21.50 & 0.00 & 1.87 & 0.96 & 0.96 \\ 
##   18 & PWB\_9 & \~{}\~{} & PWB\_9 & 1.67 & 0.08 & 20.48 & 0.00 & 1.67 & 0.79 & 0.79 \\ 
##   19 & PWB & \~{}\~{} & PWB & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   20 & PWB\_1 & \~{}1 &  & 3.86 & 0.05 & 74.45 & 0.00 & 3.86 & 2.42 & 2.42 \\ 
##   21 & PWB\_2 & \~{}1 &  & 3.82 & 0.05 & 81.37 & 0.00 & 3.82 & 2.65 & 2.65 \\ 
##   22 & PWB\_3 & \~{}1 &  & 4.14 & 0.05 & 81.59 & 0.00 & 4.14 & 2.66 & 2.66 \\ 
##   23 & PWB\_4 & \~{}1 &  & 3.97 & 0.05 & 80.85 & 0.00 & 3.97 & 2.63 & 2.63 \\ 
##   24 & PWB\_5 & \~{}1 &  & 2.90 & 0.05 & 55.85 & 0.00 & 2.90 & 1.82 & 1.82 \\ 
##   25 & PWB\_6 & \~{}1 &  & 4.47 & 0.04 & 105.70 & 0.00 & 4.47 & 3.44 & 3.44 \\ 
##   26 & PWB\_7 & \~{}1 &  & 4.48 & 0.04 & 105.74 & 0.00 & 4.48 & 3.44 & 3.44 \\ 
##   27 & PWB\_8 & \~{}1 &  & 4.31 & 0.05 & 94.76 & 0.00 & 4.31 & 3.08 & 3.08 \\ 
##   28 & PWB\_9 & \~{}1 &  & 4.76 & 0.05 & 100.24 & 0.00 & 4.76 & 3.26 & 3.26 \\ 
##   29 & PWB & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##    \hline
## \end{tabular}
## \end{table}
summary(second.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-20) converged normally after  30 iterations
## 
##                                                   Used       Total
##   Number of observations                           944        1288
## 
##   Number of missing patterns                         1
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              442.762
##   Degrees of freedom                                25
##   P-value (Chi-square)                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Latent Variables:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   Negative =~                                                           
##     PWB_1             0.829       NA                      0.981    0.616
##     PWB_2             0.661       NA                      0.782    0.542
##     PWB_3             0.994       NA                      1.176    0.755
##     PWB_4             0.752       NA                      0.890    0.590
##     PWB_5            -1.029       NA                     -1.218   -0.765
##     PWB_9             0.597       NA                      0.706    0.484
##   Positive =~                                                           
##     PWB_6             0.499       NA                      0.655    0.504
##     PWB_7             0.695       NA                      0.913    0.701
##     PWB_8             0.707       NA                      0.928    0.663
##   Purpose =~                                                            
##     Negative          0.633       NA                      0.535    0.535
##     Positive          0.851       NA                      0.648    0.648
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             3.860    0.052   74.452    0.000    3.860    2.423
##     PWB_2             3.822    0.047   81.370    0.000    3.822    2.648
##     PWB_3             4.138    0.051   81.586    0.000    4.138    2.655
##     PWB_4             3.969    0.049   80.845    0.000    3.969    2.631
##     PWB_5             2.895    0.052   55.850    0.000    2.895    1.818
##     PWB_9             4.761    0.047  100.241    0.000    4.761    3.263
##     PWB_6             4.469    0.042  105.703    0.000    4.469    3.440
##     PWB_7             4.483    0.042  105.743    0.000    4.483    3.442
##     PWB_8             4.315    0.046   94.758    0.000    4.315    3.084
##     Negative          0.000                               0.000    0.000
##     Positive          0.000                               0.000    0.000
##     Purpose           0.000                               0.000    0.000
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             1.576    0.084   18.739    0.000    1.576    0.621
##     PWB_2             1.471    0.076   19.471    0.000    1.471    0.706
##     PWB_3             1.045    0.068   15.323    0.000    1.045    0.430
##     PWB_4             1.484    0.078   19.005    0.000    1.484    0.652
##     PWB_5             1.054    0.071   14.917    0.000    1.054    0.416
##     PWB_9             1.631    0.081   20.217    0.000    1.631    0.766
##     PWB_6             1.259    0.075   16.800    0.000    1.259    0.746
##     PWB_7             0.863    0.077   11.207    0.000    0.863    0.508
##     PWB_8             1.096    0.083   13.253    0.000    1.096    0.560
##     Negative          1.000                               0.714    0.714
##     Positive          1.000                               0.580    0.580
##     Purpose           1.000                               1.000    1.000
## 
## R-Square:
##                    Estimate
##     PWB_1             0.379
##     PWB_2             0.294
##     PWB_3             0.570
##     PWB_4             0.348
##     PWB_5             0.584
##     PWB_9             0.234
##     PWB_6             0.254
##     PWB_7             0.492
##     PWB_8             0.440
##     Negative          0.286
##     Positive          0.420
(xtable(parameterEstimates(second.fit, ci = F, standardized = T,  fmi = F, remove.eq = F, 
                   remove.ineq = F, remove.def = T)))
## % latex table generated in R 3.2.2 by xtable 1.8-0 package
## % Mon Jan 25 12:41:13 2016
## \begin{table}[ht]
## \centering
## \begin{tabular}{rlllrrrrrrr}
##   \hline
##  & lhs & op & rhs & est & se & z & pvalue & std.lv & std.all & std.nox \\ 
##   \hline
## 1 & Negative & =\~{} & PWB\_1 & 0.83 &  &  &  & 0.98 & 0.62 & 0.62 \\ 
##   2 & Negative & =\~{} & PWB\_2 & 0.66 &  &  &  & 0.78 & 0.54 & 0.54 \\ 
##   3 & Negative & =\~{} & PWB\_3 & 0.99 &  &  &  & 1.18 & 0.75 & 0.75 \\ 
##   4 & Negative & =\~{} & PWB\_4 & 0.75 &  &  &  & 0.89 & 0.59 & 0.59 \\ 
##   5 & Negative & =\~{} & PWB\_5 & -1.03 &  &  &  & -1.22 & -0.76 & -0.76 \\ 
##   6 & Negative & =\~{} & PWB\_9 & 0.60 &  &  &  & 0.71 & 0.48 & 0.48 \\ 
##   7 & Positive & =\~{} & PWB\_6 & 0.50 &  &  &  & 0.65 & 0.50 & 0.50 \\ 
##   8 & Positive & =\~{} & PWB\_7 & 0.70 &  &  &  & 0.91 & 0.70 & 0.70 \\ 
##   9 & Positive & =\~{} & PWB\_8 & 0.71 &  &  &  & 0.93 & 0.66 & 0.66 \\ 
##   10 & Purpose & =\~{} & Negative & 0.63 &  &  &  & 0.53 & 0.53 & 0.53 \\ 
##   11 & Purpose & =\~{} & Positive & 0.85 &  &  &  & 0.65 & 0.65 & 0.65 \\ 
##   12 & PWB\_1 & \~{}\~{} & PWB\_1 & 1.58 & 0.08 & 18.74 & 0.00 & 1.58 & 0.62 & 0.62 \\ 
##   13 & PWB\_2 & \~{}\~{} & PWB\_2 & 1.47 & 0.08 & 19.47 & 0.00 & 1.47 & 0.71 & 0.71 \\ 
##   14 & PWB\_3 & \~{}\~{} & PWB\_3 & 1.04 & 0.07 & 15.32 & 0.00 & 1.04 & 0.43 & 0.43 \\ 
##   15 & PWB\_4 & \~{}\~{} & PWB\_4 & 1.48 & 0.08 & 19.01 & 0.00 & 1.48 & 0.65 & 0.65 \\ 
##   16 & PWB\_5 & \~{}\~{} & PWB\_5 & 1.05 & 0.07 & 14.92 & 0.00 & 1.05 & 0.42 & 0.42 \\ 
##   17 & PWB\_9 & \~{}\~{} & PWB\_9 & 1.63 & 0.08 & 20.22 & 0.00 & 1.63 & 0.77 & 0.77 \\ 
##   18 & PWB\_6 & \~{}\~{} & PWB\_6 & 1.26 & 0.07 & 16.80 & 0.00 & 1.26 & 0.75 & 0.75 \\ 
##   19 & PWB\_7 & \~{}\~{} & PWB\_7 & 0.86 & 0.08 & 11.21 & 0.00 & 0.86 & 0.51 & 0.51 \\ 
##   20 & PWB\_8 & \~{}\~{} & PWB\_8 & 1.10 & 0.08 & 13.25 & 0.00 & 1.10 & 0.56 & 0.56 \\ 
##   21 & Negative & \~{}\~{} & Negative & 1.00 & 0.00 &  &  & 0.71 & 0.71 & 0.71 \\ 
##   22 & Positive & \~{}\~{} & Positive & 1.00 & 0.00 &  &  & 0.58 & 0.58 & 0.58 \\ 
##   23 & Purpose & \~{}\~{} & Purpose & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   24 & PWB\_1 & \~{}1 &  & 3.86 & 0.05 & 74.45 & 0.00 & 3.86 & 2.42 & 2.42 \\ 
##   25 & PWB\_2 & \~{}1 &  & 3.82 & 0.05 & 81.37 & 0.00 & 3.82 & 2.65 & 2.65 \\ 
##   26 & PWB\_3 & \~{}1 &  & 4.14 & 0.05 & 81.59 & 0.00 & 4.14 & 2.66 & 2.66 \\ 
##   27 & PWB\_4 & \~{}1 &  & 3.97 & 0.05 & 80.85 & 0.00 & 3.97 & 2.63 & 2.63 \\ 
##   28 & PWB\_5 & \~{}1 &  & 2.90 & 0.05 & 55.85 & 0.00 & 2.90 & 1.82 & 1.82 \\ 
##   29 & PWB\_9 & \~{}1 &  & 4.76 & 0.05 & 100.24 & 0.00 & 4.76 & 3.26 & 3.26 \\ 
##   30 & PWB\_6 & \~{}1 &  & 4.47 & 0.04 & 105.70 & 0.00 & 4.47 & 3.44 & 3.44 \\ 
##   31 & PWB\_7 & \~{}1 &  & 4.48 & 0.04 & 105.74 & 0.00 & 4.48 & 3.44 & 3.44 \\ 
##   32 & PWB\_8 & \~{}1 &  & 4.31 & 0.05 & 94.76 & 0.00 & 4.31 & 3.08 & 3.08 \\ 
##   33 & Negative & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   34 & Positive & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   35 & Purpose & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##    \hline
## \end{tabular}
## \end{table}
summary(bifactor1.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-20) converged normally after  53 iterations
## 
##                                                   Used       Total
##   Number of observations                           944        1288
## 
##   Number of missing patterns                         1
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              183.769
##   Degrees of freedom                                18
##   P-value (Chi-square)                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Latent Variables:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   PWB =~                                                                
##     PWB_1             0.854    0.074   11.612    0.000    0.854    0.536
##     PWB_2             0.353    0.094    3.765    0.000    0.353    0.245
##     PWB_3             1.195    0.058   20.615    0.000    1.195    0.767
##     PWB_4             0.717    0.076    9.433    0.000    0.717    0.475
##     PWB_5            -1.218    0.060  -20.420    0.000   -1.218   -0.765
##     PWB_6             0.692    0.049   14.145    0.000    0.692    0.532
##     PWB_7             0.148    0.050    2.950    0.003    0.148    0.113
##     PWB_8             0.176    0.053    3.331    0.001    0.176    0.126
##     PWB_9             0.503    0.086    5.880    0.000    0.503    0.345
##   Negative =~                                                           
##     PWB_1             0.543    0.108    5.029    0.000    0.543    0.341
##     PWB_2             1.240    0.185    6.697    0.000    1.240    0.859
##     PWB_3             0.276    0.117    2.368    0.018    0.276    0.177
##     PWB_4             0.457    0.113    4.055    0.000    0.457    0.303
##     PWB_5            -0.327    0.118   -2.767    0.006   -0.327   -0.206
##     PWB_9             0.493    0.128    3.846    0.000    0.493    0.338
##   Positive =~                                                           
##     PWB_6             0.446    0.045    9.826    0.000    0.446    0.344
##     PWB_7             1.001    0.069   14.561    0.000    1.001    0.768
##     PWB_8             0.893    0.066   13.444    0.000    0.893    0.639
## 
## Covariances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   PWB ~~                                                                
##     Negative          0.000                               0.000    0.000
##     Positive          0.000                               0.000    0.000
##   Negative ~~                                                           
##     Positive          0.000                               0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             3.860    0.052   74.452    0.000    3.860    2.423
##     PWB_2             3.822    0.047   81.370    0.000    3.822    2.648
##     PWB_3             4.138    0.051   81.586    0.000    4.138    2.655
##     PWB_4             3.969    0.049   80.845    0.000    3.969    2.631
##     PWB_5             2.895    0.052   55.850    0.000    2.895    1.818
##     PWB_6             4.469    0.042  105.703    0.000    4.469    3.440
##     PWB_7             4.483    0.042  105.743    0.000    4.483    3.442
##     PWB_8             4.315    0.046   94.758    0.000    4.315    3.084
##     PWB_9             4.761    0.047  100.241    0.000    4.761    3.263
##     PWB               0.000                               0.000    0.000
##     Negative          0.000                               0.000    0.000
##     Positive          0.000                               0.000    0.000
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             1.513    0.081   18.655    0.000    1.513    0.596
##     PWB_2             0.420    0.466    0.900    0.368    0.420    0.202
##     PWB_3             0.923    0.073   12.670    0.000    0.923    0.380
##     PWB_4             1.553    0.079   19.584    0.000    1.553    0.682
##     PWB_5             0.947    0.073   12.918    0.000    0.947    0.373
##     PWB_6             1.010    0.064   15.769    0.000    1.010    0.598
##     PWB_7             0.674    0.121    5.573    0.000    0.674    0.397
##     PWB_8             1.128    0.106   10.633    0.000    1.128    0.576
##     PWB_9             1.633    0.094   17.402    0.000    1.633    0.767
##     PWB               1.000                               1.000    1.000
##     Negative          1.000                               1.000    1.000
##     Positive          1.000                               1.000    1.000
## 
## R-Square:
##                    Estimate
##     PWB_1             0.404
##     PWB_2             0.798
##     PWB_3             0.620
##     PWB_4             0.318
##     PWB_5             0.627
##     PWB_6             0.402
##     PWB_7             0.603
##     PWB_8             0.424
##     PWB_9             0.233
(xtable(parameterEstimates(bifactor1.fit, ci = F, standardized = T,  fmi = F, remove.eq = F, 
                   remove.ineq = F, remove.def = T)))
## % latex table generated in R 3.2.2 by xtable 1.8-0 package
## % Mon Jan 25 12:41:13 2016
## \begin{table}[ht]
## \centering
## \begin{tabular}{rlllrrrrrrr}
##   \hline
##  & lhs & op & rhs & est & se & z & pvalue & std.lv & std.all & std.nox \\ 
##   \hline
## 1 & PWB & =\~{} & PWB\_1 & 0.85 & 0.07 & 11.61 & 0.00 & 0.85 & 0.54 & 0.54 \\ 
##   2 & PWB & =\~{} & PWB\_2 & 0.35 & 0.09 & 3.77 & 0.00 & 0.35 & 0.24 & 0.24 \\ 
##   3 & PWB & =\~{} & PWB\_3 & 1.20 & 0.06 & 20.62 & 0.00 & 1.20 & 0.77 & 0.77 \\ 
##   4 & PWB & =\~{} & PWB\_4 & 0.72 & 0.08 & 9.43 & 0.00 & 0.72 & 0.48 & 0.48 \\ 
##   5 & PWB & =\~{} & PWB\_5 & -1.22 & 0.06 & -20.42 & 0.00 & -1.22 & -0.76 & -0.76 \\ 
##   6 & PWB & =\~{} & PWB\_6 & 0.69 & 0.05 & 14.15 & 0.00 & 0.69 & 0.53 & 0.53 \\ 
##   7 & PWB & =\~{} & PWB\_7 & 0.15 & 0.05 & 2.95 & 0.00 & 0.15 & 0.11 & 0.11 \\ 
##   8 & PWB & =\~{} & PWB\_8 & 0.18 & 0.05 & 3.33 & 0.00 & 0.18 & 0.13 & 0.13 \\ 
##   9 & PWB & =\~{} & PWB\_9 & 0.50 & 0.09 & 5.88 & 0.00 & 0.50 & 0.34 & 0.34 \\ 
##   10 & Negative & =\~{} & PWB\_1 & 0.54 & 0.11 & 5.03 & 0.00 & 0.54 & 0.34 & 0.34 \\ 
##   11 & Negative & =\~{} & PWB\_2 & 1.24 & 0.19 & 6.70 & 0.00 & 1.24 & 0.86 & 0.86 \\ 
##   12 & Negative & =\~{} & PWB\_3 & 0.28 & 0.12 & 2.37 & 0.02 & 0.28 & 0.18 & 0.18 \\ 
##   13 & Negative & =\~{} & PWB\_4 & 0.46 & 0.11 & 4.05 & 0.00 & 0.46 & 0.30 & 0.30 \\ 
##   14 & Negative & =\~{} & PWB\_5 & -0.33 & 0.12 & -2.77 & 0.01 & -0.33 & -0.21 & -0.21 \\ 
##   15 & Negative & =\~{} & PWB\_9 & 0.49 & 0.13 & 3.85 & 0.00 & 0.49 & 0.34 & 0.34 \\ 
##   16 & Positive & =\~{} & PWB\_6 & 0.45 & 0.05 & 9.83 & 0.00 & 0.45 & 0.34 & 0.34 \\ 
##   17 & Positive & =\~{} & PWB\_7 & 1.00 & 0.07 & 14.56 & 0.00 & 1.00 & 0.77 & 0.77 \\ 
##   18 & Positive & =\~{} & PWB\_8 & 0.89 & 0.07 & 13.44 & 0.00 & 0.89 & 0.64 & 0.64 \\ 
##   19 & PWB & \~{}\~{} & Negative & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   20 & PWB & \~{}\~{} & Positive & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   21 & Negative & \~{}\~{} & Positive & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   22 & PWB\_1 & \~{}\~{} & PWB\_1 & 1.51 & 0.08 & 18.65 & 0.00 & 1.51 & 0.60 & 0.60 \\ 
##   23 & PWB\_2 & \~{}\~{} & PWB\_2 & 0.42 & 0.47 & 0.90 & 0.37 & 0.42 & 0.20 & 0.20 \\ 
##   24 & PWB\_3 & \~{}\~{} & PWB\_3 & 0.92 & 0.07 & 12.67 & 0.00 & 0.92 & 0.38 & 0.38 \\ 
##   25 & PWB\_4 & \~{}\~{} & PWB\_4 & 1.55 & 0.08 & 19.58 & 0.00 & 1.55 & 0.68 & 0.68 \\ 
##   26 & PWB\_5 & \~{}\~{} & PWB\_5 & 0.95 & 0.07 & 12.92 & 0.00 & 0.95 & 0.37 & 0.37 \\ 
##   27 & PWB\_6 & \~{}\~{} & PWB\_6 & 1.01 & 0.06 & 15.77 & 0.00 & 1.01 & 0.60 & 0.60 \\ 
##   28 & PWB\_7 & \~{}\~{} & PWB\_7 & 0.67 & 0.12 & 5.57 & 0.00 & 0.67 & 0.40 & 0.40 \\ 
##   29 & PWB\_8 & \~{}\~{} & PWB\_8 & 1.13 & 0.11 & 10.63 & 0.00 & 1.13 & 0.58 & 0.58 \\ 
##   30 & PWB\_9 & \~{}\~{} & PWB\_9 & 1.63 & 0.09 & 17.40 & 0.00 & 1.63 & 0.77 & 0.77 \\ 
##   31 & PWB & \~{}\~{} & PWB & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   32 & Negative & \~{}\~{} & Negative & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   33 & Positive & \~{}\~{} & Positive & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   34 & PWB\_1 & \~{}1 &  & 3.86 & 0.05 & 74.45 & 0.00 & 3.86 & 2.42 & 2.42 \\ 
##   35 & PWB\_2 & \~{}1 &  & 3.82 & 0.05 & 81.37 & 0.00 & 3.82 & 2.65 & 2.65 \\ 
##   36 & PWB\_3 & \~{}1 &  & 4.14 & 0.05 & 81.59 & 0.00 & 4.14 & 2.66 & 2.66 \\ 
##   37 & PWB\_4 & \~{}1 &  & 3.97 & 0.05 & 80.85 & 0.00 & 3.97 & 2.63 & 2.63 \\ 
##   38 & PWB\_5 & \~{}1 &  & 2.90 & 0.05 & 55.85 & 0.00 & 2.90 & 1.82 & 1.82 \\ 
##   39 & PWB\_6 & \~{}1 &  & 4.47 & 0.04 & 105.70 & 0.00 & 4.47 & 3.44 & 3.44 \\ 
##   40 & PWB\_7 & \~{}1 &  & 4.48 & 0.04 & 105.74 & 0.00 & 4.48 & 3.44 & 3.44 \\ 
##   41 & PWB\_8 & \~{}1 &  & 4.31 & 0.05 & 94.76 & 0.00 & 4.31 & 3.08 & 3.08 \\ 
##   42 & PWB\_9 & \~{}1 &  & 4.76 & 0.05 & 100.24 & 0.00 & 4.76 & 3.26 & 3.26 \\ 
##   43 & PWB & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   44 & Negative & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   45 & Positive & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##    \hline
## \end{tabular}
## \end{table}
summary(bifactor2.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-20) converged normally after  46 iterations
## 
##                                                   Used       Total
##   Number of observations                           944        1288
## 
##   Number of missing patterns                         1
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              236.692
##   Degrees of freedom                                18
##   P-value (Chi-square)                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Latent Variables:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   PWB =~                                                                
##     PWB_1             0.913    0.060   15.187    0.000    0.913    0.573
##     PWB_2             0.857    0.055   15.647    0.000    0.857    0.594
##     PWB_3             1.018    0.060   17.031    0.000    1.018    0.653
##     PWB_4             0.939    0.054   17.383    0.000    0.939    0.623
##     PWB_5            -1.031    0.061  -16.954    0.000   -1.031   -0.648
##     PWB_6             0.379    0.056    6.731    0.000    0.379    0.292
##     PWB_7             0.139    0.054    2.555    0.011    0.139    0.107
##     PWB_8             0.174    0.057    3.041    0.002    0.174    0.125
##     PWB_9             0.757    0.055   13.795    0.000    0.757    0.519
##   F1 =~                                                                 
##     PWB_1             0.415    0.076    5.455    0.000    0.415    0.260
##     PWB_3             0.634    0.075    8.471    0.000    0.634    0.407
##     PWB_5            -0.733    0.080   -9.188    0.000   -0.733   -0.460
##     PWB_6             0.669    0.080    8.376    0.000    0.669    0.515
##   F2 =~                                                                 
##     PWB_4             0.422    0.056    7.513    0.000    0.422    0.280
##     PWB_7             1.096    0.089   12.326    0.000    1.096    0.842
##     PWB_8             0.817    0.075   10.907    0.000    0.817    0.584
##   F3 =~                                                                 
##     PWB_2             0.261       NA                      0.261    0.181
##     PWB_9             0.481       NA                      0.481    0.329
## 
## Covariances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   PWB ~~                                                                
##     F1                0.000                               0.000    0.000
##     F2                0.000                               0.000    0.000
##     F3                0.000                               0.000    0.000
##   F1 ~~                                                                 
##     F2                0.000                               0.000    0.000
##     F3                0.000                               0.000    0.000
##   F2 ~~                                                                 
##     F3                0.000                               0.000    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             3.860    0.052   74.452    0.000    3.860    2.423
##     PWB_2             3.822    0.047   81.370    0.000    3.822    2.648
##     PWB_3             4.138    0.051   81.586    0.000    4.138    2.655
##     PWB_4             3.969    0.049   80.845    0.000    3.969    2.631
##     PWB_5             2.895    0.052   55.850    0.000    2.895    1.818
##     PWB_6             4.469    0.042  105.703    0.000    4.469    3.440
##     PWB_7             4.483    0.042  105.743    0.000    4.483    3.442
##     PWB_8             4.315    0.046   94.758    0.000    4.315    3.084
##     PWB_9             4.761    0.047  100.241    0.000    4.761    3.263
##     PWB               0.000                               0.000    0.000
##     F1                0.000                               0.000    0.000
##     F2                0.000                               0.000    0.000
##     F3                0.000                               0.000    0.000
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             1.533    0.082   18.721    0.000    1.533    0.604
##     PWB_2             1.280       NA                      1.280    0.614
##     PWB_3             0.990    0.066   14.912    0.000    0.990    0.408
##     PWB_4             1.215    0.079   15.406    0.000    1.215    0.534
##     PWB_5             0.936    0.075   12.422    0.000    0.936    0.369
##     PWB_6             1.097    0.092   11.910    0.000    1.097    0.650
##     PWB_7             0.476    0.181    2.629    0.009    0.476    0.280
##     PWB_8             1.259    0.114   11.058    0.000    1.259    0.643
##     PWB_9             1.326       NA                      1.326    0.623
##     PWB               1.000                               1.000    1.000
##     F1                1.000                               1.000    1.000
##     F2                1.000                               1.000    1.000
##     F3                1.000                               1.000    1.000
## 
## R-Square:
##                    Estimate
##     PWB_1             0.396
##     PWB_2             0.386
##     PWB_3             0.592
##     PWB_4             0.466
##     PWB_5             0.631
##     PWB_6             0.350
##     PWB_7             0.720
##     PWB_8             0.357
##     PWB_9             0.377
(xtable(parameterEstimates(bifactor2.fit, ci = F, standardized = T,  fmi = F, remove.eq = F, 
                   remove.ineq = F, remove.def = T)))
## % latex table generated in R 3.2.2 by xtable 1.8-0 package
## % Mon Jan 25 12:41:13 2016
## \begin{table}[ht]
## \centering
## \begin{tabular}{rlllrrrrrrr}
##   \hline
##  & lhs & op & rhs & est & se & z & pvalue & std.lv & std.all & std.nox \\ 
##   \hline
## 1 & PWB & =\~{} & PWB\_1 & 0.91 & 0.06 & 15.19 & 0.00 & 0.91 & 0.57 & 0.57 \\ 
##   2 & PWB & =\~{} & PWB\_2 & 0.86 & 0.05 & 15.65 & 0.00 & 0.86 & 0.59 & 0.59 \\ 
##   3 & PWB & =\~{} & PWB\_3 & 1.02 & 0.06 & 17.03 & 0.00 & 1.02 & 0.65 & 0.65 \\ 
##   4 & PWB & =\~{} & PWB\_4 & 0.94 & 0.05 & 17.38 & 0.00 & 0.94 & 0.62 & 0.62 \\ 
##   5 & PWB & =\~{} & PWB\_5 & -1.03 & 0.06 & -16.95 & 0.00 & -1.03 & -0.65 & -0.65 \\ 
##   6 & PWB & =\~{} & PWB\_6 & 0.38 & 0.06 & 6.73 & 0.00 & 0.38 & 0.29 & 0.29 \\ 
##   7 & PWB & =\~{} & PWB\_7 & 0.14 & 0.05 & 2.56 & 0.01 & 0.14 & 0.11 & 0.11 \\ 
##   8 & PWB & =\~{} & PWB\_8 & 0.17 & 0.06 & 3.04 & 0.00 & 0.17 & 0.12 & 0.12 \\ 
##   9 & PWB & =\~{} & PWB\_9 & 0.76 & 0.05 & 13.79 & 0.00 & 0.76 & 0.52 & 0.52 \\ 
##   10 & F1 & =\~{} & PWB\_1 & 0.41 & 0.08 & 5.45 & 0.00 & 0.41 & 0.26 & 0.26 \\ 
##   11 & F1 & =\~{} & PWB\_3 & 0.63 & 0.07 & 8.47 & 0.00 & 0.63 & 0.41 & 0.41 \\ 
##   12 & F1 & =\~{} & PWB\_5 & -0.73 & 0.08 & -9.19 & 0.00 & -0.73 & -0.46 & -0.46 \\ 
##   13 & F1 & =\~{} & PWB\_6 & 0.67 & 0.08 & 8.38 & 0.00 & 0.67 & 0.51 & 0.51 \\ 
##   14 & F2 & =\~{} & PWB\_4 & 0.42 & 0.06 & 7.51 & 0.00 & 0.42 & 0.28 & 0.28 \\ 
##   15 & F2 & =\~{} & PWB\_7 & 1.10 & 0.09 & 12.33 & 0.00 & 1.10 & 0.84 & 0.84 \\ 
##   16 & F2 & =\~{} & PWB\_8 & 0.82 & 0.07 & 10.91 & 0.00 & 0.82 & 0.58 & 0.58 \\ 
##   17 & F3 & =\~{} & PWB\_2 & 0.26 &  &  &  & 0.26 & 0.18 & 0.18 \\ 
##   18 & F3 & =\~{} & PWB\_9 & 0.48 &  &  &  & 0.48 & 0.33 & 0.33 \\ 
##   19 & PWB & \~{}\~{} & F1 & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   20 & PWB & \~{}\~{} & F2 & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   21 & PWB & \~{}\~{} & F3 & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   22 & F1 & \~{}\~{} & F2 & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   23 & F1 & \~{}\~{} & F3 & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   24 & F2 & \~{}\~{} & F3 & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   25 & PWB\_1 & \~{}\~{} & PWB\_1 & 1.53 & 0.08 & 18.72 & 0.00 & 1.53 & 0.60 & 0.60 \\ 
##   26 & PWB\_2 & \~{}\~{} & PWB\_2 & 1.28 &  &  &  & 1.28 & 0.61 & 0.61 \\ 
##   27 & PWB\_3 & \~{}\~{} & PWB\_3 & 0.99 & 0.07 & 14.91 & 0.00 & 0.99 & 0.41 & 0.41 \\ 
##   28 & PWB\_4 & \~{}\~{} & PWB\_4 & 1.22 & 0.08 & 15.41 & 0.00 & 1.22 & 0.53 & 0.53 \\ 
##   29 & PWB\_5 & \~{}\~{} & PWB\_5 & 0.94 & 0.08 & 12.42 & 0.00 & 0.94 & 0.37 & 0.37 \\ 
##   30 & PWB\_6 & \~{}\~{} & PWB\_6 & 1.10 & 0.09 & 11.91 & 0.00 & 1.10 & 0.65 & 0.65 \\ 
##   31 & PWB\_7 & \~{}\~{} & PWB\_7 & 0.48 & 0.18 & 2.63 & 0.01 & 0.48 & 0.28 & 0.28 \\ 
##   32 & PWB\_8 & \~{}\~{} & PWB\_8 & 1.26 & 0.11 & 11.06 & 0.00 & 1.26 & 0.64 & 0.64 \\ 
##   33 & PWB\_9 & \~{}\~{} & PWB\_9 & 1.33 &  &  &  & 1.33 & 0.62 & 0.62 \\ 
##   34 & PWB & \~{}\~{} & PWB & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   35 & F1 & \~{}\~{} & F1 & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   36 & F2 & \~{}\~{} & F2 & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   37 & F3 & \~{}\~{} & F3 & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   38 & PWB\_1 & \~{}1 &  & 3.86 & 0.05 & 74.45 & 0.00 & 3.86 & 2.42 & 2.42 \\ 
##   39 & PWB\_2 & \~{}1 &  & 3.82 & 0.05 & 81.37 & 0.00 & 3.82 & 2.65 & 2.65 \\ 
##   40 & PWB\_3 & \~{}1 &  & 4.14 & 0.05 & 81.59 & 0.00 & 4.14 & 2.66 & 2.66 \\ 
##   41 & PWB\_4 & \~{}1 &  & 3.97 & 0.05 & 80.85 & 0.00 & 3.97 & 2.63 & 2.63 \\ 
##   42 & PWB\_5 & \~{}1 &  & 2.90 & 0.05 & 55.85 & 0.00 & 2.90 & 1.82 & 1.82 \\ 
##   43 & PWB\_6 & \~{}1 &  & 4.47 & 0.04 & 105.70 & 0.00 & 4.47 & 3.44 & 3.44 \\ 
##   44 & PWB\_7 & \~{}1 &  & 4.48 & 0.04 & 105.74 & 0.00 & 4.48 & 3.44 & 3.44 \\ 
##   45 & PWB\_8 & \~{}1 &  & 4.31 & 0.05 & 94.76 & 0.00 & 4.31 & 3.08 & 3.08 \\ 
##   46 & PWB\_9 & \~{}1 &  & 4.76 & 0.05 & 100.24 & 0.00 & 4.76 & 3.26 & 3.26 \\ 
##   47 & PWB & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   48 & F1 & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   49 & F2 & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   50 & F3 & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##    \hline
## \end{tabular}
## \end{table}
summary(bifactor.negative.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-20) converged normally after  32 iterations
## 
##                                                   Used       Total
##   Number of observations                           944        1288
## 
##   Number of missing patterns                         1
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic              357.805
##   Degrees of freedom                                20
##   P-value (Chi-square)                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Latent Variables:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   Negative =~                                                           
##     PWB_1             1.373   25.379    0.054    0.957    1.373    0.862
##     PWB_2             0.969   17.923    0.054    0.957    0.969    0.672
##     PWB_3             1.493   27.601    0.054    0.957    1.493    0.958
##     PWB_4             0.962   17.783    0.054    0.957    0.962    0.638
##     PWB_5            -1.535   28.388   -0.054    0.957   -1.535   -0.964
##     PWB_9             0.886   16.380    0.054    0.957    0.886    0.607
##   PWB =~                                                                
##     PWB_1             0.949   38.938    0.024    0.981    0.949    0.596
##     PWB_2             0.910   27.499    0.033    0.974    0.910    0.631
##     PWB_3             1.286   42.347    0.030    0.976    1.286    0.825
##     PWB_4             1.250   27.283    0.046    0.963    1.250    0.828
##     PWB_5            -1.348   43.554   -0.031    0.975   -1.348   -0.846
##     PWB_6             0.569    0.051   11.216    0.000    0.569    0.438
##     PWB_7             0.994    0.052   19.087    0.000    0.994    0.763
##     PWB_8             0.913    0.052   17.517    0.000    0.913    0.653
##     PWB_9             0.789   25.132    0.031    0.975    0.789    0.541
## 
## Covariances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   Negative ~~                                                           
##     PWB              -0.652   16.316   -0.040    0.968   -0.652   -0.652
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             3.860    0.052   74.452    0.000    3.860    2.423
##     PWB_2             3.822    0.047   81.370    0.000    3.822    2.648
##     PWB_3             4.138    0.051   81.586    0.000    4.138    2.655
##     PWB_4             3.969    0.049   80.845    0.000    3.969    2.631
##     PWB_5             2.895    0.052   55.850    0.000    2.895    1.818
##     PWB_9             4.761    0.047  100.241    0.000    4.761    3.263
##     PWB_6             4.469    0.042  105.703    0.000    4.469    3.440
##     PWB_7             4.483    0.042  105.743    0.000    4.483    3.442
##     PWB_8             4.315    0.046   94.758    0.000    4.315    3.084
##     Negative          0.000                               0.000    0.000
##     PWB               0.000                               0.000    0.000
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     PWB_1             1.451    0.084   17.188    0.000    1.451    0.572
##     PWB_2             1.465    0.075   19.498    0.000    1.465    0.703
##     PWB_3             1.048    0.069   15.134    0.000    1.048    0.432
##     PWB_4             1.356    0.073   18.604    0.000    1.356    0.596
##     PWB_5             1.060    0.071   14.943    0.000    1.060    0.418
##     PWB_9             1.633    0.081   20.236    0.000    1.633    0.767
##     PWB_6             1.364    0.072   18.957    0.000    1.364    0.808
##     PWB_7             0.708    0.082    8.607    0.000    0.708    0.417
##     PWB_8             1.123    0.079   14.159    0.000    1.123    0.574
##     Negative          1.000                               1.000    1.000
##     PWB               1.000                               1.000    1.000
## 
## R-Square:
##                    Estimate
##     PWB_1             0.428
##     PWB_2             0.297
##     PWB_3             0.568
##     PWB_4             0.404
##     PWB_5             0.582
##     PWB_9             0.233
##     PWB_6             0.192
##     PWB_7             0.583
##     PWB_8             0.426
(xtable(parameterEstimates(bifactor.negative.fit, ci = F, standardized = T,  fmi = F, remove.eq = F, 
                   remove.ineq = F, remove.def = T)))
## % latex table generated in R 3.2.2 by xtable 1.8-0 package
## % Mon Jan 25 12:41:13 2016
## \begin{table}[ht]
## \centering
## \begin{tabular}{rlllrrrrrrr}
##   \hline
##  & lhs & op & rhs & est & se & z & pvalue & std.lv & std.all & std.nox \\ 
##   \hline
## 1 & Negative & =\~{} & PWB\_1 & 1.37 & 25.38 & 0.05 & 0.96 & 1.37 & 0.86 & 0.86 \\ 
##   2 & Negative & =\~{} & PWB\_2 & 0.97 & 17.92 & 0.05 & 0.96 & 0.97 & 0.67 & 0.67 \\ 
##   3 & Negative & =\~{} & PWB\_3 & 1.49 & 27.60 & 0.05 & 0.96 & 1.49 & 0.96 & 0.96 \\ 
##   4 & Negative & =\~{} & PWB\_4 & 0.96 & 17.78 & 0.05 & 0.96 & 0.96 & 0.64 & 0.64 \\ 
##   5 & Negative & =\~{} & PWB\_5 & -1.54 & 28.39 & -0.05 & 0.96 & -1.54 & -0.96 & -0.96 \\ 
##   6 & Negative & =\~{} & PWB\_9 & 0.89 & 16.38 & 0.05 & 0.96 & 0.89 & 0.61 & 0.61 \\ 
##   7 & PWB & =\~{} & PWB\_1 & 0.95 & 38.94 & 0.02 & 0.98 & 0.95 & 0.60 & 0.60 \\ 
##   8 & PWB & =\~{} & PWB\_2 & 0.91 & 27.50 & 0.03 & 0.97 & 0.91 & 0.63 & 0.63 \\ 
##   9 & PWB & =\~{} & PWB\_3 & 1.29 & 42.35 & 0.03 & 0.98 & 1.29 & 0.83 & 0.83 \\ 
##   10 & PWB & =\~{} & PWB\_4 & 1.25 & 27.28 & 0.05 & 0.96 & 1.25 & 0.83 & 0.83 \\ 
##   11 & PWB & =\~{} & PWB\_5 & -1.35 & 43.55 & -0.03 & 0.98 & -1.35 & -0.85 & -0.85 \\ 
##   12 & PWB & =\~{} & PWB\_6 & 0.57 & 0.05 & 11.22 & 0.00 & 0.57 & 0.44 & 0.44 \\ 
##   13 & PWB & =\~{} & PWB\_7 & 0.99 & 0.05 & 19.09 & 0.00 & 0.99 & 0.76 & 0.76 \\ 
##   14 & PWB & =\~{} & PWB\_8 & 0.91 & 0.05 & 17.52 & 0.00 & 0.91 & 0.65 & 0.65 \\ 
##   15 & PWB & =\~{} & PWB\_9 & 0.79 & 25.13 & 0.03 & 0.97 & 0.79 & 0.54 & 0.54 \\ 
##   16 & PWB\_1 & \~{}\~{} & PWB\_1 & 1.45 & 0.08 & 17.19 & 0.00 & 1.45 & 0.57 & 0.57 \\ 
##   17 & PWB\_2 & \~{}\~{} & PWB\_2 & 1.46 & 0.08 & 19.50 & 0.00 & 1.46 & 0.70 & 0.70 \\ 
##   18 & PWB\_3 & \~{}\~{} & PWB\_3 & 1.05 & 0.07 & 15.13 & 0.00 & 1.05 & 0.43 & 0.43 \\ 
##   19 & PWB\_4 & \~{}\~{} & PWB\_4 & 1.36 & 0.07 & 18.60 & 0.00 & 1.36 & 0.60 & 0.60 \\ 
##   20 & PWB\_5 & \~{}\~{} & PWB\_5 & 1.06 & 0.07 & 14.94 & 0.00 & 1.06 & 0.42 & 0.42 \\ 
##   21 & PWB\_9 & \~{}\~{} & PWB\_9 & 1.63 & 0.08 & 20.24 & 0.00 & 1.63 & 0.77 & 0.77 \\ 
##   22 & PWB\_6 & \~{}\~{} & PWB\_6 & 1.36 & 0.07 & 18.96 & 0.00 & 1.36 & 0.81 & 0.81 \\ 
##   23 & PWB\_7 & \~{}\~{} & PWB\_7 & 0.71 & 0.08 & 8.61 & 0.00 & 0.71 & 0.42 & 0.42 \\ 
##   24 & PWB\_8 & \~{}\~{} & PWB\_8 & 1.12 & 0.08 & 14.16 & 0.00 & 1.12 & 0.57 & 0.57 \\ 
##   25 & Negative & \~{}\~{} & Negative & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   26 & PWB & \~{}\~{} & PWB & 1.00 & 0.00 &  &  & 1.00 & 1.00 & 1.00 \\ 
##   27 & Negative & \~{}\~{} & PWB & -0.65 & 16.32 & -0.04 & 0.97 & -0.65 & -0.65 & -0.65 \\ 
##   28 & PWB\_1 & \~{}1 &  & 3.86 & 0.05 & 74.45 & 0.00 & 3.86 & 2.42 & 2.42 \\ 
##   29 & PWB\_2 & \~{}1 &  & 3.82 & 0.05 & 81.37 & 0.00 & 3.82 & 2.65 & 2.65 \\ 
##   30 & PWB\_3 & \~{}1 &  & 4.14 & 0.05 & 81.59 & 0.00 & 4.14 & 2.66 & 2.66 \\ 
##   31 & PWB\_4 & \~{}1 &  & 3.97 & 0.05 & 80.85 & 0.00 & 3.97 & 2.63 & 2.63 \\ 
##   32 & PWB\_5 & \~{}1 &  & 2.90 & 0.05 & 55.85 & 0.00 & 2.90 & 1.82 & 1.82 \\ 
##   33 & PWB\_9 & \~{}1 &  & 4.76 & 0.05 & 100.24 & 0.00 & 4.76 & 3.26 & 3.26 \\ 
##   34 & PWB\_6 & \~{}1 &  & 4.47 & 0.04 & 105.70 & 0.00 & 4.47 & 3.44 & 3.44 \\ 
##   35 & PWB\_7 & \~{}1 &  & 4.48 & 0.04 & 105.74 & 0.00 & 4.48 & 3.44 & 3.44 \\ 
##   36 & PWB\_8 & \~{}1 &  & 4.31 & 0.05 & 94.76 & 0.00 & 4.31 & 3.08 & 3.08 \\ 
##   37 & Negative & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##   38 & PWB & \~{}1 &  & 0.00 & 0.00 &  &  & 0.00 & 0.00 & 0.00 \\ 
##    \hline
## \end{tabular}
## \end{table}
?parameterEstimates

Residual correlations

correl = residuals(two.fit, type="cor")
correl
## $type
## [1] "cor.bollen"
## 
## $cor
##       PWB_1  PWB_3  PWB_4  PWB_5  PWB_6  PWB_9  PWB_2  PWB_7  PWB_8 
## PWB_1  0.000                                                        
## PWB_3  0.001  0.000                                                 
## PWB_4 -0.041  0.018  0.000                                          
## PWB_5 -0.018 -0.006  0.033  0.000                                   
## PWB_6  0.021 -0.006 -0.031 -0.011  0.000                            
## PWB_9  0.030 -0.011  0.071 -0.007 -0.124  0.000                     
## PWB_2  0.386  0.277  0.334 -0.302  0.106  0.334  0.000              
## PWB_7 -0.175 -0.096  0.176  0.070  0.209 -0.014 -0.040  0.000       
## PWB_8 -0.138 -0.071  0.118  0.068  0.174  0.001 -0.050  0.017  0.000
## 
## $mean
## PWB_1 PWB_3 PWB_4 PWB_5 PWB_6 PWB_9 PWB_2 PWB_7 PWB_8 
##     0     0     0     0     0     0     0     0     0
View(correl$cor)
correl1 = residuals(one.fit, type="cor")
correl1
## $type
## [1] "cor.bollen"
## 
## $cor
##       PWB_1  PWB_2  PWB_3  PWB_4  PWB_5  PWB_6  PWB_7  PWB_8  PWB_9 
## PWB_1  0.000                                                        
## PWB_2  0.113  0.000                                                 
## PWB_3  0.000 -0.058  0.000                                          
## PWB_4 -0.065  0.072  0.012  0.000                                   
## PWB_5 -0.014  0.039 -0.033  0.041  0.000                            
## PWB_6  0.020 -0.117  0.015 -0.034 -0.030  0.000                     
## PWB_7 -0.170  0.024 -0.081  0.179  0.056  0.219  0.000              
## PWB_8 -0.134  0.011 -0.058  0.120  0.055  0.183  0.462  0.000       
## PWB_9  0.007  0.126 -0.021  0.047  0.005 -0.131 -0.013  0.001  0.000
## 
## $mean
## PWB_1 PWB_2 PWB_3 PWB_4 PWB_5 PWB_6 PWB_7 PWB_8 PWB_9 
##     0     0     0     0     0     0     0     0     0
View(correl1$cor)
correl0 = residuals(second.fit, type="cor")
correl0
## $type
## [1] "cor.bollen"
## 
## $cor
##       PWB_1  PWB_2  PWB_3  PWB_4  PWB_5  PWB_9  PWB_6  PWB_7  PWB_8 
## PWB_1  0.000                                                        
## PWB_2  0.098  0.000                                                 
## PWB_3 -0.001 -0.072  0.000                                          
## PWB_4 -0.069  0.058  0.012  0.000                                   
## PWB_5 -0.016  0.051 -0.041  0.040  0.000                            
## PWB_9 -0.008  0.105 -0.036  0.033  0.018  0.000                     
## PWB_6  0.222  0.052  0.265  0.159 -0.285  0.018  0.000              
## PWB_7 -0.192  0.001 -0.107  0.159  0.080 -0.034 -0.029  0.000       
## PWB_8 -0.150 -0.006 -0.076  0.105  0.072 -0.015 -0.048  0.040  0.000
## 
## $mean
## PWB_1 PWB_2 PWB_3 PWB_4 PWB_5 PWB_9 PWB_6 PWB_7 PWB_8 
##     0     0     0     0     0     0     0     0     0
View(correl0$cor)
correl4 = residuals(bifactor1.fit, type="cor")
correl4
## $type
## [1] "cor.bollen"
## 
## $cor
##       PWB_1  PWB_2  PWB_3  PWB_4  PWB_5  PWB_6  PWB_7  PWB_8  PWB_9 
## PWB_1  0.000                                                        
## PWB_2  0.008  0.000                                                 
## PWB_3 -0.008 -0.003  0.000                                          
## PWB_4 -0.064  0.001  0.039  0.000                                   
## PWB_5 -0.006  0.001  0.005  0.014  0.000                            
## PWB_6  0.044  0.016 -0.011  0.009 -0.011  0.000                     
## PWB_7 -0.103  0.105 -0.010  0.248 -0.019  0.000  0.000              
## PWB_8 -0.076  0.088  0.001  0.181 -0.007  0.000  0.000  0.000       
## PWB_9 -0.010 -0.007  0.005  0.052 -0.019 -0.081  0.044  0.053  0.000
## 
## $mean
## PWB_1 PWB_2 PWB_3 PWB_4 PWB_5 PWB_6 PWB_7 PWB_8 PWB_9 
##     0     0     0     0     0     0     0     0     0
View(correl4$cor)
correl5 = residuals(bifactor2.fit, type="cor")
correl5
## $type
## [1] "cor.bollen"
## 
## $cor
##       PWB_1  PWB_2  PWB_3  PWB_4  PWB_5  PWB_6  PWB_7  PWB_8  PWB_9 
## PWB_1  0.000                                                        
## PWB_2  0.092  0.000                                                 
## PWB_3 -0.017 -0.051  0.000                                          
## PWB_4 -0.062  0.008  0.050  0.000                                   
## PWB_5  0.004  0.022 -0.008 -0.008  0.000                            
## PWB_6  0.028 -0.027 -0.003  0.080  0.007  0.000                     
## PWB_7 -0.104  0.070  0.007  0.000 -0.036  0.293  0.000              
## PWB_8 -0.080  0.044  0.016  0.000 -0.023  0.250  0.000  0.000       
## PWB_9 -0.007  0.000 -0.009 -0.005 -0.016 -0.049  0.028  0.032  0.000
## 
## $mean
## PWB_1 PWB_2 PWB_3 PWB_4 PWB_5 PWB_6 PWB_7 PWB_8 PWB_9 
##     0     0     0     0     0     0     0     0     0
correl3 = residuals(bifactor.negative.fit, type="cor")
correl3
## $type
## [1] "cor.bollen"
## 
## $cor
##       PWB_1  PWB_2  PWB_3  PWB_4  PWB_5  PWB_9  PWB_6  PWB_7  PWB_8 
## PWB_1  0.000                                                        
## PWB_2  0.092  0.000                                                 
## PWB_3 -0.018 -0.072  0.000                                          
## PWB_4 -0.036  0.052  0.023  0.000                                   
## PWB_5 -0.001  0.052 -0.043  0.032  0.000                            
## PWB_9 -0.016  0.105 -0.034  0.036  0.017  0.000                     
## PWB_6  0.314  0.062  0.309  0.081 -0.323  0.039  0.000              
## PWB_7 -0.068 -0.014 -0.077 -0.013  0.061 -0.028 -0.010  0.000       
## PWB_8 -0.031 -0.007 -0.033 -0.028  0.039  0.002  0.001  0.007  0.000
## 
## $mean
## PWB_1 PWB_2 PWB_3 PWB_4 PWB_5 PWB_9 PWB_6 PWB_7 PWB_8 
##     0     0     0     0     0     0     0     0     0
View(correl3$cor)

Modification indicies

#modindices(two.fit, sort. = TRUE, minimum.value = 3.84)
#modindices(one.fit, sort. = TRUE, minimum.value = 3.84)
#modindices(bifactor1.fit, sort. = TRUE, minimum.value = 3.84)
#modindices(bifactor.negative.fit, sort. = TRUE, minimum.value = 3.84)

Fit Measures

fitmeasures(two.fit)#Models two factors:Positive and Negative for Purpose  
##                npar                fmin               chisq 
##              28.000               0.311             587.190 
##                  df              pvalue      baseline.chisq 
##              26.000               0.000            2337.145 
##         baseline.df     baseline.pvalue                 cfi 
##              36.000               0.000               0.756 
##                 tli                nnfi                 rfi 
##               0.662               0.662               0.652 
##                 nfi                pnfi                 ifi 
##               0.749               0.541               0.757 
##                 rni                logl   unrestricted.logl 
##               0.756          -14382.524          -14088.929 
##                 aic                 bic              ntotal 
##           28821.048           28956.852             944.000 
##                bic2               rmsea      rmsea.ci.lower 
##           28867.925               0.151               0.141 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.162               0.000               0.258 
##          rmr_nomean                srmr        srmr_bentler 
##               0.283               0.120               0.120 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.131               0.120               0.131 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.120               0.131              63.514 
##               cn_01                 gfi                agfi 
##              74.376               0.993               0.985 
##                pgfi                 mfi                ecvi 
##               0.478               0.743                  NA
fitmeasures(one.fit) #Models as a single purpose factor
##                npar                fmin               chisq 
##              27.000               0.341             643.119 
##                  df              pvalue      baseline.chisq 
##              27.000               0.000            2337.145 
##         baseline.df     baseline.pvalue                 cfi 
##              36.000               0.000               0.732 
##                 tli                nnfi                 rfi 
##               0.643               0.643               0.633 
##                 nfi                pnfi                 ifi 
##               0.725               0.544               0.733 
##                 rni                logl   unrestricted.logl 
##               0.732          -14410.488          -14088.929 
##                 aic                 bic              ntotal 
##           28874.977           29005.930             944.000 
##                bic2               rmsea      rmsea.ci.lower 
##           28920.180               0.155               0.145 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.166               0.000               0.182 
##          rmr_nomean                srmr        srmr_bentler 
##               0.200               0.095               0.095 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.104               0.095               0.104 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.095               0.104              59.880 
##               cn_01                 gfi                agfi 
##              69.934               0.991               0.982 
##                pgfi                 mfi                ecvi 
##               0.496               0.722                  NA
fitmeasures(second.fit)#Second order models as Purpose being the higher factor made up of Purpose and Positive
##                npar                fmin               chisq 
##              29.000               0.235             442.762 
##                  df              pvalue      baseline.chisq 
##              25.000               0.000            2337.145 
##         baseline.df     baseline.pvalue                 cfi 
##              36.000               0.000               0.818 
##                 tli                nnfi                 rfi 
##               0.739               0.739               0.727 
##                 nfi                pnfi                 ifi 
##               0.811               0.563               0.819 
##                 rni                logl   unrestricted.logl 
##               0.818          -14310.310          -14088.929 
##                 aic                 bic              ntotal 
##           28678.620           28819.273             944.000 
##                bic2               rmsea      rmsea.ci.lower 
##           28727.171               0.133               0.122 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.144               0.000               0.179 
##          rmr_nomean                srmr        srmr_bentler 
##               0.197               0.086               0.086 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.095               0.086               0.095 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.086               0.095              81.278 
##               cn_01                 gfi                agfi 
##              95.481               0.993               0.985 
##                pgfi                 mfi                ecvi 
##               0.460               0.801                  NA
fitmeasures(bifactor1.fit)#Models bifactor with Positive and Purpose as factors uncorolated with the main factor
##                npar                fmin               chisq 
##              36.000               0.097             183.769 
##                  df              pvalue      baseline.chisq 
##              18.000               0.000            2337.145 
##         baseline.df     baseline.pvalue                 cfi 
##              36.000               0.000               0.928 
##                 tli                nnfi                 rfi 
##               0.856               0.856               0.843 
##                 nfi                pnfi                 ifi 
##               0.921               0.461               0.929 
##                 rni                logl   unrestricted.logl 
##               0.928          -14180.814          -14088.929 
##                 aic                 bic              ntotal 
##           28433.627           28608.232             944.000 
##                bic2               rmsea      rmsea.ci.lower 
##           28493.898               0.099               0.086 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.112               0.000               0.108 
##          rmr_nomean                srmr        srmr_bentler 
##               0.119               0.053               0.053 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.058               0.053               0.058 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.053               0.058             149.298 
##               cn_01                 gfi                agfi 
##             179.790               0.997               0.992 
##                pgfi                 mfi                ecvi 
##               0.332               0.916                  NA
fitmeasures(bifactor2.fit)#Models bifactor with Positive and Purpose as factors uncorolated with the main factor
##                npar                fmin               chisq 
##              36.000               0.125             236.692 
##                  df              pvalue      baseline.chisq 
##              18.000               0.000            2337.145 
##         baseline.df     baseline.pvalue                 cfi 
##              36.000               0.000               0.905 
##                 tli                nnfi                 rfi 
##               0.810               0.810               0.797 
##                 nfi                pnfi                 ifi 
##               0.899               0.449               0.906 
##                 rni                logl   unrestricted.logl 
##               0.905          -14207.275          -14088.929 
##                 aic                 bic              ntotal 
##           28486.550           28661.154             944.000 
##                bic2               rmsea      rmsea.ci.lower 
##           28546.820               0.113               0.101 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.127               0.000               0.115 
##          rmr_nomean                srmr        srmr_bentler 
##               0.126               0.062               0.062 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.068               0.062               0.068 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.062               0.068             116.140 
##               cn_01                 gfi                agfi 
##             139.814               0.997               0.991 
##                pgfi                 mfi                ecvi 
##               0.332               0.891                  NA
fitmeasures(bifactor.negative.fit)#Models bifactor as the negatively worded item as a factor uncorolated with the main factor
##                npar                fmin               chisq 
##              34.000               0.190             357.805 
##                  df              pvalue      baseline.chisq 
##              20.000               0.000            2337.145 
##         baseline.df     baseline.pvalue                 cfi 
##              36.000               0.000               0.853 
##                 tli                nnfi                 rfi 
##               0.736               0.736               0.724 
##                 nfi                pnfi                 ifi 
##               0.847               0.471               0.854 
##                 rni                logl   unrestricted.logl 
##               0.853          -14267.831          -14088.929 
##                 aic                 bic              ntotal 
##           28603.663           28768.567             944.000 
##                bic2               rmsea      rmsea.ci.lower 
##           28660.585               0.134               0.122 
##      rmsea.ci.upper        rmsea.pvalue                 rmr 
##               0.146               0.000               0.171 
##          rmr_nomean                srmr        srmr_bentler 
##               0.188               0.083               0.083 
## srmr_bentler_nomean         srmr_bollen  srmr_bollen_nomean 
##               0.091               0.083               0.091 
##          srmr_mplus   srmr_mplus_nomean               cn_05 
##               0.083               0.091              83.870 
##               cn_01                 gfi                agfi 
##             100.111               0.995               0.986 
##                pgfi                 mfi                ecvi 
##               0.368               0.836                  NA

Create dataset for Target rotation

all_surveys <- read.csv("~/Dropbox/Git/stats/allsurveysYT1_Jan2016.csv", header=T)
PWBTR<-select(all_surveys, PWB_1, PWB_2, PWB_3,PWB_4, PWB_5,PWB_6,PWB_9, PWB_8,PWB_7)
PWB$PWB_1  <-  7- PWB$PWB_1
PWB$PWB_2  <-  7- PWB$PWB_2
PWB$PWB_3  <-  7- PWB$PWB_3
PWB$PWB_4  <-  7- PWB$PWB_4
PWB$PWB_9  <-  7- PWB$PWB_9
PWBTR<- data.frame(apply(PWBTR,2, as.numeric))

library(GPArotation)
library(psych)
library(dplyr)

PWBTR<-tbl_df(PWBTR)
PWBTR
## Source: local data frame [1,288 x 9]
## 
##    PWB_1 PWB_2 PWB_3 PWB_4 PWB_5 PWB_6 PWB_9 PWB_8 PWB_7
##    (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl)
## 1      3     1     2     4     5     4     6     5     3
## 2      5     5     3     3     6     1     4     4     2
## 3      5     4     4     5     5     4     5     6     6
## 4      2     5     2     2     3     5     1     4     4
## 5      4     4     4     4     4     4     4     4     4
## 6      6     5     5     5     4     4     5     4     4
## 7      4     3     4     3     3     3     3     3     4
## 8      6     5     6     6     6     6     6     6     2
## 9      2     2     2     2     1     5     2     5     5
## 10     5     5     5     5     5     5     5     5     5
## ..   ...   ...   ...   ...   ...   ...   ...   ...   ...
str(PWBTR)
## Classes 'tbl_df', 'tbl' and 'data.frame':    1288 obs. of  9 variables:
##  $ PWB_1: num  3 5 5 2 4 6 4 6 2 5 ...
##  $ PWB_2: num  1 5 4 5 4 5 3 5 2 5 ...
##  $ PWB_3: num  2 3 4 2 4 5 4 6 2 5 ...
##  $ PWB_4: num  4 3 5 2 4 5 3 6 2 5 ...
##  $ PWB_5: num  5 6 5 3 4 4 3 6 1 5 ...
##  $ PWB_6: num  4 1 4 5 4 4 3 6 5 5 ...
##  $ PWB_9: num  6 4 5 1 4 5 3 6 2 5 ...
##  $ PWB_8: num  5 4 6 4 4 4 3 6 5 5 ...
##  $ PWB_7: num  3 2 6 4 4 4 4 2 5 5 ...
colnames(PWBTR) <- c("1","2", "3", "4", "5", "6", "7", "8", "9")
#Target rotation: choose "simple structure" a priori and can be applied to oblique and orthogonal rotation based on 
#what paper says facotrs should be PWB
Targ_key <- make.keys(9,list(f1=1:6,f2=7:9))
Targ_key <- scrub(Targ_key,isvalue=1)  #fix the 0s, allow the NAs to be estimated
Targ_key <- list(Targ_key)
PWBTR_cor <- corFiml(PWBTR) # convert the raw data to correlation matrix uisng FIML
out_targetQ <- fa(PWBTR_cor,2,rotate="TargetQ",n.obs = 816,Target=Targ_key) #TargetT for orthogonal rotation
fa2latex(fa(PWBTR_cor,2,rotate="TargetQ",n.obs = 816,Target=Targ_key), heading="Table 7. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWBTR_cor, 2, rotate = "TargetQ", n.obs = 816, Target = Targ_key) % Called in the psych package  Table 7. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r r }
##  \multicolumn{ 5 }{l}{ Table 7. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   MR1  &  MR2  &  h2  &  u2  &  com \cr 
##   \hline 
## 1   &  \bf{ 0.68}  &   0.19  &  0.44  &  0.56  &  1.16 \cr 
##  2   &  \bf{ 0.51}  &  -0.03  &  0.27  &  0.73  &  1.01 \cr 
##  3   &  \bf{ 0.78}  &   0.06  &  0.59  &  0.41  &  1.01 \cr 
##  4   &  \bf{ 0.53}  &  -0.24  &  0.39  &  0.61  &  1.39 \cr 
##  5   &  \bf{ 0.79}  &   0.05  &  0.60  &  0.40  &  1.01 \cr 
##  6   &  \bf{-0.44}  &   0.28  &  0.32  &  0.68  &  1.69 \cr 
##  7   &  \bf{ 0.46}  &   0.00  &  0.21  &  0.79  &  1.00 \cr 
##  8   &  -0.05  &  \bf{ 0.60}  &  0.38  &  0.62  &  1.02 \cr 
##  9   &  -0.01  &  \bf{ 0.83}  &  0.70  &  0.30  &  1.00 \cr 
## \hline \cr SS loadings & 2.64 &  1.25 &  \cr  
## \cr 
##             \hline \cr 
## MR1   &  1.00 & -0.21 \cr 
##  MR2   & -0.21 &  1.00 \cr 
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}
out_targetQ[c("loadings", "score.cor", "TLI", "RMSEA")]
## $loadings
## 
## Loadings:
##   MR1    MR2   
## 1  0.675  0.192
## 2  0.514       
## 3  0.777       
## 4  0.527 -0.236
## 5  0.785       
## 6 -0.440  0.277
## 7  0.461       
## 8         0.603
## 9         0.833
## 
##                  MR1   MR2
## SS loadings    2.628 1.234
## Proportion Var 0.292 0.137
## Cumulative Var 0.292 0.429
## 
## $score.cor
##            [,1]       [,2]
## [1,]  1.0000000 -0.2350767
## [2,] -0.2350767  1.0000000
## 
## $TLI
## [1] 0.8557789
## 
## $RMSEA
##      RMSEA      lower      upper confidence 
## 0.09873280 0.08500035 0.11220761 0.10000000
out_targetQ
## Factor Analysis using method =  minres
## Call: fa(r = PWBTR_cor, nfactors = 2, n.obs = 816, rotate = "TargetQ", 
##     Target = Targ_key)
## Standardized loadings (pattern matrix) based upon correlation matrix
##     MR1   MR2   h2   u2 com
## 1  0.68  0.19 0.44 0.56 1.2
## 2  0.51 -0.03 0.27 0.73 1.0
## 3  0.78  0.06 0.59 0.41 1.0
## 4  0.53 -0.24 0.39 0.61 1.4
## 5  0.79  0.05 0.60 0.40 1.0
## 6 -0.44  0.28 0.32 0.68 1.7
## 7  0.46  0.00 0.21 0.79 1.0
## 8 -0.05  0.60 0.38 0.62 1.0
## 9 -0.01  0.83 0.70 0.30 1.0
## 
##                        MR1  MR2
## SS loadings           2.64 1.25
## Proportion Var        0.29 0.14
## Cumulative Var        0.29 0.43
## Proportion Explained  0.68 0.32
## Cumulative Proportion 0.68 1.00
## 
##  With factor correlations of 
##       MR1   MR2
## MR1  1.00 -0.21
## MR2 -0.21  1.00
## 
## Mean item complexity =  1.1
## Test of the hypothesis that 2 factors are sufficient.
## 
## The degrees of freedom for the null model are  36  and the objective function was  2.48 with Chi Square of  2008.29
## The degrees of freedom for the model are 19  and the objective function was  0.21 
## 
## The root mean square of the residuals (RMSR) is  0.05 
## The df corrected root mean square of the residuals is  0.07 
## 
## The harmonic number of observations is  816 with the empirical chi square  152.45  with prob <  7.4e-23 
## The total number of observations was  816  with MLE Chi Square =  168.87  with prob <  4.7e-26 
## 
## Tucker Lewis Index of factoring reliability =  0.856
## RMSEA index =  0.099  and the 90 % confidence intervals are  0.085 0.112
## BIC =  41.49
## Fit based upon off diagonal values = 0.97
## Measures of factor score adequacy             
##                                                 MR1  MR2
## Correlation of scores with factors             0.92 0.87
## Multiple R square of scores with factors       0.84 0.76
## Minimum correlation of possible factor scores  0.68 0.52

CFI

1-((out_targetQ$STATISTIC - out_targetQ$dof)/(out_targetQ$null.chisq- out_targetQ$null.dof))
## [1] 0.9240107

Target toration as three factors based on EFA - works well as three factors but with cross loadings

all_surveys <- read.csv("~/Dropbox/Git/stats/allsurveysYT1_Jan2016.csv", header=T)
PWBTR<-select(all_surveys, PWB_1, PWB_3, PWB_5,PWB_6, PWB_7, PWB_4,PWB_8, PWB_2,PWB_9)
PWB$PWB_1  <-  7- PWB$PWB_1
PWB$PWB_2  <-  7- PWB$PWB_2
PWB$PWB_3  <-  7- PWB$PWB_3
PWB$PWB_4  <-  7- PWB$PWB_4
PWB$PWB_9  <-  7- PWB$PWB_9
PWBTR<- data.frame(apply(PWBTR,2, as.numeric))

library(GPArotation)
library(psych)
library(dplyr)

PWBTR<-tbl_df(PWBTR)
PWBTR
## Source: local data frame [1,288 x 9]
## 
##    PWB_1 PWB_3 PWB_5 PWB_6 PWB_7 PWB_4 PWB_8 PWB_2 PWB_9
##    (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl)
## 1      3     2     5     4     3     4     5     1     6
## 2      5     3     6     1     2     3     4     5     4
## 3      5     4     5     4     6     5     6     4     5
## 4      2     2     3     5     4     2     4     5     1
## 5      4     4     4     4     4     4     4     4     4
## 6      6     5     4     4     4     5     4     5     5
## 7      4     4     3     3     4     3     3     3     3
## 8      6     6     6     6     2     6     6     5     6
## 9      2     2     1     5     5     2     5     2     2
## 10     5     5     5     5     5     5     5     5     5
## ..   ...   ...   ...   ...   ...   ...   ...   ...   ...
str(PWBTR)
## Classes 'tbl_df', 'tbl' and 'data.frame':    1288 obs. of  9 variables:
##  $ PWB_1: num  3 5 5 2 4 6 4 6 2 5 ...
##  $ PWB_3: num  2 3 4 2 4 5 4 6 2 5 ...
##  $ PWB_5: num  5 6 5 3 4 4 3 6 1 5 ...
##  $ PWB_6: num  4 1 4 5 4 4 3 6 5 5 ...
##  $ PWB_7: num  3 2 6 4 4 4 4 2 5 5 ...
##  $ PWB_4: num  4 3 5 2 4 5 3 6 2 5 ...
##  $ PWB_8: num  5 4 6 4 4 4 3 6 5 5 ...
##  $ PWB_2: num  1 5 4 5 4 5 3 5 2 5 ...
##  $ PWB_9: num  6 4 5 1 4 5 3 6 2 5 ...
colnames(PWBTR) <- c("1","2", "3", "4", "5", "6", "7", "8", "9")
#Target rotation: choose "simple structure" a priori and can be applied to oblique and orthogonal rotation based on 
#what paper says facotrs should be PWB
Targ_key <- make.keys(9,list(f1=1:4,f2=5:6, f3=7:9))
Targ_key <- scrub(Targ_key,isvalue=1)  #fix the 0s, allow the NAs to be estimated
Targ_key <- list(Targ_key)
PWBTR_cor <- corFiml(PWBTR) # convert the raw data to correlation matrix uisng FIML
out_targetQ <- fa(PWBTR_cor,3,rotate="TargetQ",n.obs = 816,Target=Targ_key) #TargetT for orthogonal rotation
fa2latex(fa(PWBTR_cor,3,rotate="TargetQ",n.obs = 816,Target=Targ_key), heading="Table 8. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWBTR_cor, 3, rotate = "TargetQ", n.obs = 816, Target = Targ_key) % Called in the psych package  Table 8. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r r r }
##  \multicolumn{ 6 }{l}{ Table 8. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   MR1  &  MR2  &  MR3  &  h2  &  u2  &  com \cr 
##   \hline 
## 1   &  \bf{ 0.54}  &   0.17  &   0.20  &  0.44  &  0.56  &  1.48 \cr 
##  2   &  \bf{ 0.72}  &   0.07  &   0.09  &  0.59  &  0.41  &  1.05 \cr 
##  3   &  \bf{ 0.74}  &   0.06  &   0.09  &  0.61  &  0.39  &  1.04 \cr 
##  4   &  \bf{-0.77}  &   0.20  &  \bf{ 0.38}  &  0.52  &  0.48  &  1.62 \cr 
##  5   &   0.01  &  \bf{ 0.83}  &  -0.01  &  0.69  &  0.31  &  1.00 \cr 
##  6   &   0.25  &  -0.30  &  \bf{ 0.36}  &  0.42  &  0.58  &  2.77 \cr 
##  7   &  -0.05  &  \bf{ 0.60}  &   0.01  &  0.38  &  0.62  &  1.02 \cr 
##  8   &   0.08  &  -0.14  &  \bf{ 0.59}  &  0.44  &  0.56  &  1.15 \cr 
##  9   &   0.09  &  -0.08  &  \bf{ 0.49}  &  0.32  &  0.68  &  1.13 \cr 
## \hline \cr SS loadings & 2.13 &  1.27 &  1 &  \cr  
## \cr 
##             \hline \cr 
## MR1   &  1.00 & -0.25 &  0.56 \cr 
##  MR2   & -0.25 &  1.00 &  0.01 \cr 
##  MR3   &  0.56 &  0.01 &  1.00 \cr 
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}
out_targetQ[c("loadings", "score.cor", "TLI", "RMSEA")]
## $loadings
## 
## Loadings:
##   MR1    MR2    MR3   
## 1  0.544  0.171  0.202
## 2  0.722              
## 3  0.739              
## 4 -0.765  0.203  0.376
## 5         0.833       
## 6  0.254 -0.299  0.361
## 7         0.603       
## 8        -0.138  0.594
## 9                0.494
## 
##                  MR1   MR2   MR3
## SS loadings    2.031 1.252 0.926
## Proportion Var 0.226 0.139 0.103
## Cumulative Var 0.226 0.365 0.468
## 
## $score.cor
##            [,1]       [,2]       [,3]
## [1,]  1.0000000 -0.2351284  0.5058006
## [2,] -0.2351284  1.0000000 -0.1502985
## [3,]  0.5058006 -0.1502985  1.0000000
## 
## $TLI
## [1] 0.9268462
## 
## $RMSEA
##      RMSEA      lower      upper confidence 
## 0.07035195 0.05295846 0.08810460 0.10000000
out_targetQ
## Factor Analysis using method =  minres
## Call: fa(r = PWBTR_cor, nfactors = 3, n.obs = 816, rotate = "TargetQ", 
##     Target = Targ_key)
## Standardized loadings (pattern matrix) based upon correlation matrix
##     MR1   MR2   MR3   h2   u2 com
## 1  0.54  0.17  0.20 0.44 0.56 1.5
## 2  0.72  0.07  0.09 0.59 0.41 1.1
## 3  0.74  0.06  0.09 0.61 0.39 1.0
## 4 -0.77  0.20  0.38 0.52 0.48 1.6
## 5  0.01  0.83 -0.01 0.69 0.31 1.0
## 6  0.25 -0.30  0.36 0.42 0.58 2.8
## 7 -0.05  0.60  0.01 0.38 0.62 1.0
## 8  0.08 -0.14  0.59 0.44 0.56 1.1
## 9  0.09 -0.08  0.49 0.32 0.68 1.1
## 
##                        MR1  MR2  MR3
## SS loadings           2.13 1.27 1.00
## Proportion Var        0.24 0.14 0.11
## Cumulative Var        0.24 0.38 0.49
## Proportion Explained  0.48 0.29 0.23
## Cumulative Proportion 0.48 0.77 1.00
## 
##  With factor correlations of 
##       MR1   MR2  MR3
## MR1  1.00 -0.25 0.56
## MR2 -0.25  1.00 0.01
## MR3  0.56  0.01 1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 3 factors are sufficient.
## 
## The degrees of freedom for the null model are  36  and the objective function was  2.48 with Chi Square of  2008.29
## The degrees of freedom for the model are 12  and the objective function was  0.07 
## 
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.04 
## 
## The harmonic number of observations is  816 with the empirical chi square  34.55  with prob <  0.00055 
## The total number of observations was  816  with MLE Chi Square =  59.97  with prob <  2.3e-08 
## 
## Tucker Lewis Index of factoring reliability =  0.927
## RMSEA index =  0.07  and the 90 % confidence intervals are  0.053 0.088
## BIC =  -20.48
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                 MR1  MR2  MR3
## Correlation of scores with factors             0.91 0.87 0.82
## Multiple R square of scores with factors       0.83 0.76 0.67
## Minimum correlation of possible factor scores  0.67 0.53 0.34

CFI

1-((out_targetQ$STATISTIC - out_targetQ$dof)/(out_targetQ$null.chisq- out_targetQ$null.dof))
## [1] 0.9756766

Create dataset for Target rotation

all_surveys <- read.csv("~/Dropbox/Git/stats/allsurveysYT1_Jan2016.csv", header=T)
PWB<-select(all_surveys, PWB_1, PWB_3, PWB_5,PWB_6, PWB_7, PWB_8,   PWB_2, PWB_4, PWB_9)
PWB<- data.frame(apply(PWB,2, as.numeric))


library(GPArotation)
library(psych)
library(dplyr)

PWB<-tbl_df(PWB)
PWB
## Source: local data frame [1,288 x 9]
## 
##    PWB_1 PWB_3 PWB_5 PWB_6 PWB_7 PWB_8 PWB_2 PWB_4 PWB_9
##    (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl)
## 1      3     2     5     4     3     5     1     4     6
## 2      5     3     6     1     2     4     5     3     4
## 3      5     4     5     4     6     6     4     5     5
## 4      2     2     3     5     4     4     5     2     1
## 5      4     4     4     4     4     4     4     4     4
## 6      6     5     4     4     4     4     5     5     5
## 7      4     4     3     3     4     3     3     3     3
## 8      6     6     6     6     2     6     5     6     6
## 9      2     2     1     5     5     5     2     2     2
## 10     5     5     5     5     5     5     5     5     5
## ..   ...   ...   ...   ...   ...   ...   ...   ...   ...
str(PWB)
## Classes 'tbl_df', 'tbl' and 'data.frame':    1288 obs. of  9 variables:
##  $ PWB_1: num  3 5 5 2 4 6 4 6 2 5 ...
##  $ PWB_3: num  2 3 4 2 4 5 4 6 2 5 ...
##  $ PWB_5: num  5 6 5 3 4 4 3 6 1 5 ...
##  $ PWB_6: num  4 1 4 5 4 4 3 6 5 5 ...
##  $ PWB_7: num  3 2 6 4 4 4 4 2 5 5 ...
##  $ PWB_8: num  5 4 6 4 4 4 3 6 5 5 ...
##  $ PWB_2: num  1 5 4 5 4 5 3 5 2 5 ...
##  $ PWB_4: num  4 3 5 2 4 5 3 6 2 5 ...
##  $ PWB_9: num  6 4 5 1 4 5 3 6 2 5 ...
colnames(PWB) <- c("1","2", "3", "4", "5", "6", "7", "8", "9")
#Target rotation: choose "simple structure" a priori and can be applied to oblique and orthogonal rotation based on 
#what paper says facotrs should be PWB
Targ_key <- make.keys(9,list(f1=1:4,f2=5:7, f3=8:9))
Targ_key <- scrub(Targ_key,isvalue=1)  #fix the 0s, allow the NAs to be estimated
Targ_key <- list(Targ_key)
PWB_cor <- corFiml(PWB) # convert the raw data to correlation matrix uisng FIML
out_targetQ <- fa(PWB_cor,3,rotate="TargetQ",n.obs = 816,Target=Targ_key) #TargetT for orthogonal rotation
fa2latex(fa(PWB_cor,3,rotate="TargetQ",n.obs = 816,Target=Targ_key), heading="Table 9. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWB_cor, 3, rotate = "TargetQ", n.obs = 816, Target = Targ_key) % Called in the psych package  Table 9. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r r r }
##  \multicolumn{ 6 }{l}{ Table 9. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   MR1  &  MR2  &  MR3  &  h2  &  u2  &  com \cr 
##   \hline 
## 1   &  \bf{ 0.58}  &   0.19  &   0.18  &  0.44  &  0.56  &  1.41 \cr 
##  2   &  \bf{ 0.74}  &   0.08  &   0.08  &  0.59  &  0.41  &  1.05 \cr 
##  3   &  \bf{ 0.75}  &   0.06  &   0.08  &  0.61  &  0.39  &  1.04 \cr 
##  4   &  \bf{-0.71}  &   0.23  &  \bf{ 0.34}  &  0.52  &  0.48  &  1.68 \cr 
##  5   &   0.07  &  \bf{ 0.85}  &  -0.06  &  0.69  &  0.31  &  1.02 \cr 
##  6   &  -0.01  &  \bf{ 0.61}  &  -0.03  &  0.38  &  0.62  &  1.00 \cr 
##  7   &   0.14  &  -0.10  &  \bf{ 0.57}  &  0.44  &  0.56  &  1.19 \cr 
##  8   &   0.28  &  -0.28  &  \bf{ 0.36}  &  0.42  &  0.58  &  2.83 \cr 
##  9   &   0.14  &  -0.05  &  \bf{ 0.47}  &  0.32  &  0.68  &  1.22 \cr 
## \hline \cr SS loadings & 2.18 &  1.28 &  0.94 &  \cr  
## \cr 
##             \hline \cr 
## MR1   &  1.00 & -0.28 &  0.50 \cr 
##  MR2   & -0.28 &  1.00 &  0.00 \cr 
##  MR3   &  0.50 &  0.00 &  1.00 \cr 
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}
out_targetQ[c("loadings", "score.cor", "TLI", "RMSEA")]
## $loadings
## 
## Loadings:
##   MR1    MR2    MR3   
## 1  0.579  0.187  0.180
## 2  0.737              
## 3  0.753              
## 4 -0.709  0.229  0.341
## 5         0.846       
## 6         0.614       
## 7  0.140 -0.103  0.565
## 8  0.275 -0.281  0.356
## 9  0.145         0.468
## 
##                  MR1   MR2   MR3
## SS loadings    2.069 1.282 0.832
## Proportion Var 0.230 0.142 0.092
## Cumulative Var 0.230 0.372 0.465
## 
## $score.cor
##            [,1]       [,2]       [,3]
## [1,]  1.0000000 -0.2351284  0.5058006
## [2,] -0.2351284  1.0000000 -0.1502985
## [3,]  0.5058006 -0.1502985  1.0000000
## 
## $TLI
## [1] 0.9268462
## 
## $RMSEA
##      RMSEA      lower      upper confidence 
## 0.07035195 0.05295846 0.08810460 0.10000000
out_targetQ
## Factor Analysis using method =  minres
## Call: fa(r = PWB_cor, nfactors = 3, n.obs = 816, rotate = "TargetQ", 
##     Target = Targ_key)
## Standardized loadings (pattern matrix) based upon correlation matrix
##     MR1   MR2   MR3   h2   u2 com
## 1  0.58  0.19  0.18 0.44 0.56 1.4
## 2  0.74  0.08  0.08 0.59 0.41 1.0
## 3  0.75  0.06  0.08 0.61 0.39 1.0
## 4 -0.71  0.23  0.34 0.52 0.48 1.7
## 5  0.07  0.85 -0.06 0.69 0.31 1.0
## 6 -0.01  0.61 -0.03 0.38 0.62 1.0
## 7  0.14 -0.10  0.57 0.44 0.56 1.2
## 8  0.28 -0.28  0.36 0.42 0.58 2.8
## 9  0.14 -0.05  0.47 0.32 0.68 1.2
## 
##                        MR1  MR2  MR3
## SS loadings           2.18 1.28 0.94
## Proportion Var        0.24 0.14 0.10
## Cumulative Var        0.24 0.38 0.49
## Proportion Explained  0.49 0.29 0.21
## Cumulative Proportion 0.49 0.79 1.00
## 
##  With factor correlations of 
##       MR1   MR2 MR3
## MR1  1.00 -0.28 0.5
## MR2 -0.28  1.00 0.0
## MR3  0.50  0.00 1.0
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 3 factors are sufficient.
## 
## The degrees of freedom for the null model are  36  and the objective function was  2.48 with Chi Square of  2008.29
## The degrees of freedom for the model are 12  and the objective function was  0.07 
## 
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.04 
## 
## The harmonic number of observations is  816 with the empirical chi square  34.55  with prob <  0.00055 
## The total number of observations was  816  with MLE Chi Square =  59.97  with prob <  2.3e-08 
## 
## Tucker Lewis Index of factoring reliability =  0.927
## RMSEA index =  0.07  and the 90 % confidence intervals are  0.053 0.088
## BIC =  -20.48
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                 MR1  MR2  MR3
## Correlation of scores with factors             0.91 0.88 0.80
## Multiple R square of scores with factors       0.83 0.77 0.64
## Minimum correlation of possible factor scores  0.67 0.53 0.27
#The best fit to the data seems to be three factors. F1: questions 1,3,5,6. f2: 8,7,4. f3: 2,9

CFI

1-((out_targetQ$STATISTIC - out_targetQ$dof)/(out_targetQ$null.chisq- out_targetQ$null.dof))
## [1] 0.9756766

Based on the above model we try F1: questions 1,3,5,6. f2: 8,7,4. f3: 2,9. this the best fit to the data. (PWB_4 crossloads)

all_surveys <- read.csv("~/Dropbox/Git/stats/allsurveysYT1_Jan2016.csv", header=T)
PWB<-select(all_surveys, PWB_1, PWB_3, PWB_5,PWB_6, PWB_7, PWB_8,PWB_4, PWB_2,  PWB_9)
PWB<- data.frame(apply(PWB,2, as.numeric))
PWB<-tbl_df(PWB)
PWB
## Source: local data frame [1,288 x 9]
## 
##    PWB_1 PWB_3 PWB_5 PWB_6 PWB_7 PWB_8 PWB_4 PWB_2 PWB_9
##    (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl)
## 1      3     2     5     4     3     5     4     1     6
## 2      5     3     6     1     2     4     3     5     4
## 3      5     4     5     4     6     6     5     4     5
## 4      2     2     3     5     4     4     2     5     1
## 5      4     4     4     4     4     4     4     4     4
## 6      6     5     4     4     4     4     5     5     5
## 7      4     4     3     3     4     3     3     3     3
## 8      6     6     6     6     2     6     6     5     6
## 9      2     2     1     5     5     5     2     2     2
## 10     5     5     5     5     5     5     5     5     5
## ..   ...   ...   ...   ...   ...   ...   ...   ...   ...
colnames(PWB) <- c("1","2", "3", "4", "5", "6", "7", "8", "9")
#Target rotation: choose "simple structure" a priori and can be applied to oblique and orthogonal rotation based on 
#what paper says facotrs should be PWB
Targ_key <- make.keys(9,list(f1=1:4,f2=5:7, f3=8:9))
Targ_key <- scrub(Targ_key,isvalue=1)  #fix the 0s, allow the NAs to be estimated
Targ_key <- list(Targ_key)
PWB_cor <- corFiml(PWB) # convert the raw data to correlation matrix uisng FIML
out_targetQ <- fa(PWB_cor,3,rotate="TargetQ",n.obs = 816,Target=Targ_key) #TargetT for orthogonal rotation
fa2latex(fa(PWB_cor,3,rotate="TargetQ",n.obs = 816,Target=Targ_key), heading="Table 10. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWB_cor, 3, rotate = "TargetQ", n.obs = 816, Target = Targ_key) % Called in the psych package  Table 10. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r r r }
##  \multicolumn{ 6 }{l}{ Table 10. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   MR1  &  MR2  &  MR3  &  h2  &  u2  &  com \cr 
##   \hline 
## 1   &  \bf{ 0.56}  &   0.16  &   0.20  &  0.44  &  0.56  &  1.42 \cr 
##  2   &  \bf{ 0.73}  &   0.06  &   0.09  &  0.59  &  0.41  &  1.04 \cr 
##  3   &  \bf{ 0.74}  &   0.04  &   0.08  &  0.61  &  0.39  &  1.03 \cr 
##  4   &  \bf{-0.74}  &   0.22  &  \bf{ 0.37}  &  0.52  &  0.48  &  1.69 \cr 
##  5   &   0.08  &  \bf{ 0.85}  &  -0.02  &  0.69  &  0.31  &  1.02 \cr 
##  6   &  -0.01  &  \bf{ 0.62}  &   0.00  &  0.38  &  0.62  &  1.00 \cr 
##  7   &   0.24  &  \bf{-0.31}  &  \bf{ 0.36}  &  0.42  &  0.58  &  2.73 \cr 
##  8   &   0.08  &  -0.14  &  \bf{ 0.59}  &  0.44  &  0.56  &  1.16 \cr 
##  9   &   0.10  &  -0.09  &  \bf{ 0.49}  &  0.32  &  0.68  &  1.15 \cr 
## \hline \cr SS loadings & 2.1 &  1.32 &  0.99 &  \cr  
## \cr 
##             \hline \cr 
## MR1   &  1.00 & -0.29 &  0.56 \cr 
##  MR2   & -0.29 &  1.00 & -0.02 \cr 
##  MR3   &  0.56 & -0.02 &  1.00 \cr 
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}
out_targetQ[c("loadings", "score.cor", "TLI", "RMSEA")]
## $loadings
## 
## Loadings:
##   MR1    MR2    MR3   
## 1  0.559  0.162  0.196
## 2  0.726              
## 3  0.742              
## 4 -0.739  0.222  0.374
## 5         0.850       
## 6         0.616       
## 7  0.237 -0.312  0.358
## 8        -0.145  0.588
## 9                0.489
## 
##                  MR1   MR2   MR3
## SS loadings    2.015 1.308 0.906
## Proportion Var 0.224 0.145 0.101
## Cumulative Var 0.224 0.369 0.470
## 
## $score.cor
##            [,1]       [,2]       [,3]
## [1,]  1.0000000 -0.2351284  0.5058006
## [2,] -0.2351284  1.0000000 -0.1502985
## [3,]  0.5058006 -0.1502985  1.0000000
## 
## $TLI
## [1] 0.9268462
## 
## $RMSEA
##      RMSEA      lower      upper confidence 
## 0.07035195 0.05295846 0.08810460 0.10000000
out_targetQ
## Factor Analysis using method =  minres
## Call: fa(r = PWB_cor, nfactors = 3, n.obs = 816, rotate = "TargetQ", 
##     Target = Targ_key)
## Standardized loadings (pattern matrix) based upon correlation matrix
##     MR1   MR2   MR3   h2   u2 com
## 1  0.56  0.16  0.20 0.44 0.56 1.4
## 2  0.73  0.06  0.09 0.59 0.41 1.0
## 3  0.74  0.04  0.08 0.61 0.39 1.0
## 4 -0.74  0.22  0.37 0.52 0.48 1.7
## 5  0.08  0.85 -0.02 0.69 0.31 1.0
## 6 -0.01  0.62  0.00 0.38 0.62 1.0
## 7  0.24 -0.31  0.36 0.42 0.58 2.7
## 8  0.08 -0.14  0.59 0.44 0.56 1.2
## 9  0.10 -0.09  0.49 0.32 0.68 1.1
## 
##                        MR1  MR2  MR3
## SS loadings           2.10 1.32 0.99
## Proportion Var        0.23 0.15 0.11
## Cumulative Var        0.23 0.38 0.49
## Proportion Explained  0.48 0.30 0.22
## Cumulative Proportion 0.48 0.78 1.00
## 
##  With factor correlations of 
##       MR1   MR2   MR3
## MR1  1.00 -0.29  0.56
## MR2 -0.29  1.00 -0.02
## MR3  0.56 -0.02  1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 3 factors are sufficient.
## 
## The degrees of freedom for the null model are  36  and the objective function was  2.48 with Chi Square of  2008.29
## The degrees of freedom for the model are 12  and the objective function was  0.07 
## 
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.04 
## 
## The harmonic number of observations is  816 with the empirical chi square  34.55  with prob <  0.00055 
## The total number of observations was  816  with MLE Chi Square =  59.97  with prob <  2.3e-08 
## 
## Tucker Lewis Index of factoring reliability =  0.927
## RMSEA index =  0.07  and the 90 % confidence intervals are  0.053 0.088
## BIC =  -20.48
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                 MR1  MR2  MR3
## Correlation of scores with factors             0.91 0.88 0.81
## Multiple R square of scores with factors       0.83 0.77 0.66
## Minimum correlation of possible factor scores  0.67 0.54 0.33

The best fit to the data seems to be three factors. F1: questions 1,3,5,6. f2: 8,7,4. f3: 2,9

CFI

1-((out_targetQ$STATISTIC - out_targetQ$dof)/(out_targetQ$null.chisq- out_targetQ$null.dof))
## [1] 0.9756766

Droping question 1 as well because it also loads on all of the factors. Much better fit to the data

all_surveys <- read.csv("~/Dropbox/Git/stats/allsurveysYT1_Jan2016.csv", header=T)
PWB<-select(all_surveys, PWB_3, PWB_5,PWB_6, PWB_8,PWB_7, PWB_2, PWB_9)
PWB<- data.frame(apply(PWB,2, as.numeric))
PWB<-tbl_df(PWB)
PWB
## Source: local data frame [1,288 x 7]
## 
##    PWB_3 PWB_5 PWB_6 PWB_8 PWB_7 PWB_2 PWB_9
##    (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl)
## 1      2     5     4     5     3     1     6
## 2      3     6     1     4     2     5     4
## 3      4     5     4     6     6     4     5
## 4      2     3     5     4     4     5     1
## 5      4     4     4     4     4     4     4
## 6      5     4     4     4     4     5     5
## 7      4     3     3     3     4     3     3
## 8      6     6     6     6     2     5     6
## 9      2     1     5     5     5     2     2
## 10     5     5     5     5     5     5     5
## ..   ...   ...   ...   ...   ...   ...   ...
colnames(PWB) <- c("1","2", "3", "4", "5", "6", "7")
#Target rotation: choose "simple structure" a priori and can be applied to oblique and orthogonal rotation based on 
#what paper says facotrs should be PWB
Targ_key <- make.keys(7,list(f1=1:3,f2=4:5, f3=6:7))
Targ_key <- scrub(Targ_key,isvalue=1)  #fix the 0s, allow the NAs to be estimated
Targ_key <- list(Targ_key)
PWB_cor <- corFiml(PWB) # convert the raw data to correlation matrix uisng FIML
out_targetQ <- fa(PWB_cor,3,rotate="TargetQ",n.obs = 816,Target=Targ_key) #TargetT for orthogonal rotation
fa2latex(fa(PWB_cor,3,rotate="TargetQ",n.obs = 816,Target=Targ_key), heading="Table 11. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWB_cor, 3, rotate = "TargetQ", n.obs = 816, Target = Targ_key) % Called in the psych package  Table 11. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r r r }
##  \multicolumn{ 6 }{l}{ Table 11. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   MR1  &  MR2  &  MR3  &  h2  &  u2  &  com \cr 
##   \hline 
## 1   &  \bf{ 0.72}  &   0.12  &   0.12  &  0.59  &  0.41  &  1.11 \cr 
##  2   &  \bf{ 0.74}  &   0.10  &   0.14  &  0.65  &  0.35  &  1.12 \cr 
##  3   &  \bf{-0.69}  &   0.23  &   0.27  &  0.49  &  0.51  &  1.54 \cr 
##  4   &  -0.02  &  \bf{ 0.64}  &  -0.07  &  0.43  &  0.57  &  1.02 \cr 
##  5   &   0.00  &  \bf{ 0.77}  &  -0.06  &  0.60  &  0.40  &  1.01 \cr 
##  6   &   0.08  &  -0.10  &  \bf{ 0.53}  &  0.35  &  0.65  &  1.12 \cr 
##  7   &   0.03  &  -0.06  &  \bf{ 0.61}  &  0.39  &  0.61  &  1.02 \cr 
## \hline \cr SS loadings & 1.59 &  1.11 &  0.8 &  \cr  
## \cr 
##             \hline \cr 
## MR1   &  1.00 & -0.26 &  0.54 \cr 
##  MR2   & -0.26 &  1.00 &  0.01 \cr 
##  MR3   &  0.54 &  0.01 &  1.00 \cr 
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}
out_targetQ[c("loadings", "score.cor", "TLI", "RMSEA")]
## $loadings
## 
## Loadings:
##   MR1    MR2    MR3   
## 1  0.720  0.125  0.116
## 2  0.737  0.104  0.142
## 3 -0.691  0.230  0.269
## 4         0.643       
## 5         0.772       
## 6        -0.102  0.534
## 7                0.606
## 
##                  MR1   MR2   MR3
## SS loadings    1.547 1.102 0.766
## Proportion Var 0.221 0.157 0.109
## Cumulative Var 0.221 0.378 0.488
## 
## $score.cor
##            [,1]       [,2]       [,3]
## [1,]  1.0000000 -0.2365795  0.4069225
## [2,] -0.2365795  1.0000000 -0.1502887
## [3,]  0.4069225 -0.1502887  1.0000000
## 
## $TLI
## [1] 1.012585
## 
## $RMSEA
##      RMSEA      lower      upper confidence 
## 0.00000000         NA 0.03151667 0.10000000
out_targetQ
## Factor Analysis using method =  minres
## Call: fa(r = PWB_cor, nfactors = 3, n.obs = 816, rotate = "TargetQ", 
##     Target = Targ_key)
## Standardized loadings (pattern matrix) based upon correlation matrix
##     MR1   MR2   MR3   h2   u2 com
## 1  0.72  0.12  0.12 0.59 0.41 1.1
## 2  0.74  0.10  0.14 0.65 0.35 1.1
## 3 -0.69  0.23  0.27 0.49 0.51 1.5
## 4 -0.02  0.64 -0.07 0.43 0.57 1.0
## 5  0.00  0.77 -0.06 0.60 0.40 1.0
## 6  0.08 -0.10  0.53 0.35 0.65 1.1
## 7  0.03 -0.06  0.61 0.39 0.61 1.0
## 
##                        MR1  MR2  MR3
## SS loadings           1.59 1.11 0.80
## Proportion Var        0.23 0.16 0.11
## Cumulative Var        0.23 0.38 0.50
## Proportion Explained  0.45 0.32 0.23
## Cumulative Proportion 0.45 0.77 1.00
## 
##  With factor correlations of 
##       MR1   MR2  MR3
## MR1  1.00 -0.26 0.54
## MR2 -0.26  1.00 0.01
## MR3  0.54  0.01 1.00
## 
## Mean item complexity =  1.1
## Test of the hypothesis that 3 factors are sufficient.
## 
## The degrees of freedom for the null model are  21  and the objective function was  1.56 with Chi Square of  1268.09
## The degrees of freedom for the model are 3  and the objective function was  0 
## 
## The root mean square of the residuals (RMSR) is  0 
## The df corrected root mean square of the residuals is  0.01 
## 
## The harmonic number of observations is  816 with the empirical chi square  0.38  with prob <  0.94 
## The total number of observations was  816  with MLE Chi Square =  0.76  with prob <  0.86 
## 
## Tucker Lewis Index of factoring reliability =  1.013
## RMSEA index =  0  and the 90 % confidence intervals are  NA 0.032
## BIC =  -19.35
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                 MR1  MR2  MR3
## Correlation of scores with factors             0.90 0.84 0.79
## Multiple R square of scores with factors       0.80 0.71 0.62
## Minimum correlation of possible factor scores  0.61 0.42 0.24
#The best fit to the data seems to be three factors. F1: questions 1,3,5,6. f2: 8,7,4. f3: 2,9

CFI

1-((out_targetQ$STATISTIC - out_targetQ$dof)/(out_targetQ$null.chisq- out_targetQ$null.dof))
## [1] 1.001793

Dropping PWB_4 – still not great and PWB_1 crossloads significantly and PWB_9 does not load well on any of the factors.

all_surveys <- read.csv("~/Dropbox/Git/stats/allsurveysYT1_Jan2016.csv", header=T)
PWB<-select(all_surveys, PWB_1, PWB_3, PWB_5,PWB_6, PWB_7, PWB_8, PWB_2,  PWB_9)
PWB<- data.frame(apply(PWB,2, as.numeric))
PWB<-tbl_df(PWB)
PWB
## Source: local data frame [1,288 x 8]
## 
##    PWB_1 PWB_3 PWB_5 PWB_6 PWB_7 PWB_8 PWB_2 PWB_9
##    (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl)
## 1      3     2     5     4     3     5     1     6
## 2      5     3     6     1     2     4     5     4
## 3      5     4     5     4     6     6     4     5
## 4      2     2     3     5     4     4     5     1
## 5      4     4     4     4     4     4     4     4
## 6      6     5     4     4     4     4     5     5
## 7      4     4     3     3     4     3     3     3
## 8      6     6     6     6     2     6     5     6
## 9      2     2     1     5     5     5     2     2
## 10     5     5     5     5     5     5     5     5
## ..   ...   ...   ...   ...   ...   ...   ...   ...
colnames(PWB) <- c("1","2", "3", "4", "5", "6", "7", "8")
#Target rotation: choose "simple structure" a priori and can be applied to oblique and orthogonal rotation based on 
#what paper says facotrs should be PWB
Targ_key <- make.keys(8,list(f1=1:4,f2=5:6, f3=7:8))
Targ_key <- scrub(Targ_key,isvalue=1)  #fix the 0s, allow the NAs to be estimated
Targ_key <- list(Targ_key)
PWB_cor <- corFiml(PWB) # convert the raw data to correlation matrix uisng FIML
out_targetQ <- fa(PWB_cor,3,rotate="TargetQ",n.obs = 816,Target=Targ_key) #TargetT for orthogonal rotation
fa2latex(fa(PWB_cor,3,rotate="TargetQ",n.obs = 816,Target=Targ_key), heading="Table 12. Factor Loadings for Exploratory Factor Analysis PWB")
## % Called in the psych package  fa2latex % Called in the psych package  fa(PWB_cor, 3, rotate = "TargetQ", n.obs = 816, Target = Targ_key) % Called in the psych package  Table 12. Factor Loadings for Exploratory Factor Analysis PWB 
## \begin{table}[htpb]\caption{fa2latex}
## \begin{center}
## \begin{scriptsize} 
## \begin{tabular} {l r r r r r r }
##  \multicolumn{ 6 }{l}{ Table 12. Factor Loadings for Exploratory Factor Analysis PWB } \cr 
##  \hline Variable  &   MR1  &  MR2  &  MR3  &  h2  &  u2  &  com \cr 
##   \hline 
## 1   &  \bf{ 0.51}  &   0.16  &   0.25  &  0.47  &  0.53  &  1.71 \cr 
##  2   &  \bf{ 0.76}  &   0.07  &   0.01  &  0.58  &  0.42  &  1.02 \cr 
##  3   &  \bf{ 0.78}  &   0.05  &   0.04  &  0.63  &  0.37  &  1.01 \cr 
##  4   &  \bf{-0.66}  &   0.27  &   0.23  &  0.46  &  0.54  &  1.60 \cr 
##  5   &   0.01  &  \bf{ 0.81}  &  -0.08  &  0.65  &  0.35  &  1.02 \cr 
##  6   &  -0.04  &  \bf{ 0.62}  &  -0.06  &  0.40  &  0.60  &  1.02 \cr 
##  7   &   0.00  &  -0.12  &  \bf{ 0.76}  &  0.59  &  0.41  &  1.05 \cr 
##  8   &   0.17  &  -0.04  &  \bf{ 0.40}  &  0.26  &  0.74  &  1.38 \cr 
## \hline \cr SS loadings & 1.96 &  1.17 &  0.91 &  \cr  
## \cr 
##             \hline \cr 
## MR1   &  1.00 & -0.18 &  0.56 \cr 
##  MR2   & -0.18 &  1.00 &  0.03 \cr 
##  MR3   &  0.56 &  0.03 &  1.00 \cr 
##  \hline 
## \end{tabular}
## \end{scriptsize}
## \end{center}
## \label{default}
## \end{table}
out_targetQ[c("loadings", "score.cor", "TLI", "RMSEA")]
## $loadings
## 
## Loadings:
##   MR1    MR2    MR3   
## 1  0.507  0.163  0.255
## 2  0.764              
## 3  0.777              
## 4 -0.657  0.270  0.229
## 5         0.810       
## 6         0.625       
## 7        -0.116  0.761
## 8  0.172         0.396
## 
##                  MR1   MR2   MR3
## SS loadings    1.907 1.168 0.865
## Proportion Var 0.238 0.146 0.108
## Cumulative Var 0.238 0.384 0.493
## 
## $score.cor
##            [,1]       [,2]       [,3]
## [1,]  1.0000000 -0.1771134  0.4632567
## [2,] -0.1771134  1.0000000 -0.1502922
## [3,]  0.4632567 -0.1502922  1.0000000
## 
## $TLI
## [1] 0.9268019
## 
## $RMSEA
##      RMSEA      lower      upper confidence 
## 0.07261013 0.05031065 0.09606291 0.10000000
out_targetQ
## Factor Analysis using method =  minres
## Call: fa(r = PWB_cor, nfactors = 3, n.obs = 816, rotate = "TargetQ", 
##     Target = Targ_key)
## Standardized loadings (pattern matrix) based upon correlation matrix
##     MR1   MR2   MR3   h2   u2 com
## 1  0.51  0.16  0.25 0.47 0.53 1.7
## 2  0.76  0.07  0.01 0.58 0.42 1.0
## 3  0.78  0.05  0.04 0.63 0.37 1.0
## 4 -0.66  0.27  0.23 0.46 0.54 1.6
## 5  0.01  0.81 -0.08 0.65 0.35 1.0
## 6 -0.04  0.62 -0.06 0.40 0.60 1.0
## 7  0.00 -0.12  0.76 0.59 0.41 1.0
## 8  0.17 -0.04  0.40 0.26 0.74 1.4
## 
##                        MR1  MR2  MR3
## SS loadings           1.96 1.17 0.91
## Proportion Var        0.24 0.15 0.11
## Cumulative Var        0.24 0.39 0.50
## Proportion Explained  0.49 0.29 0.23
## Cumulative Proportion 0.49 0.77 1.00
## 
##  With factor correlations of 
##       MR1   MR2  MR3
## MR1  1.00 -0.18 0.56
## MR2 -0.18  1.00 0.03
## MR3  0.56  0.03 1.00
## 
## Mean item complexity =  1.2
## Test of the hypothesis that 3 factors are sufficient.
## 
## The degrees of freedom for the null model are  28  and the objective function was  2.05 with Chi Square of  1662.08
## The degrees of freedom for the model are 7  and the objective function was  0.05 
## 
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.04 
## 
## The harmonic number of observations is  816 with the empirical chi square  23.1  with prob <  0.0016 
## The total number of observations was  816  with MLE Chi Square =  36.83  with prob <  5.1e-06 
## 
## Tucker Lewis Index of factoring reliability =  0.927
## RMSEA index =  0.073  and the 90 % confidence intervals are  0.05 0.096
## BIC =  -10.1
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                 MR1  MR2  MR3
## Correlation of scores with factors             0.91 0.86 0.83
## Multiple R square of scores with factors       0.82 0.74 0.69
## Minimum correlation of possible factor scores  0.65 0.47 0.38
#The best fit to the data seems to be three factors. F1: questions 1,3,5,6. f2: 8,7,4. f3: 2,9

CFI

1-((out_targetQ$STATISTIC - out_targetQ$dof)/(out_targetQ$null.chisq- out_targetQ$null.dof))
## [1] 0.9817464