Project overview

This data was used to conduct a structural equation model of academic performance. Latent variables of attention, relevance, confidence, and satisfaction were created, and then satisfaction was predicted from attention, relevance, and confidence.

my_data <- read.table("~/Downloads/motivate2.txt", quote="\"", comment.char="")
names(my_data)[names(my_data) == "V1"] <- "att1"
names(my_data)[names(my_data) == "V2"] <- "att2"
names(my_data)[names(my_data) == "V3"] <- "att3"
names(my_data)[names(my_data) == "V4"] <- "rel1"
names(my_data)[names(my_data) == "V5"] <- "rel2"
names(my_data)[names(my_data) == "V6"] <- "rel3"
names(my_data)[names(my_data) == "V7"] <- "con1"
names(my_data)[names(my_data) == "V8"] <- "con2"
names(my_data)[names(my_data) == "V9"] <- "con3"
names(my_data)[names(my_data) == "V10"] <- "sat1"
names(my_data)[names(my_data) == "V11"] <- "sat2"
names(my_data)[names(my_data) == "V12"] <- "sat3"
colnames(my_data)
##  [1] "att1" "att2" "att3" "rel1" "rel2" "rel3" "con1" "con2" "con3" "sat1"
## [11] "sat2" "sat3"

Model specificication

mod<-'ATT=~1*att1+att2+att3
REL=~1*rel1+rel2+rel3
CON=~1*con1+con2+con3
SAT=~1*sat1+sat2+sat3
ATT~g1*REL+G2*CON+g3*SAT

#covariances between exo variables
REL~~CON+SAT

#variance of exo variables
REL~~REL
CON~~CON
SAT~~SAT

'

Fit and summarize model

fit.mod <- sem(model = mod,
               missing = "ML",
               data = my_data)

summary(fit.mod,
        fit.measures= TRUE,
        standardized = TRUE,
        cov=TRUE, 
        rsquare=TRUE
        #if you want fit measures like AIC, BIC, etc, use
        #fit.measures = TRUE
)
## lavaan 0.6-7 ended normally after 56 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of free parameters                         42
##                                                       
##   Number of observations                           193
##   Number of missing patterns                         1
##                                                       
## Model Test User Model:
##                                                       
##   Test statistic                                90.820
##   Degrees of freedom                                48
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1565.675
##   Degrees of freedom                                66
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.971
##   Tucker-Lewis Index (TLI)                       0.961
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1553.397
##   Loglikelihood unrestricted model (H1)      -1507.988
##                                                       
##   Akaike (AIC)                                3190.795
##   Bayesian (BIC)                              3327.828
##   Sample-size adjusted Bayesian (BIC)         3194.783
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.068
##   90 Percent confidence interval - lower         0.046
##   90 Percent confidence interval - upper         0.089
##   P-value RMSEA <= 0.05                          0.083
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.046
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   ATT =~                                                                
##     att1              1.000                               0.441    0.672
##     att2              1.176    0.133    8.849    0.000    0.518    0.765
##     att3              1.261    0.138    9.143    0.000    0.555    0.843
##   REL =~                                                                
##     rel1              1.000                               0.515    0.869
##     rel2              1.202    0.075   15.924    0.000    0.619    0.911
##     rel3              1.011    0.084   12.013    0.000    0.521    0.746
##   CON =~                                                                
##     con1              1.000                               0.551    0.881
##     con2              1.081    0.063   17.071    0.000    0.595    0.895
##     con3              1.044    0.061   17.113    0.000    0.575    0.893
##   SAT =~                                                                
##     sat1              1.000                               0.483    0.817
##     sat2              1.201    0.100   12.002    0.000    0.580    0.791
##     sat3              1.008    0.081   12.464    0.000    0.487    0.806
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   ATT ~                                                                 
##     REL       (g1)    0.187    0.077    2.440    0.015    0.219    0.219
##     CON       (G2)   -0.217    0.095   -2.291    0.022   -0.271   -0.271
##     SAT       (g3)    0.788    0.152    5.180    0.000    0.863    0.863
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   REL ~~                                                                
##     CON               0.100    0.024    4.155    0.000    0.354    0.354
##     SAT               0.143    0.025    5.825    0.000    0.575    0.575
##   CON ~~                                                                
##     SAT               0.200    0.028    7.054    0.000    0.752    0.752
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .att1              2.914    0.047   61.722    0.000    2.914    4.443
##    .att2              3.157    0.049   64.787    0.000    3.157    4.663
##    .att3              3.147    0.047   66.349    0.000    3.147    4.776
##    .rel1              3.449    0.043   80.860    0.000    3.449    5.820
##    .rel2              3.349    0.049   68.451    0.000    3.349    4.927
##    .rel3              3.389    0.050   67.415    0.000    3.389    4.853
##    .con1              3.145    0.045   69.934    0.000    3.145    5.034
##    .con2              3.221    0.048   67.327    0.000    3.221    4.846
##    .con3              3.216    0.046   69.383    0.000    3.216    4.994
##    .sat1              3.169    0.043   74.487    0.000    3.169    5.362
##    .sat2              3.090    0.053   58.536    0.000    3.090    4.214
##    .sat3              3.249    0.043   74.795    0.000    3.249    5.384
##    .ATT               0.000                               0.000    0.000
##     REL               0.000                               0.000    0.000
##     CON               0.000                               0.000    0.000
##     SAT               0.000                               0.000    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     REL               0.265    0.036    7.323    0.000    1.000    1.000
##     CON               0.303    0.040    7.603    0.000    1.000    1.000
##     SAT               0.233    0.035    6.612    0.000    1.000    1.000
##    .att1              0.236    0.028    8.298    0.000    0.236    0.549
##    .att2              0.190    0.026    7.387    0.000    0.190    0.414
##    .att3              0.126    0.023    5.532    0.000    0.126    0.289
##    .rel1              0.086    0.014    6.266    0.000    0.086    0.244
##    .rel2              0.079    0.017    4.522    0.000    0.079    0.171
##    .rel3              0.216    0.026    8.393    0.000    0.216    0.443
##    .con1              0.087    0.013    6.697    0.000    0.087    0.223
##    .con2              0.088    0.014    6.357    0.000    0.088    0.198
##    .con3              0.084    0.013    6.498    0.000    0.084    0.202
##    .sat1              0.116    0.016    7.220    0.000    0.116    0.332
##    .sat2              0.202    0.026    7.809    0.000    0.202    0.375
##    .sat3              0.127    0.017    7.500    0.000    0.127    0.350
##    .ATT               0.060    0.016    3.684    0.000    0.311    0.311
## 
## R-Square:
##                    Estimate
##     att1              0.451
##     att2              0.586
##     att3              0.711
##     rel1              0.756
##     rel2              0.829
##     rel3              0.557
##     con1              0.777
##     con2              0.802
##     con3              0.798
##     sat1              0.668
##     sat2              0.625
##     sat3              0.650
##     ATT               0.689

View path diagram

semPaths(fit.mod, 
         whatLabels = "std",
         what="std",
         layout='tree',
         curve=TRUE,
         edge.label.cex = .5,
         edge.label.color = "black",
         edge.width = 0.3,
         normalize=TRUE,
         covAtResiduals = TRUE
      )