library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.1     ✔ stringr   1.5.2
## ✔ 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)
library(ggplot2)

Egzersiz yapmayan psikoloji öğrencilerine uygulanan psikoeğitim programı, stres düzeylerini anlamlı biçimde düşürür mü?

Bağımlı değişken: Stres puanı

program_öncesi = c(25,28,30,27,26,29,31,28)
program_sonrası = c(22,25,27,24,23,26,28,25)

Aynı bireylerin iki farklı zamandaki ölçümleri: program_öncesi → psikoeğitim öncesi stres düzeyleri program_sonrası → psikoeğitim sonrası stres düzeyleri

stres_veri <- data.frame(
  id=1:8,
  program_öncesi = c(25,28,30,27,26,29,31,28),
  program_sonrası = c(22,25,27,24,23,26,28,25)
)

stres_veri
##   id program_öncesi program_sonrası
## 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_öncesi, program_sonrası),
    names_to = "zaman",
    values_to = "stres"
  )
veri_long
## # A tibble: 16 × 3
##       id zaman           stres
##    <int> <chr>           <dbl>
##  1     1 program_öncesi     25
##  2     1 program_sonrası    22
##  3     2 program_öncesi     28
##  4     2 program_sonrası    25
##  5     3 program_öncesi     30
##  6     3 program_sonrası    27
##  7     4 program_öncesi     27
##  8     4 program_sonrası    24
##  9     5 program_öncesi     26
## 10     5 program_sonrası    23
## 11     6 program_öncesi     29
## 12     6 program_sonrası    26
## 13     7 program_öncesi     31
## 14     7 program_sonrası    28
## 15     8 program_öncesi     28
## 16     8 program_sonrası    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_grey()

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_öncesi,
  stres_veri$program_sonrası,
  paried = TRUE
)
## Warning in wilcox.test.default(stres_veri$program_öncesi,
## stres_veri$program_sonrası, : cannot compute exact p-value with ties
sonuc_stres
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  stres_veri$program_öncesi and stres_veri$program_sonrası
## W = 55, p-value = 0.01729
## alternative hypothesis: true location shift is not equal to 0

wilcoxon signed-rank testi sonuçları, psikoeğitim programı sonrasında stres düzeylerinin anlamlı biçimde azaldığını göstermiştir (V=36, p<.05).