Veri setinin yüklenmesi

library(lavaan)
## This is lavaan 0.6-19
## lavaan is FREE software! Please report any bugs.
data("HolzingerSwineford1939")
head(HolzingerSwineford1939)
##   id sex ageyr agemo  school grade       x1   x2    x3       x4   x5        x6
## 1  1   1    13     1 Pasteur     7 3.333333 7.75 0.375 2.333333 5.75 1.2857143
## 2  2   2    13     7 Pasteur     7 5.333333 5.25 2.125 1.666667 3.00 1.2857143
## 3  3   2    13     1 Pasteur     7 4.500000 5.25 1.875 1.000000 1.75 0.4285714
## 4  4   1    13     2 Pasteur     7 5.333333 7.75 3.000 2.666667 4.50 2.4285714
## 5  5   2    12     2 Pasteur     7 4.833333 4.75 0.875 2.666667 4.00 2.5714286
## 6  6   2    14     1 Pasteur     7 5.333333 5.00 2.250 1.000000 3.00 0.8571429
##         x7   x8       x9
## 1 3.391304 5.75 6.361111
## 2 3.782609 6.25 7.916667
## 3 3.260870 3.90 4.416667
## 4 3.000000 5.30 4.861111
## 5 3.695652 6.30 5.916667
## 6 4.347826 6.65 7.500000

Yol modelinin oluşturulması denemeleri

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(lavaan)
library(semPlot)


dat <- HolzingerSwineford1939 %>%
  rename(
    GorselAlgi    = x1,
    Kupler        = x2,
    Test        = x3,
    ParagrafAnlama= x4,
    GenelBilgi    = x5,
    CumleTamamlama= x6,
    KelimeAnlami  = x7,
    KelimeSinifi  = x8,
    Toplama       = x9
  )

print(names(dat))
##  [1] "id"             "sex"            "ageyr"          "agemo"         
##  [5] "school"         "grade"          "GorselAlgi"     "Kupler"        
##  [9] "Test"           "ParagrafAnlama" "GenelBilgi"     "CumleTamamlama"
## [13] "KelimeAnlami"   "KelimeSinifi"   "Toplama"
model <- ' GorselAlgi   ~  Kupler
 
          ParagrafAnlama ~ GenelBilgi +  KelimeAnlami + CumleTamamlama
  
       GenelBilgi  ~ GorselAlgi +  ParagrafAnlama + Test'


   fit <- sem(model, data = dat)

semPaths(fit,rotation=2, curvePivot = TRUE,
           sizeMan = 12, sizeInt = 1, 
            sizeLat = 4,
           edge.label.cex = 1.8,
           pastel=TRUE,
           nCharNodes = 0, nCharEdges = 0)

summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-19 ended normally after 24 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        10
## 
##   Number of observations                           301
## 
## Model Test User Model:
##                                                       
##   Test statistic                                85.461
##   Degrees of freedom                                 8
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               619.340
##   Degrees of freedom                                15
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.872
##   Tucker-Lewis Index (TLI)                       0.760
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1181.955
##   Loglikelihood unrestricted model (H1)      -1139.224
##                                                       
##   Akaike (AIC)                                2383.909
##   Bayesian (BIC)                              2420.980
##   Sample-size adjusted Bayesian (SABIC)       2389.266
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.179
##   90 Percent confidence interval - lower         0.146
##   90 Percent confidence interval - upper         0.215
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.117
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   GorselAlgi ~                                                          
##     Kupler            0.295    0.055    5.403    0.000    0.295    0.297
##   ParagrafAnlama ~                                                      
##     GenelBilgi       -1.181    0.298   -3.967    0.000   -1.181   -1.338
##     KelimeAnlami      0.117    0.087    1.339    0.181    0.117    0.111
##     CumleTamamlama    1.736    0.268    6.475    0.000    1.736    1.654
##   GenelBilgi ~                                                          
##     GorselAlgi       -0.094    0.049   -1.929    0.054   -0.094   -0.084
##     ParagrafAnlama    1.200    0.072   16.752    0.000    1.200    1.059
##     Test             -0.065    0.051   -1.270    0.204   -0.065   -0.057
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .GorselAlgi        1.238    0.101   12.268    0.000    1.238    0.912
##    .ParagrafAnlama    2.579    0.791    3.262    0.001    2.579    1.957
##    .GenelBilgi        0.946    0.102    9.307    0.000    0.946    0.559
fitmeasures(fit,fit.measures = c("chisq" ,"df" ,"pvalue",
                                     "cfi","tli","rmsea",    
                                     "rmsea.ci.lower","rmsea.ci.upper"
                                     ,"srmr"))
