library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(broom) # test çıktısını tabloya çevirme
library(ggplot2) # görselleştirme
#Wilcoxon Signed-Rank Testi
program_oncesi = c(25,28,30,27,26,29,31,28)
program_sonrasi = c(22,25,27,24,23,26,28,25)
stres_veri <- data.frame(id = 1:8, program_oncesi = c(25,28,30,27,26,29,31,28), program_sonrasi = c(22,25,27,24,23,26,28,25))
stres_veri
## id program_oncesi program_sonrasi
## 1 1 25 22
## 2 2 28 25
## 3 3 30 27
## 4 4 27 24
## 5 5 26 23
## 6 6 29 26
## 7 7 31 28
## 8 8 28 25
veri_long <- stres_veri %>% pivot_longer(cols = c(program_oncesi , program_sonrasi),
names_to = "zaman", values_to = "stres")
veri_long
## # A tibble: 16 × 3
## id zaman stres
## <int> <chr> <dbl>
## 1 1 program_oncesi 25
## 2 1 program_sonrasi 22
## 3 2 program_oncesi 28
## 4 2 program_sonrasi 25
## 5 3 program_oncesi 30
## 6 3 program_sonrasi 27
## 7 4 program_oncesi 27
## 8 4 program_sonrasi 24
## 9 5 program_oncesi 26
## 10 5 program_sonrasi 23
## 11 6 program_oncesi 29
## 12 6 program_sonrasi 26
## 13 7 program_oncesi 31
## 14 7 program_sonrasi 28
## 15 8 program_oncesi 28
## 16 8 program_sonrasi 25
ggplot(veri_long, aes(x = zaman , y = stres , group = id)) + geom_line(alpha=0.4)+
geom_point(size = 2)+ labs(title = "Program Öncesi ve Sonrası Stres", x = "Zaman", y = "Stres")+ theme_minimal()
ggplot(veri_long, aes(x= zaman, y= stres, fill = zaman))+geom_boxplot(alpha=0.6)+geom_jitter(width = 0.1 , alpha = 0.6)+ theme_minimal()
sonuc_stres <- wilcox.test(stres_veri$program_oncesi,stres_veri$program_sonrasi,
paired = TRUE)
## Warning in wilcox.test.default(stres_veri$program_oncesi,
## stres_veri$program_sonrasi, : cannot compute exact p-value with ties
sonuc_stres
##
## Wilcoxon signed rank test with continuity correction
##
## data: stres_veri$program_oncesi and stres_veri$program_sonrasi
## V = 36, p-value = 0.005962
## alternative hypothesis: true location shift is not equal to 0
Wilcoxon SigneRank testi sonuçları , psikoeğitim programı sonrasında stres düzeylerinin anlamlı biçimde azaldığını göstermiştir. ( V= 36, p<.05).