data<-read.csv("/Users/levibrackman/Dropbox/Git/stats/Schools Study/Students self assessment data.csv")
require(dplyr)
## Loading required package: 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
sectionone<-select(data, MLQ_1_1, MLQ_4_1, MLQ_5_1, MLQ_6_1, MLQ_11_1)
sectiononecomp<- sectionone[complete.cases(sectionone[,]),]
data <- read.csv("~/Dropbox/Git/stats/allsurveysYT1_Jan2016.csv", header=T)
data<-tbl_df(data)
MLQ<-select(data, MLQ_1, MLQ_2, MLQ_3, MLQ_4, MLQ_5, MLQ_6,MLQ_7, MLQ_8, MLQ_9, MLQ_10)
MLQ$MLQ_9 <- 8- MLQ$MLQ_9
purposemodelMLQ= ' Purpose =~ MLQ_1 + MLQ_5 + MLQ_4 + MLQ_6 + MLQ_9'
purposefit1=cfa(purposemodelMLQ, data=MLQ)
require(semPlot)
semPaths(purposefit1, whatLabels = "std", layout = "tree")
summary(purposefit1, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-20) converged normally after 25 iterations
##
## Used Total
## Number of observations 970 1288
##
## Estimator ML
## Minimum Function Test Statistic 33.938
## Degrees of freedom 5
## P-value (Chi-square) 0.000
##
## Parameter Estimates:
##
## Information Expected
## Standard Errors Standard
##
## Latent Variables:
## Estimate Std.Err Z-value P(>|z|) Std.lv Std.all
## Purpose =~
## MLQ_1 1.000 1.398 0.813
## MLQ_5 0.825 0.032 25.569 0.000 1.154 0.781
## MLQ_4 0.899 0.035 25.729 0.000 1.257 0.785
## MLQ_6 0.947 0.037 25.872 0.000 1.324 0.789
## MLQ_9 0.563 0.047 12.037 0.000 0.788 0.401
##
## Variances:
## Estimate Std.Err Z-value P(>|z|) Std.lv Std.all
## MLQ_1 1.000 0.064 15.566 0.000 1.000 0.338
## MLQ_5 0.851 0.050 16.882 0.000 0.851 0.390
## MLQ_4 0.983 0.059 16.729 0.000 0.983 0.383
## MLQ_6 1.062 0.064 16.586 0.000 1.062 0.377
## MLQ_9 3.246 0.152 21.416 0.000 3.246 0.840
## Purpose 1.955 0.134 14.567 0.000 1.000 1.000
##
## R-Square:
## Estimate
## MLQ_1 0.662
## MLQ_5 0.610
## MLQ_4 0.617
## MLQ_6 0.623
## MLQ_9 0.160
correlMP = residuals(purposefit1, type="cor")
correlMP
## $type
## [1] "cor.bollen"
##
## $cor
## MLQ_1 MLQ_5 MLQ_4 MLQ_6 MLQ_9
## MLQ_1 0.000
## MLQ_5 0.019 0.000
## MLQ_4 -0.021 -0.011 0.000
## MLQ_6 -0.004 -0.018 0.037 0.000
## MLQ_9 0.030 0.033 -0.007 -0.059 0.000
##
## $mean
## MLQ_1 MLQ_5 MLQ_4 MLQ_6 MLQ_9
## 0 0 0 0 0
zcorrelsMP = residuals(purposefit1, type = "standardized")
zcorrelsMP
## $type
## [1] "standardized"
##
## $cov
## MLQ_1 MLQ_5 MLQ_4 MLQ_6 MLQ_9
## MLQ_1 0.000
## MLQ_5 2.272 0.000
## MLQ_4 -5.229 -1.657 NA
## MLQ_6 -0.727 -3.039 3.585 0.000
## MLQ_9 2.014 2.005 -0.439 -4.177 NA
##
## $mean
## MLQ_1 MLQ_5 MLQ_4 MLQ_6 MLQ_9
## 0 0 0 0 0
modindices(purposefit1, sort. = TRUE, minimum.value = 3.84)
## lhs op rhs mi epc sepc.lv sepc.all sepc.nox
## 19 MLQ_4 ~~ MLQ_6 23.755 0.258 0.258 0.096 0.096
## 21 MLQ_6 ~~ MLQ_9 14.849 -0.271 -0.271 -0.082 -0.082
## 13 MLQ_1 ~~ MLQ_4 10.238 -0.178 -0.178 -0.065 -0.065
## 12 MLQ_1 ~~ MLQ_5 8.034 0.145 0.145 0.057 0.057
## 17 MLQ_5 ~~ MLQ_6 5.668 -0.116 -0.116 -0.047 -0.047
## 15 MLQ_1 ~~ MLQ_9 4.485 0.150 0.150 0.044 0.044
## 18 MLQ_5 ~~ MLQ_9 4.384 0.131 0.131 0.045 0.045
options(scipen=999)
MLQpurpose_fit<-fitmeasures(purposefit1)[c('chisq', 'df', 'pvalue', 'cfi', 'rmsea', 'srmr', 'tli')]#Models purpose and meaning
Colunm names explained:
It seems that when we have a positive question instead of the negatively worded one we get a much better fit for the data.
## Source: local data frame [7 x 4]
##
## Fit_Measure MLQ_With_9 Meaning_Purpose_PN Purpose_PN
## (fctr) (dbl) (dbl) (dbl)
## 1 Chisq 33.937974012844 15.560836718 16.300424242
## 2 DF 5.000000000000 4.000000000 5.000000000
## 3 P-Value 0.000002449668 0.003668787 0.006036693
## 4 CFI 0.985671972577 0.997790999 0.997840758
## 5 RMSEA 0.077243721945 0.062160406 0.054968207
## 6 SRMR 0.023296983085 0.004403999 0.004560752
## 7 TLI 0.971343945155 0.994477498 0.995681515