##          chisq             df         pvalue            cfi            tli 
##         85.461          8.000          0.000          0.872          0.760 
##          rmsea rmsea.ci.lower rmsea.ci.upper           srmr 
##          0.179          0.146          0.215          0.117

GorselAlgi ~ Kupler Estimate = 0.295, p < .001: Kupler testinden alınan puan arttıkça GorselAlgi puanı da anlamlı biçimde artıyor. Pozitif ve anlamlı bir ilişki var (β = 0.297 standardized).

ParagrafAnlama ~ GenelBilgi + KelimeAnlami + CumleTamamlama GenelBilgi → ParagrafAnlama: Estimate = -1.181, p < .001 Beklenmedik biçimde negatif ve anlamlı. GenelBilgi arttıkça ParagrafAnlama düşüyor gibi görünüyor (standardized: -1.338), bu çok büyük ve olumsuz bir etki. Modeldeki değişken ilişkilerini tekrar kontrol etmek gerekebilir.

KelimeAnlami → ParagrafAnlama: Estimate = 0.117, p = 0.181 Anlamlı değil (p > .05), etkisi zayıf (standardized: 0.111)

CumleTamamlama → ParagrafAnlama: Estimate = 1.736, p < .001 Güçlü ve anlamlı bir pozitif ilişki (β = 1.654) → ParagrafAnlama’yı pozitif etkiliyor.

GenelBilgi ~ GorselAlgi + ParagrafAnlama + Test GorselAlgi → GenelBilgi: Estimate = -0.094, p = 0.054 Anlamlılık sınırında (p ≈ .05), küçük bir negatif etki. Standardized: -0.084

ParagrafAnlama → GenelBilgi: Estimate = 1.200, p < .001 Çok anlamlı ve güçlü pozitif bir ilişki (β = 1.059)

Test → GenelBilgi: Estimate = -0.065, p = 0.204 Anlamlı değil, etki zayıf (β = -0.057)

** Ki kare düşük p anlamlı ama uyum indeksleri peki iyi değil tahminlerde daha iyi olabilir bu bilgilere göre modeli tekrar düzenliyorum

model1 <- ' GorselAlgi   ~  Kupler
 
          ParagrafAnlama ~   CumleTamamlama
  
       GenelBilgi  ~   ParagrafAnlama '


fit1 <- sem(model1, data = dat)


fit1 <- sem(model1, data = dat)

semPaths(fit1,rotation=2, curvePivot = TRUE,
           sizeMan = 12, sizeInt = 1, 
            sizeLat = 4,
           edge.label.cex = 1.8,
           pastel=TRUE,
           nCharNodes = 0, nCharEdges = 0)

