## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ purrr     1.0.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
## 
## Attaching package: 'flextable'
## 
## 
## The following object is masked from 'package:purrr':
## 
##     compose

Ortalama için Hipotez Testi

Bu bölümde bir anakütle ortalaması için hipotez testleri yapılacaktır. Bu amaçla R içindeki mtcars veri seti kullanılacaktır.

Hipotezlerin Oluşturulması

Hipotez: 4 silindirli araçlar 1 galon benzin ile ortalama 20 milden fazla mesafe gider

Hipotezler \[H_0:\mu=20 \] \[H_1:\mu>20\] Aşağıdaki @tbl-tablo1’de mtcarsveri setine ait ilk 6 gözlem verilmektedir.

data("mtcars")
head(mtcars)|> flextable()

mpg

cyl

disp

hp

drat

wt

qsec

vs

am

gear

carb

21.0

6

160

110

3.90

2.620

16.46

0

1

4

4

21.0

6

160

110

3.90

2.875

17.02

0

1

4

4

22.8

4

108

93

3.85

2.320

18.61

1

1

4

1

21.4

6

258

110

3.08

3.215

19.44

1

0

3

1

18.7

8

360

175

3.15

3.440

17.02

0

0

3

2

18.1

6

225

105

2.76

3.460

20.22

1

0

3

1

4 silidirli otomobilleri veri seti içinden çekelim

mpg_4=mtcars$mpg[mtcars$cyl==4]
mpg_4
##  [1] 22.8 24.4 22.8 32.4 30.4 33.9 21.5 27.3 26.0 30.4 21.4
x_ort=mean(mpg_4)
x_ort
## [1] 26.66364
std_sapma=sd(mpg_4)
std_sapma
## [1] 4.509828
n=length(mpg_4)
t=round((x_ort-20)/(std_sapma/sqrt(n)),2)
t
## [1] 4.9

test istatistiği \[t=\frac{\bar x-\mu}{s/\sqrt{n}}=\frac{26.66-20}{4.51/\sqrt{11}}\]