Yol Analizi
Yol analizi, bağımlı değişken ile iki veya daha fazla bağımlı değişken arasındaki ilişkileri inceleyerek nedensel modelleri değerlendirmek için kullanılan bir istatistiksel analiz yöntemidir.
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.4.3
##
## 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(haven)
## Warning: package 'haven' was built under R version 4.4.3
ogrenci <- read_sav("veri.sav")
colnames(ogrenci) <- c("ID","TOT","MAT01","MAT02","MAT03","MAT04","MAT05","SEVME0","SEVME1","OZGUVEN0","OZGUVEN1","DEGER0","DEGER1")
ogrenci <- na.omit(ogrenci)
yol_model <- ' OZGUVEN1 ~ MAT01
SEVME1 ~ MAT01
DEGER1 ~ OZGUVEN1 + SEVME1
OZGUVEN1 ~~ SEVME1'
library(lavaan)
## Warning: package 'lavaan' was built under R version 4.4.3
## This is lavaan 0.6-21
## lavaan is FREE software! Please report any bugs.
yol_fit <- sem(yol_model, ogrenci)
library(semPlot)
semPaths(yol_fit,rotation=2, curvePivot = TRUE,
sizeMan = 12, sizeInt = 1,
sizeLat = 4,
edge.label.cex = 1.8,
pastel=TRUE,
nCharNodes = 0, nCharEdges = 0)
fitmeasures(yol_fit,fit.measures = c("chisq" ,"df" , "pvalue"))
## chisq df pvalue
## 9.438 1.000 0.002
fitMeasures(yol_fit, c("rmsea","rmsea.ci.lower",
"rmsea.ci.upper","rmsea.pvalue"))
## rmsea rmsea.ci.lower rmsea.ci.upper rmsea.pvalue
## 0.042 0.021 0.069 0.641
fitMeasures(yol_fit, "srmr")
## srmr
## 0.01
fitmeasures(yol_fit,fit.measures = c("cfi","tli","nnfi"))
## cfi tli nnfi
## 0.998 0.990 0.990
fitmeasures(yol_fit,fit.measures = c("chisq" ,"df" ,"pvalue",
"cfi","tli","rmsea",
"rmsea.ci.lower","rmsea.ci.upper"
,"srmr"))
## chisq df pvalue cfi tli
## 9.438 1.000 0.002 0.998 0.990
## rmsea rmsea.ci.lower rmsea.ci.upper srmr
## 0.042 0.021 0.069 0.010
resid(yol_fit, type='normalized')
## $type
## [1] "normalized"
##
## $cov
## OZGUVE SEVME1 DEGER1 MAT01
## OZGUVEN1 0.00
## SEVME1 0.00 0.00
## DEGER1 0.00 0.00 0.00
## MAT01 0.00 0.00 -2.23 0.00
modindices(yol_fit, sort = TRUE)
## lhs op rhs mi epc sepc.lv sepc.all sepc.nox
## 13 OZGUVEN1 ~ DEGER1 9.429 -0.076 -0.076 -0.082 -0.082
## 10 OZGUVEN1 ~~ DEGER1 9.429 -0.033 -0.033 -0.082 -0.082
## 16 DEGER1 ~ MAT01 9.429 0.000 0.000 -0.045 0.000
## 19 MAT01 ~ DEGER1 9.429 -8.953 -8.953 -0.063 -0.063
Modelin Yeniden Tanımlanması
yol_model_v1 <-
'OZGUVEN1 ~ MAT01
DEGER1 ~ OZGUVEN1 + SEVME1
OZGUVEN1 ~~ DEGER1
OZGUVEN1 ~~ SEVME1'
yol_fit_v1 <- sem(yol_model_v1, ogrenci)
semPaths(yol_fit_v1,rotation=2, curvePivot = TRUE,
sizeMan = 12, sizeInt = 1,
sizeLat = 4,
edge.label.cex = 1.8,
pastel=TRUE,
nCharNodes = 0, nCharEdges = 0)
fitmeasures(yol_fit_v1,fit.measures=c("chisq","p","df"))
## chisq df
## 497.812 1.000
p_pa <-
semPaths(yol_fit_v1, whatLabels = "est",
sizeMan = 10,
edge.label.cex = 1.15,
style = "ram",layout = "spring" ,
nCharNodes = 0, nCharEdges = 0)
p_pa_2 <- semptools::mark_sig(p_pa, yol_fit_v1)
plot(p_pa_2)
summary(yol_fit)
## lavaan 0.6-21 ended normally after 22 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 8
##
## Number of observations 4713
##
## Model Test User Model:
##
## Test statistic 9.438
## Degrees of freedom 1
## P-value (Chi-square) 0.002
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|)
## OZGUVEN1 ~
## MAT01 -0.004 0.000 -44.429 0.000
## SEVME1 ~
## MAT01 -0.002 0.000 -22.914 0.000
## DEGER1 ~
## OZGUVEN1 0.095 0.016 5.806 0.000
## SEVME1 0.483 0.015 32.123 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .OZGUVEN1 ~~
## .SEVME1 0.232 0.007 31.477 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .OZGUVEN1 0.367 0.008 48.544 0.000
## .SEVME1 0.553 0.011 48.544 0.000
## .DEGER1 0.432 0.009 48.544 0.000
standardizedsolution(yol_fit)
## lhs op rhs est.std se z pvalue ci.lower ci.upper
## 1 OZGUVEN1 ~ MAT01 -0.543 0.009 -57.320 0 -0.562 -0.525
## 2 SEVME1 ~ MAT01 -0.317 0.013 -24.786 0 -0.342 -0.292
## 3 DEGER1 ~ OZGUVEN1 0.088 0.015 5.818 0 0.058 0.117
## 4 DEGER1 ~ SEVME1 0.485 0.014 34.931 0 0.457 0.512
## 5 OZGUVEN1 ~~ SEVME1 0.516 0.011 48.266 0 0.495 0.537
## 6 OZGUVEN1 ~~ OZGUVEN1 0.705 0.010 68.429 0 0.685 0.725
## 7 SEVME1 ~~ SEVME1 0.900 0.008 111.242 0 0.884 0.916
## 8 DEGER1 ~~ DEGER1 0.708 0.011 63.618 0 0.686 0.730
## 9 MAT01 ~~ MAT01 1.000 0.000 NA NA 1.000 1.000
Standartlaştırılmış Artık
fitted(yol_fit)$cov
## OZGUVE SEVME1 DEGER1 MAT01
## OZGUVEN1 0.520
## SEVME1 0.330 0.615
## DEGER1 0.209 0.328 0.610
## MAT01 -43.294 -27.420 -17.351 12206.404
inspectSampleCov(yol_fit,data=ogrenci)
## Warning: 'inspectSampleCov' is deprecated.
## Use 'lavInspectSampleCov' instead.
## See help("Deprecated")
## $cov
## OZGUVE SEVME1 DEGER1 MAT01
## OZGUVEN1 0.520
## SEVME1 0.330 0.615
## DEGER1 0.209 0.328 0.610
## MAT01 -43.294 -27.420 -20.078 12206.404
parameterEstimates(yol_fit,standardized = TRUE)
## lhs op rhs est se z pvalue ci.lower ci.upper
## 1 OZGUVEN1 ~ MAT01 -0.004 0.000 -44.429 0 -0.004 -0.003
## 2 SEVME1 ~ MAT01 -0.002 0.000 -22.914 0 -0.002 -0.002
## 3 DEGER1 ~ OZGUVEN1 0.095 0.016 5.806 0 0.063 0.127
## 4 DEGER1 ~ SEVME1 0.483 0.015 32.123 0 0.454 0.512
## 5 OZGUVEN1 ~~ SEVME1 0.232 0.007 31.477 0 0.218 0.247
## 6 OZGUVEN1 ~~ OZGUVEN1 0.367 0.008 48.544 0 0.352 0.381
## 7 SEVME1 ~~ SEVME1 0.553 0.011 48.544 0 0.531 0.575
## 8 DEGER1 ~~ DEGER1 0.432 0.009 48.544 0 0.415 0.450
## 9 MAT01 ~~ MAT01 12206.404 0.000 NA NA 12206.404 12206.404
## std.lv std.all std.nox
## 1 -0.004 -0.543 -0.005
## 2 -0.002 -0.317 -0.003
## 3 0.095 0.088 0.088
## 4 0.483 0.485 0.485
## 5 0.232 0.516 0.516
## 6 0.367 0.705 0.705
## 7 0.553 0.900 0.900
## 8 0.432 0.708 0.708
## 9 12206.404 1.000 12206.404
inspect(yol_fit, "rsquare")
## OZGUVEN1 SEVME1 DEGER1
## 0.295 0.100 0.292
library(knitr)
## Warning: package 'knitr' was built under R version 4.4.3
standardizedsolution(yol_fit) %>%
filter(op == "~") %>%
select('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="Factor Loadings")
| Değişkenler | Gosterge | B | SE | Z | p-value |
|---|---|---|---|---|---|
| OZGUVEN1 | MAT01 | -0.543 | 0.009 | -57.320 | 0 |
| SEVME1 | MAT01 | -0.317 | 0.013 | -24.786 | 0 |
| DEGER1 | OZGUVEN1 | 0.088 | 0.015 | 5.818 | 0 |
| DEGER1 | SEVME1 | 0.485 | 0.014 | 34.931 | 0 |