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))
Cet exercice fait partie du cours
Bayesian Modeling with RJAGS
Instructions
- Check out the first 6 rows of
sleep_study. - Define a new
sleep_studyvariablediff_3, theday_3minus theday_0reaction times. - Use
ggplot()with ageom_histogram()layer to construct a histogram of thediff_3data. summarize()the mean and standard deviation of thediff_3observations.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de 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(___, ___)