sleep

references:
- ISI, exploration 6.2, p.340

library(tidyverse)
library(knitr)

hypotheses

\[H_0 : \mu_{unrestricted} - \mu_{deprived} = 0\] \[H_0 : \mu_{unrestricted} - \mu_{deprived} > 0\]

data

sleep.data <- read.delim("Sleep.txt")
str(sleep.data)
## 'data.frame':    21 obs. of  2 variables:
##  $ sleep: Factor w/ 2 levels "deprived","unrestricted": 2 2 2 2 2 2 2 2 2 2 ...
##  $ time : num  -7 11.6 12.1 12.6 14.5 18.6 25.2 30.5 34.5 45.6 ...

statistics

tbl <- sleep.data %>%
  group_by(sleep) %>%
  summarize(mean = mean(time),
            s = sd(time),
            n = n())
kable(tbl)
sleep mean s n
deprived 3.90 12.17185 11
unrestricted 19.82 14.72532 10

\[{diff}_{observed} = \bar{x}_{unrestricted} - \bar{x}_{deprived}\]

(x.bar.diff.observed <- tbl$mean[2] - tbl$mean[1])
## [1] 15.92

dot plots

ggplot(sleep.data, aes(time)) +
  geom_dotplot(fill = "darkred", dotsize = 1.0) +
  facet_grid(sleep ~ .) +
  labs(title = "Sleep")