1 Libraries

We are going to use psych (Revelle, 2023), lavaan version 0.6.15 (Rosseel, Jorgensen, & Rockwood, 2023), semTools version 0.5.6 (Jorgensen, Pornprasertmanit, Schoemann, & Rosseel, 2022) and semPlot version 1.1.6 (Epskamp, 2022) in our analysis. Load the packages.

library(foreign)
library(psych)
library(lavaan)
library(semTools)
library(semPlot)

2 Load data

data = read.spss("Attitude_Statistics v3.sav", F, T)
dim(data)
## [1] 150  13
names(data)
##  [1] "ID"  "Q1"  "Q2"  "Q3"  "Q4"  "Q5"  "Q6"  "Q7"  "Q8"  "Q9"  "Q10" "Q11" "Q12"
describe(data[-1])
vars n mean sd median trimmed mad min max range skew kurtosis se
Q1 1 150 3.126667 1.1009250 3 3.125000 1.4826 1 5 4 -0.0995748 -0.7324083 0.0898901
Q2 2 150 3.506667 1.0346135 3 3.550000 1.4826 1 5 4 -0.1441109 -0.4692084 0.0844758
Q3 3 150 3.180000 1.0302147 3 3.166667 1.4826 1 5 4 -0.0321343 -0.4202388 0.0841167
Q4 4 150 2.813333 1.1723130 3 2.775000 1.4826 1 5 4 0.1888890 -0.8077519 0.0957190
Q5 5 150 3.313333 1.0109247 3 3.316667 1.4826 1 5 4 -0.2242453 -0.4760474 0.0825417
Q6 6 150 3.053333 1.0916810 3 3.050000 1.4826 1 5 4 -0.0432196 -0.7058165 0.0891354
Q7 7 150 2.920000 1.1901159 3 2.925000 1.4826 1 5 4 -0.0366766 -1.0562073 0.0971726
Q8 8 150 3.326667 0.9999776 3 3.341667 1.4826 1 5 4 -0.0816209 -0.1204552 0.0816478
Q9 9 150 3.440000 1.0457970 3 3.483333 1.4826 1 5 4 -0.2091593 -0.3234321 0.0853890
Q10 10 150 3.313333 1.0999492 3 3.358333 1.4826 1 5 4 -0.2157639 -0.3888402 0.0898105
Q11 11 150 3.353333 0.9350496 3 3.366667 1.4826 1 5 4 -0.3074829 -0.3281186 0.0763465
Q12 12 150 2.826667 0.9813473 3 2.833333 1.4826 1 5 4 0.0945084 -0.6761637 0.0801267

3 Correlational & causal

3.1 Correlational

3.1.1 Observed variables

# Q4 & Q11
model.c = "
Q4 ~~ Q11
"
corr.c = sem(model.c, data = data, meanstructure = T)  # meanstructure -> display mean
summary(corr.c, fit.measures = T, standardized = T)
## lavaan 0.6.15 ended normally after 13 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         5
## 
##   Number of observations                           150
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                32.305
##   Degrees of freedom                                 1
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -422.299
##   Loglikelihood unrestricted model (H1)       -422.299
##                                                       
##   Akaike (AIC)                                 854.599
##   Bayesian (BIC)                               869.652
##   Sample-size adjusted Bayesian (SABIC)        853.828
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.000
##   P-value H_0: RMSEA <= 0.050                       NA
##   P-value H_0: RMSEA >= 0.080                       NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Q4 ~~                                                                 
##     Q11               0.479    0.097    4.934    0.000    0.479    0.440
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     Q4                2.813    0.095   29.490    0.000    2.813    2.408
##     Q11               3.353    0.076   44.070    0.000    3.353    3.598
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     Q4                1.365    0.158    8.660    0.000    1.365    1.000
##     Q11               0.868    0.100    8.660    0.000    0.868    1.000
semPaths(corr.c, what = "path", whatLabels = "par", edge.color = "black",
         edge.label.cex = 1, residuals = F, sizeInt = 4)
cor(data$Q4, data$Q11)
## [1] 0.4401738

3.1.2 Latent variables