summary(fit1, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-19 ended normally after 6 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         7
## 
##   Number of observations                           301
## 
## Model Test User Model:
##                                                       
##   Test statistic                               101.928
##   Degrees of freedom                                 5
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               568.452
##   Degrees of freedom                                 9
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.827
##   Tucker-Lewis Index (TLI)                       0.688
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1215.632
##   Loglikelihood unrestricted model (H1)      -1164.668
##                                                       
##   Akaike (AIC)                                2445.264
##   Bayesian (BIC)                              2471.213
##   Sample-size adjusted Bayesian (SABIC)       2449.013
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.254
##   90 Percent confidence interval - lower         0.212
##   90 Percent confidence interval - upper         0.298
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.143
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   GorselAlgi ~                                                          
##     Kupler            0.294    0.055    5.389    0.000    0.294    0.297
##   ParagrafAnlama ~                                                      
##     CumleTamamlama    0.749    0.043   17.221    0.000    0.749    0.704
##   GenelBilgi ~                                                          
##     ParagrafAnlama    0.807    0.043   18.583    0.000    0.807    0.731
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .GorselAlgi ~~                                                         
##    .GenelBilgi        0.021    0.056    0.366    0.714    0.021    0.021
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .GorselAlgi        1.238    0.101   12.268    0.000    1.238    0.912
##    .ParagrafAnlama    0.680    0.055   12.268    0.000    0.680    0.504
##    .GenelBilgi        0.768    0.063   12.268    0.000    0.768    0.466
fitmeasures(fit1,fit.measures = c("chisq" ,"df" ,"pvalue",
                                     "cfi","tli","rmsea",    
                                     "rmsea.ci.lower","rmsea.ci.upper"
                                     ,"srmr"))
##          chisq             df         pvalue            cfi            tli 
##        101.928          5.000          0.000          0.827          0.688 
##          rmsea rmsea.ci.lower rmsea.ci.upper           srmr 
##          0.254          0.212          0.298          0.143

** İkinci modelde tahminler daha kuvvetli ancak veri değişken çıkardığım için varyans düştü ve istenile uyumlar yakalanmadı modifikasyonlarla daha güzel bir model oluşturmaya çalışacağım

resid(fit1, type='normalized')
## $type
## [1] "normalized"
## 
## $cov
##                GrslAl PrgrfA GnlBlg Kupler CmlTmm
## GorselAlgi      0.006                            
## ParagrafAnlama  5.817  0.000                     
## GenelBilgi      4.515  0.084  0.103              
## Kupler          0.016  0.423  1.015  0.000       
## CumleTamamlama  5.747  0.000  5.173  0.000  0.000
modindices(fit1, sort = TRUE)
##               lhs op            rhs     mi    epc sepc.lv sepc.all sepc.nox
## 21     GenelBilgi  ~ CumleTamamlama 52.962  0.473   0.473    0.403    0.369
## 12 ParagrafAnlama ~~     GenelBilgi 52.962 -0.430  -0.430   -0.595   -0.595
## 17 ParagrafAnlama  ~     GenelBilgi 51.624 -0.553  -0.553   -0.611   -0.611
## 28 CumleTamamlama  ~     GenelBilgi 43.875  0.599   0.599    0.702    0.702
## 13     GorselAlgi  ~ ParagrafAnlama 36.048  0.334   0.334    0.334    0.334
## 14     GorselAlgi  ~     GenelBilgi 36.048  0.414   0.414    0.456    0.456
## 15     GorselAlgi  ~ CumleTamamlama 29.567  0.325   0.325    0.305    0.279
## 26 CumleTamamlama  ~     GorselAlgi 23.801  0.239   0.239    0.254    0.254
## 22         Kupler  ~     GorselAlgi 22.709 -1.288  -1.288   -1.277   -1.277
## 11     GorselAlgi ~~ ParagrafAnlama  9.512  0.163   0.163    0.178    0.178
## 16 ParagrafAnlama  ~     GorselAlgi  8.836  0.121   0.121    0.122    0.122
## 19     GenelBilgi  ~     GorselAlgi  0.520  0.106   0.106    0.097    0.097
## 20     GenelBilgi  ~         Kupler  0.520  0.031   0.031    0.029    0.024
## 18 ParagrafAnlama  ~         Kupler  0.186  0.018   0.018    0.018    0.015
## 23         Kupler  ~ ParagrafAnlama  0.045  0.008   0.008    0.008    0.008
## 27 CumleTamamlama  ~ ParagrafAnlama  0.045 -0.041  -0.041   -0.043   -0.043
## 24         Kupler  ~     GenelBilgi  0.000  0.000   0.000    0.000    0.000
## 8          Kupler ~~         Kupler  0.000  0.000   0.000    0.000    0.000
## 25         Kupler  ~ CumleTamamlama  0.000  0.000   0.000    0.000    0.000
## 9          Kupler ~~ CumleTamamlama  0.000  0.000   0.000       NA    0.000
## 10 CumleTamamlama ~~ CumleTamamlama  0.000  0.000   0.000    0.000    0.000
## 29 CumleTamamlama  ~         Kupler  0.000  0.000   0.000    0.000    0.000

** Artık değerlerden elde edilen verilerle önerilen modifikasyonlar birbiri ile oldukça uyumlu. Artık değeri büyük olan ilişkiler için modifikasyon önerileri yapılmış. ilk modifikasyonu modele ekleyeceğim.

model2 <- ' GorselAlgi   ~  Kupler
 
          ParagrafAnlama ~   CumleTamamlama
  
       GenelBilgi  ~   ParagrafAnlama 
      GenelBilgi  ~   CumleTamamlama   '





fit2 <- sem(model2, data = dat)

semPaths(fit2,rotation=2, curvePivot = TRUE,
           sizeMan = 12, sizeInt = 1, 
            sizeLat = 4,
           edge.label.cex = 1.8,
           pastel=TRUE,
           nCharNodes = 0, nCharEdges = 0)

summary(fit2, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-19 ended normally after 7 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         8
## 
##   Number of observations                           301
## 
## Model Test User Model:
##                                                       
##   Test statistic                                42.910
##   Degrees of freedom                                 4
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               568.452
##   Degrees of freedom                                 9
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.930
##   Tucker-Lewis Index (TLI)                       0.844
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1186.123
##   Loglikelihood unrestricted model (H1)      -1164.668
##                                                       
##   Akaike (AIC)                                2388.246
##   Bayesian (BIC)                              2417.903
##   Sample-size adjusted Bayesian (SABIC)       2392.531
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.180
##   90 Percent confidence interval - lower         0.134
##   90 Percent confidence interval - upper         0.230
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.135
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   GorselAlgi ~                                                          
##     Kupler            0.294    0.055    5.398    0.000    0.294    0.297
##   ParagrafAnlama ~                                                      
##     CumleTamamlama    0.749    0.043   17.221    0.000    0.749    0.704
##   GenelBilgi ~                                                          
##     ParagrafAnlama    0.502    0.055    9.053    0.000    0.502    0.451
##     CumleTamamlama    0.479    0.059    8.123    0.000    0.479    0.404
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .GorselAlgi ~~                                                         
##    .GenelBilgi       -0.027    0.051   -0.533    0.594   -0.027   -0.031
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .GorselAlgi        1.238    0.101   12.268    0.000    1.238    0.912
##    .ParagrafAnlama    0.680    0.055   12.268    0.000    0.680    0.504
##    .GenelBilgi        0.631    0.051   12.268    0.000    0.631    0.376
fitmeasures(fit1,fit.measures = c("chisq" ,"df" ,"pvalue",
                                     "cfi","tli","rmsea",    
                                     "rmsea.ci.lower","rmsea.ci.upper"
                                     ,"srmr"))
##          chisq             df         pvalue            cfi            tli 
##        101.928          5.000          0.000          0.827          0.688 
##          rmsea rmsea.ci.lower rmsea.ci.upper           srmr 
##          0.254          0.212          0.298          0.143

Cumle tamamlamaın paragraf anlamayla beraber yordadığı modeli deneyelim.

model3 <- ' GorselAlgi   ~  Kupler
 
          ParagrafAnlama ~   CumleTamamlama
  
       GenelBilgi  ~   ParagrafAnlama + CumleTamamlama   '   
       
fit3 <- sem(model3, data = dat)

semPaths(fit3,rotation=2, curvePivot = TRUE,
           sizeMan = 12, sizeInt = 1, 
            sizeLat = 4,
           edge.label.cex = 1.8,
           pastel=TRUE,
           nCharNodes = 0, nCharEdges = 0)

summary(fit3, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-19 ended normally after 7 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         8
## 
##   Number of observations                           301
## 
## Model Test User Model:
##                                                       
##   Test statistic                                42.910
##   Degrees of freedom                                 4
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               568.452
##   Degrees of freedom                                 9
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.930
##   Tucker-Lewis Index (TLI)                       0.844
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1186.123
##   Loglikelihood unrestricted model (H1)      -1164.668
##                                                       
##   Akaike (AIC)                                2388.246
##   Bayesian (BIC)                              2417.903
##   Sample-size adjusted Bayesian (SABIC)       2392.531
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.180
##   90 Percent confidence interval - lower         0.134
##   90 Percent confidence interval - upper         0.230
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.135
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   GorselAlgi ~                                                          
##     Kupler            0.294    0.055    5.398    0.000    0.294    0.297
##   ParagrafAnlama ~                                                      
##     CumleTamamlama    0.749    0.043   17.221    0.000    0.749    0.704
##   GenelBilgi ~                                                          
##     ParagrafAnlama    0.502    0.055    9.053    0.000    0.502    0.451
##     CumleTamamlama    0.479    0.059    8.123    0.000    0.479    0.404
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .GorselAlgi ~~                                                         
##    .GenelBilgi       -0.027    0.051   -0.533    0.594   -0.027   -0.031
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .GorselAlgi        1.238    0.101   12.268    0.000    1.238    0.912
##    .ParagrafAnlama    0.680    0.055   12.268    0.000    0.680    0.504
##    .GenelBilgi        0.631    0.051   12.268    0.000    0.631    0.376
fitmeasures(fit3,fit.measures = c("chisq" ,"df" ,"pvalue",
                                     "cfi","tli","rmsea",    
                                     "rmsea.ci.lower","rmsea.ci.upper"
                                     ,"srmr"))
##          chisq             df         pvalue            cfi            tli 
##         42.910          4.000          0.000          0.930          0.844 
##          rmsea rmsea.ci.lower rmsea.ci.upper           srmr 
##          0.180          0.134          0.230          0.135

Uyum indeksleri çok daha iyi ve yeterli kabul edilebilir tlı biraz daha yüksek olabilir. Oluşturulan nihai yol analizinin katsayılarını ve anlamlılık düzeylerini şekilde gösterelim

kts <- 
semPaths(fit3, whatLabels = "est",
sizeMan = 10,
edge.label.cex = 1.15,
style = "ram",layout = "spring" ,
nCharNodes = 0, nCharEdges = 0)

anlm <- semptools::mark_sig(kts, fit3)
plot(anlm)

**hamodelde kurduğumuz ililkilere ait katsayılır anlamlı. Şekilde anlamsız ve küçük değerler korelasyon ve kovaryans değerleri.

summary(fit3, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-19 ended normally after 7 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         8
## 
##   Number of observations                           301
## 
## Model Test User Model:
##                                                       
##   Test statistic                                42.910
##   Degrees of freedom                                 4
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               568.452
##   Degrees of freedom                                 9
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.930
##   Tucker-Lewis Index (TLI)                       0.844
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1186.123
##   Loglikelihood unrestricted model (H1)      -1164.668
##                                                       
##   Akaike (AIC)                                2388.246
##   Bayesian (BIC)                              2417.903
##   Sample-size adjusted Bayesian (SABIC)       2392.531
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.180
##   90 Percent confidence interval - lower         0.134
##   90 Percent confidence interval - upper         0.230
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.135
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   GorselAlgi ~                                                          
##     Kupler            0.294    0.055    5.398    0.000    0.294    0.297
##   ParagrafAnlama ~                                                      
##     CumleTamamlama    0.749    0.043   17.221    0.000    0.749    0.704
##   GenelBilgi ~                                                          
##     ParagrafAnlama    0.502    0.055    9.053    0.000    0.502    0.451
##     CumleTamamlama    0.479    0.059    8.123    0.000    0.479    0.404
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .GorselAlgi ~~                                                         
##    .GenelBilgi       -0.027    0.051   -0.533    0.594   -0.027   -0.031
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .GorselAlgi        1.238    0.101   12.268    0.000    1.238    0.912
##    .ParagrafAnlama    0.680    0.055   12.268    0.000    0.680    0.504
##    .GenelBilgi        0.631    0.051   12.268    0.000    0.631    0.376
fitmeasures(fit3,fit.measures = c("chisq" ,"df" ,"pvalue",
                                     "cfi","tli","rmsea",    
                                     "rmsea.ci.lower","rmsea.ci.upper"
                                     ,"srmr"))
##          chisq             df         pvalue            cfi            tli 
##         42.910          4.000          0.000          0.930          0.844 
##          rmsea rmsea.ci.lower rmsea.ci.upper           srmr 
##          0.180          0.134          0.230          0.135

** Nihai modeldeki uyum indeksleri oldukça iyi. RMSEA ve SRMR değerleri çok iyi durumda. CFI ve TLI değerleri de oldukça iyi.

** Nihai modeldeki değişkenlerin ilişkileri ve anlamlılıklarıda makul.

Modellerin karşılaştırılması

fitmeasures(fit,fit.measures = c("AIC","BIC"))
##      aic      bic 
## 2383.909 2420.980
fitmeasures(fit1,fit.measures = c("AIC","BIC"))
##      aic      bic 
## 2445.264 2471.213
fitmeasures(fit2,fit.measures = c("AIC","BIC"))
##      aic      bic 
## 2388.246 2417.903
fitmeasures(fit3,fit.measures = c("AIC","BIC"))
##      aic      bic 
## 2388.246 2417.903

** Son modelin diğer modellere göre daha uygun olduğu görülmektedir. Son modelin aic ve bic değerleri diğer modellere göre daha düşük.

Model sonuçlarının rapor edilmesi

library(knitr)
standardizedsolution(fit3) %>% 
  filter(op == "~") %>% 
  select('Bağımlı Değişkenler'=lhs, Gosterge=rhs,
         B=est.std, SE=se, Z=z, 'p-value'=pvalue) %>% 
  knitr::kable(digits = 3, booktabs=TRUE, format="markdown",
               caption="Yol Katsayıları ve Anlamlılık ")
Yol Katsayıları ve Anlamlılık
Bağımlı Değişkenler Gosterge B SE Z p-value
GorselAlgi Kupler 0.297 0.051 5.782 0
ParagrafAnlama CumleTamamlama 0.704 0.025 27.984 0
GenelBilgi ParagrafAnlama 0.451 0.048 9.438 0
GenelBilgi CumleTamamlama 0.404 0.048 8.492 0

Doğrudan, dolaylı ve toplam etki hesaplama

Doğrudan etkiler

library(lavaan)
library(dplyr)


# Standartize edilmiş çözümü al
effects <- standardizedSolution(fit3)

direct_effects <- standardizedSolution(fit3) %>% 
  filter(op == "~") %>% 
  select(Yolu = lhs, Etkileyen = rhs, Beta = est.std)

# Sonuçları göster
print(direct_effects)
##             Yolu      Etkileyen  Beta
## 1     GorselAlgi         Kupler 0.297
## 2 ParagrafAnlama CumleTamamlama 0.704
## 3     GenelBilgi ParagrafAnlama 0.451
## 4     GenelBilgi CumleTamamlama 0.404

Dolaylı etki

# Standartize edilmiş çözümü al
effects <- standardizedSolution(fit3)

# 1. Doğrudan etkileri ayıklayalım
a_path <- effects %>% 
  filter(lhs == "ParagrafAnlama" & rhs == "CumleTamamlama") %>% 
  pull(est.std)  

b_path <- effects %>% 
  filter(lhs == "GenelBilgi" & rhs == "ParagrafAnlama") %>% 
  pull(est.std)  

# 2. Dolaylı etkiyi hesapla (a*b)
indirect_effect <- a_path * b_path  


# Sonucu göster
print(indirect_effect)
## [1] 0.3175766

**Semoutput paketin yükleyemediğim için kikare karşılaştırmalarına bakamadım

Aracı değişken analizi

library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
fit4 <- lm(GenelBilgi ~ CumleTamamlama, data = dat)


fita <- lm(ParagrafAnlama ~ CumleTamamlama, data = dat)


fitb <- lm(GenelBilgi ~ ParagrafAnlama + CumleTamamlama, data = dat)


fitc <- lm(CumleTamamlama ~ GenelBilgi + ParagrafAnlama, data = dat)

stargazer(fit4, fita, fitb, fitc, type = "text", title = "Baron and Kenny Yöntemi ile Aracılık Etkisi",digits = 2,
          font.size ="tiny")
## 
## Baron and Kenny Yöntemi ile Aracılık Etkisi
## ===================================================================================================================
##                                                           Dependent variable:                                      
##                     -----------------------------------------------------------------------------------------------
##                           GenelBilgi            ParagrafAnlama            GenelBilgi            CumleTamamlama     
##                               (1)                     (2)                     (3)                     (4)          
## -------------------------------------------------------------------------------------------------------------------
## GenelBilgi                                                                                          0.37***        
##                                                                                                     (0.05)         
##                                                                                                                    
## ParagrafAnlama                                                              0.50***                 0.36***        
##                                                                             (0.06)                  (0.05)         
##                                                                                                                    
## CumleTamamlama              0.85***                 0.75***                 0.48***                                
##                             (0.05)                  (0.04)                  (0.06)                                 
##                                                                                                                    
## Constant                    2.49***                 1.42***                 1.78***                -0.54***        
##                             (0.12)                  (0.11)                  (0.13)                  (0.14)         
##                                                                                                                    
## -------------------------------------------------------------------------------------------------------------------
## Observations                  301                     301                     301                     301          
## R2                           0.52                    0.50                    0.62                    0.59          
## Adjusted R2                  0.52                    0.49                    0.62                    0.58          
## Residual Std. Error     0.90 (df = 299)         0.83 (df = 299)         0.80 (df = 298)         0.71 (df = 298)    
## F Statistic         321.76*** (df = 1; 299) 294.60*** (df = 1; 299) 242.81*** (df = 2; 298) 210.73*** (df = 2; 298)
## ===================================================================================================================
## Note:                                                                                   *p<0.1; **p<0.05; ***p<0.01

CumleTamamlama’nın GenelBilgi üzerinde toplam etkisi olduğunu gösterir (Etki: 0.85, p < .001) Etki: 0.75 CumleTamamlama’nın aracı değişken ParagrafAnlama üzerinde anlamlı etkisi olduğunu gösterir (Etki: 0.75, p < .001)

Her iki değişken de GenelBilgi üzerinde anlamlı. Bu, kısmi aracılık olduğunu gösterir çünkü CumleTamamlama etkisi tamamen kaybolmamış, ama azalmış ParagrafAnlama etkisi: 0.50 (***)

CumleTamamlama etkisi: 0.48 (***)

library(multilevel)
## Zorunlu paket yükleniyor: nlme
## 
## Attaching package: 'nlme'
## The following object is masked from 'package:dplyr':
## 
##     collapse
## Zorunlu paket yükleniyor: MASS
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
sobel(dat$GenelBilgi, dat$ParagrafAnlama, dat$CumleTamamlama)
## $`Mod1: Y~X`
##               Estimate Std. Error   t value     Pr(>|t|)
## (Intercept) -0.4675257 0.15428300 -3.030312 2.656524e-03
## pred         0.6112379 0.03407541 17.937800 2.373361e-49
## 
## $`Mod2: Y~X+M`
##               Estimate Std. Error   t value     Pr(>|t|)
## (Intercept) -0.5358792 0.14364658 -3.730539 2.287285e-04
## pred         0.3734997 0.04654416  8.024631 2.362117e-14
## med          0.3594567 0.05159617  6.966732 2.082921e-11
## 
## $`Mod3: M~X`
##              Estimate Std. Error   t value     Pr(>|t|)
## (Intercept) 0.1901577 0.16063007  1.183824 2.374231e-01
## pred        0.6613822 0.03547725 18.642433 5.322365e-52
## 
## $Indirect.Effect
## [1] 0.2377383
## 
## $SE
## [1] 0.03642977
## 
## $z.value
## [1] 6.525933
## 
## $N
## [1] 301
library(bda)
## Zorunlu paket yükleniyor: boot
## bda - 18.3.2
attach(dat)
mediation.test(CumleTamamlama,ParagrafAnlama,GenelBilgi)
##                Sobel       Aroian      Goodman
## z.value 7.269377e+00 7.259274e+00 7.279523e+00
## p.value 3.611481e-13 3.891739e-13 3.350019e-13

**aracı etki istatistiksel olarak anlamlı (p<0,001, p= 0.0000000000003611481)

library(mediation)
## Zorunlu paket yükleniyor: Matrix
## Zorunlu paket yükleniyor: mvtnorm
## Zorunlu paket yükleniyor: sandwich
## mediation: Causal Mediation Analysis
## Version: 4.5.0
## 
## Attaching package: 'mediation'
## The following object is masked from 'dat':
## 
##     school
library(gvlma)

fitM <- lm(ParagrafAnlama ~ CumleTamamlama, data=dat)  
fitY <- lm(GenelBilgi ~ CumleTamamlama + ParagrafAnlama, data=dat)

gvlma(fitM)
## 
## Call:
## lm(formula = ParagrafAnlama ~ CumleTamamlama, data = dat)
## 
## Coefficients:
##    (Intercept)  CumleTamamlama  
##         1.4249          0.7485  
## 
## 
## ASSESSMENT OF THE LINEAR MODEL ASSUMPTIONS
## USING THE GLOBAL TEST ON 4 DEGREES-OF-FREEDOM:
## Level of Significance =  0.05 
## 
## Call:
##  gvlma(x = fitM) 
## 
##                     Value p-value                Decision
## Global Stat        4.1491  0.3862 Assumptions acceptable.
## Skewness           0.1620  0.6873 Assumptions acceptable.
## Kurtosis           0.8148  0.3667 Assumptions acceptable.
## Link Function      2.3030  0.1291 Assumptions acceptable.
## Heteroscedasticity 0.8693  0.3512 Assumptions acceptable.
gvlma(fitY)
## 
## Call:
## lm(formula = GenelBilgi ~ CumleTamamlama + ParagrafAnlama, data = dat)
## 
## Coefficients:
##    (Intercept)  CumleTamamlama  ParagrafAnlama  
##         1.7785          0.4757          0.4973  
## 
## 
## ASSESSMENT OF THE LINEAR MODEL ASSUMPTIONS
## USING THE GLOBAL TEST ON 4 DEGREES-OF-FREEDOM:
## Level of Significance =  0.05 
## 
## Call:
##  gvlma(x = fitY) 
## 
##                      Value   p-value                   Decision
## Global Stat        40.3884 3.597e-08 Assumptions NOT satisfied!
## Skewness            0.8014 3.707e-01    Assumptions acceptable.
## Kurtosis            0.9839 3.212e-01    Assumptions acceptable.
## Link Function      38.2485 6.228e-10 Assumptions NOT satisfied!
## Heteroscedasticity  0.3546 5.515e-01    Assumptions acceptable.

**Y modelinde doğrusallık sorunu mevcut.

fitMed <- mediate(fitM, fitY, treat="CumleTamamlama", mediator="ParagrafAnlama")
summary(fitMed)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value    
## ACME              0.373        0.277         0.46  <2e-16 ***
## ADE               0.475        0.355         0.59  <2e-16 ***
## Total Effect      0.847        0.757         0.94  <2e-16 ***
## Prop. Mediated    0.439        0.333         0.55  <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 301 
## 
## 
## Simulations: 1000

**aracılık etkisi anlamlı (0,373), doğrudan etki anlamlı (0,474)i toplam etki anlamlı (0,846)

oran=0,373/0,846=0,440 (Aracı değişkenin toplam etkideki oranı)

fitMedBoot <- mediate(fitM, fitY, boot=TRUE, sims=999, treat="CumleTamamlama", mediator="ParagrafAnlama")
## Running nonparametric bootstrap
summary(fitMedBoot)
## 
## Causal Mediation Analysis 
## 
## Nonparametric Bootstrap Confidence Intervals with the Percentile Method
## 
##                Estimate 95% CI Lower 95% CI Upper p-value    
## ACME              0.372        0.280         0.48  <2e-16 ***
## ADE               0.476        0.354         0.59  <2e-16 ***
## Total Effect      0.848        0.754         0.95  <2e-16 ***
## Prop. Mediated    0.439        0.331         0.56  <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 301 
## 
## 
## Simulations: 999

# Farklı örneklemlerde de sonuçlar benzer çıktı. Değerler anlamlı.