Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Experimental Design in R

Cursus bekijken

Oefeninstructies

  • Use aov() to create nhanes_rcbd. Recall that the treatment is stored in mcq365d and you're testing the outcome bmxwt, with the blocking factor riagendr.
  • Examine the results of nhanes_rcbd with summary().
  • Use dplyr functions to examine the mean weights by mcq365d and riagendr.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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 = ___(___))
Code bewerken en uitvoeren