model.cl = "
F1 =~ Q4 + Q6 + Q7 + Q11
F2 =~ Q8 + Q9 + Q10
"
corr.cl = sem(model.cl, data = data)
summary(corr.cl, fit.measures = T, standardized = T)
## lavaan 0.6.15 ended normally after 22 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        15
## 
##   Number of observations                           150
## 
## Model Test User Model:
##                                                       
##   Test statistic                                20.451
##   Degrees of freedom                                13
##   P-value (Chi-square)                           0.085
## 
## Model Test Baseline Model:
## 
##   Test statistic                               380.263
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.979
##   Tucker-Lewis Index (TLI)                       0.966
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1380.510
##   Loglikelihood unrestricted model (H1)      -1370.284
##                                                       
##   Akaike (AIC)                                2791.020
##   Bayesian (BIC)                              2836.179
##   Sample-size adjusted Bayesian (SABIC)       2788.707
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.062
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.111
##   P-value H_0: RMSEA <= 0.050                    0.314
##   P-value H_0: RMSEA >= 0.080                    0.306
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.063
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   F1 =~                                                                 
##     Q4                1.000                               0.941    0.806
##     Q6                0.830    0.103    8.040    0.000    0.781    0.718
##     Q7                0.960    0.115    8.348    0.000    0.904    0.762
##     Q11               0.504    0.088    5.742    0.000    0.474    0.509
##   F2 =~                                                                 
##     Q8                1.000                               0.651    0.653
##     Q9                1.351    0.170    7.951    0.000    0.880    0.844
##     Q10               1.444    0.182    7.927    0.000    0.940    0.858
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   F1 ~~                                                                 
##     F2                0.048    0.060    0.800    0.424    0.078    0.078
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q4                0.479    0.097    4.932    0.000    0.479    0.351
##    .Q6                0.574    0.088    6.530    0.000    0.574    0.485
##    .Q7                0.591    0.101    5.825    0.000    0.591    0.420
##    .Q11               0.644    0.081    7.997    0.000    0.644    0.741
##    .Q8                0.569    0.076    7.526    0.000    0.569    0.573
##    .Q9                0.313    0.077    4.054    0.000    0.313    0.288
##    .Q10               0.318    0.086    3.693    0.000    0.318    0.264
##     F1                0.886    0.168    5.279    0.000    1.000    1.000
##     F2                0.424    0.101    4.191    0.000    1.000    1.000
semPaths(corr.cl, what = "path", whatLabels = "par", edge.color = "black", 
         layout = "tree2", edge.label.cex = 1, residuals = F)

3.2 Causal effects

3.2.1 Observed variables

# Q4 & Q11
model.cs = "
Q4 ~ Q11
"
cause.cs = sem(model.cs, data = data)
summary(cause.cs, fit.measures = T, standardized = T)
## lavaan 0.6.15 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         2
## 
##   Number of observations                           150
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                32.305
##   Degrees of freedom                                 1
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -220.034
##   Loglikelihood unrestricted model (H1)       -220.034
##                                                       
##   Akaike (AIC)                                 444.067
##   Bayesian (BIC)                               450.088
##   Sample-size adjusted Bayesian (SABIC)        443.759
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.000
##   P-value H_0: RMSEA <= 0.050                       NA
##   P-value H_0: RMSEA >= 0.080                       NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Q4 ~                                                                  
##     Q11               0.552    0.092    6.004    0.000    0.552    0.440
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Q4                1.101    0.127    8.660    0.000    1.101    0.806
summary(lm(formula = Q4 ~ Q11, data = data))  # compare with SLR
## 
## Call:
## lm(formula = Q4 ~ Q11, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.7221 -0.6183 -0.1702  0.8298  2.9335 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.96274    0.32207   2.989  0.00328 ** 
## Q11          0.55187    0.09254   5.964 1.74e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.056 on 148 degrees of freedom
## Multiple R-squared:  0.1938, Adjusted R-squared:  0.1883 
## F-statistic: 35.57 on 1 and 148 DF,  p-value: 1.737e-08
semPaths(cause.cs, what = "path", whatLabels = "par", edge.color = "black", 
         rotation = 2, edge.label.cex = 1, residuals = F)