library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── 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(lsr)
library(car)
## Zorunlu paket yükleniyor: carData
##
## Attaching package: 'car'
##
## The following object is masked from 'package:dplyr':
##
## recode
##
## The following object is masked from 'package:purrr':
##
## some
set.seed(1923)
deney_grubu <- rnorm(50, mean = 45, sd = 8) # İlaç verilen grup (deney grubu)
kontrol_grubu <- rnorm(50, mean = 52, sd = 8) # Plasebo verilen grup (kontrol grubu)
fare_verisi <- data.frame( grup = rep(c( "Deney", "Kontrol"), each = 50)) %>%
mutate( sure = round(c(deney_grubu, kontrol_grubu), 2))
head(fare_verisi)
## grup sure
## 1 Deney 39.81
## 2 Deney 45.56
## 3 Deney 53.49
## 4 Deney 56.08
## 5 Deney 52.47
## 6 Deney 42.59
fare_istatistik <- fare_verisi %>%
group_by(grup) %>%
summarise( N = n(), Ortalama = mean(sure), Standart_sapma = sd(sure))
print(fare_istatistik)
## # A tibble: 2 × 4
## grup N Ortalama Standart_sapma
## <chr> <int> <dbl> <dbl>
## 1 Deney 50 45.2 8.81
## 2 Kontrol 50 52.4 7.92
Varsayımların Test Edilmesi 1. normallik testi # Her grup için ayrı ayrı normallik testi
fare_verisi %>%
group_by(grup) %>%
summarise(shapiro_p = shapiro.test(sure)$p.value)
## # A tibble: 2 × 2
## grup shapiro_p
## <chr> <dbl>
## 1 Deney 0.409
## 2 Kontrol 0.810
car ::leveneTest( sure ~ grup, data = fare_verisi)
## Warning in leveneTest.default(y = y, group = group, ...): group coerced to
## factor.
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 1 0.5295 0.4686
## 98
#Bağımsız örneklem t-testi
sonuc <- t.test (sure ~ grup, data = fare_verisi, var.equal = TRUE)
print(sonuc)
##
## Two Sample t-test
##
## data: sure by grup
## t = -4.3425, df = 98, p-value = 3.436e-05
## alternative hypothesis: true difference in means between group Deney and group Kontrol is not equal to 0
## 95 percent confidence interval:
## -10.601619 -3.951181
## sample estimates:
## mean in group Deney mean in group Kontrol
## 45.1614 52.4378
ggplot(fare_verisi, aes( x = grup, y = sure, fill = grup)) +
geom_boxplot(width = 0.5, color = "black", alpha = 0.7) +
theme_minimal() +
scale_fill_manual(values = c( "#2E8B57" , "#CD5C5C")) +
labs(title = " İlaç (Deney) ve Plasebo (Kontrol) Gruplarının Labirent Tamamlama Sureleri",
subtitle = "Deney grubunun daha hızlı olduğu (sürenin düşük olduğu) görülmektedir.", x= "Grup" , y= "Sure (Saniye)")