NHANES RCBD
Recall that our blocked experiment involved a treatment wherein the doctor asks the patient to reduce their fat or calories in their diet, and we're testing the effect this has on weight (bmxwt
). We plan to block by gender, which in the NHANES dataset is stored as riagendr
. Recall that blocking is done to create experimental groups that are as similar as possible. Blocking this experiment by gender means that if we observe an effect of the treatment on bmxwt,
it's more likely that the effect was actually due to the treatment versus the individual's gender.
In your R code, you denote a blocked experiment by using a formula that looks like: outcome ~ treatment + blocking_factor
in the appropriate modeling function.
nhanes_final
is available.
This exercise is part of the course
Experimental Design in R
Exercise instructions
- Use
aov()
to createnhanes_rcbd
. Recall that the treatment is stored inmcq365d
and you're testing the outcomebmxwt
, with the blocking factorriagendr
. - Examine the results of
nhanes_rcbd
withsummary()
. - Use
dplyr
functions to examine the mean weights bymcq365d
andriagendr
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Use aov() to create nhanes_rcbd
___
# Check results of nhanes_rcbd with summary()
___
# Print mean weights by mcq365d and riagendr
___ %>%
group_by(___, ___) %>%
summarize(mean_wt = ___(___))