Guiding questions

  1. In ANCOVA, we want to compare two or more groups while at the same time taking into account the effect of a continuous variable. For example, we might want to evaluate the effect of 2 different educational interventions for children in improving spelling while at the same time taking into account age differences. In this example, we would have:
  • a control group that did not receive any intervention;

  • a treatment group that received one of the educational interventions; and

  • another treatment group that received the other educational intervention.

Please simulate data assuming these 3 groups. These simulated data should resemble what is shown below, where each color represents a separate group:

This graph suggests a clear effect of age in spelling ability for all groups. Furthermore, we can see that these educational treatments (blue and red lines) increased spelling ability relative to the control group (black line) across all ages but that the 2nd treatment (red line) tended to outperform the 1st treatment (blue line).

  1. Once you have simulated these data, let’s fit a linear model. To this end, we will rely on the same tricks we used for ANOVA. In other words, we will create 2 binary variables because we have 3 treatments.

  2. Fit a linear model in a frequentist framework using the “lm” function

a - What is the p-value of the model? This is shown at the very bottom together with the F-statistic and should be identical to the one we get using the “aov” function.

b - Draw the regression lines for each group using the estimated parameters.

  1. Fit a linear model in a Bayesian framework using our JAGS code. Do our parameter estimates from the Bayesian model match those estimated using a frequentist framework?



Back to main menu

Comments?

Send me an email at