Sleep study data
Researchers enrolled 18 subjects in a sleep deprivation study. Their observed sleep_study
data are loaded in the workspace. These data contain the day_0
reaction times and day_3
reaction times after 3 sleep deprived nights for each subject
.
You will define and explore diff_3
, the observed difference in reaction times for each subject. This will require the mutate()
& summarize()
functions. For example, the following would add variable day_0_s
, day_0
reaction times in seconds, to sleep_study
:
sleep_study <- sleep_study %>%
mutate(day_0_s = day_0 * 0.001)
You can then summarize()
the day_0_s
values, here by their minimum & maximum:
sleep_study %>%
summarize(min(day_0_s), max(day_0_s))
This exercise is part of the course
Bayesian Modeling with RJAGS
Exercise instructions
- Check out the first 6 rows of
sleep_study
. - Define a new
sleep_study
variablediff_3
, theday_3
minus theday_0
reaction times. - Use
ggplot()
with ageom_histogram()
layer to construct a histogram of thediff_3
data. summarize()
the mean and standard deviation of thediff_3
observations.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Check out the first 6 rows of sleep_study
# Define diff_3
sleep_study <- sleep_study %>%
mutate(diff_3 = ___)
# Histogram of diff_3
ggplot(___, aes(x = ___)) +
geom_histogram(binwidth = 20, color = "white")
# Mean and standard deviation of diff_3
sleep_study %>%
summarize(___, ___)