-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathttest_flipbook.Rmd
95 lines (76 loc) · 2.35 KB
/
ttest_flipbook.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
title: "How to t test"
author: "Peter Higgins"
output:
xaringan::moon_reader:
lib_dir: libs
css: xaringan-themer.css
nature:
ratio: 16:9
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
```{r setup, include = F}
# This is the recommended set up for flipbooks
# you might think about setting cache to TRUE as you gain practice --- building flipbooks from scratch can be time consuming
knitr::opts_chunk$set(fig.width = 6, message = FALSE, warning = FALSE, comment = "", cache = FALSE, fig.retina = 3)
library(flipbookr)
library(tidyverse)
library(infer)
library(medicaldata)
prostate <- medicaldata::blood_storage %>% as.tibble()
```
```{r xaringan-themer, include=FALSE, warning=FALSE}
library(xaringanthemer)
xaringanthemer::style_duo_accent(
primary_color = "#00274C",
secondary_color = "#FFCB05",
header_font_google = google_font("Lato"),
text_font_google = google_font("Manrope"),
code_font_google = google_font("Roboto Mono"),
base_font_size = "20px",
code_font_size = "2rem",
)
```
### We will start with the tidy version from the {infer} package: t_test()
#### Notice that you have to state the order of the two levels of your grouping variable
---
```{r ttest1, include = FALSE}
prostate %>%
t_test(TVol ~ AA,
order = c("0", "1"))
# Interpreting the results
# The t statistic is first
# followed by degrees of freedom
# then the p value
# the default alternative: two.sided
# then the confidence bounds
# output is a tibble so that it is
# easy to use these results
```
`r chunk_reveal("ttest1", break_type = "auto", title = "Tidy version from the {infer} package")`
---
### Now we will use the baseR version: t.test()
#### Notice that you have to use `data = .`
#### It is not quite as pipe-friendly
#### But you do not have to specify the order of the two levels.
---
```{r ttest2, include = FALSE}
prostate %>%
t.test(TVol ~ AA, data = .)
# Interpreting the results
# The t statistic is first
# followed by degrees of freedom
# then the p value
# then the alternative hypothesis
# then the confidence bounds
# then the mean mpg for each group
```
`r chunk_reveal("ttest2", break_type = "auto", title = "Base R Version")`
---
```{css, eval = TRUE, echo = FALSE}
.remark-code{line-height: 1.5; font-size: 80%}
```
### Which version of the t test do you like better?
Discuss.