# Solved – Repeated measures ANOVA in R: Error(Subject) vs. Error(Subject/Day)

How should these two models be interpreted differently? Specifically, what is the circumstance where you would run one over the other?

``aov(Temperature~Day+Error(Subject))  aov(Temperature~Day+Error(Subject/Day))  ``

We'll use an example where I measured the temperature of 10 people once every day for a week. My main interest is to see if the temperature measurements change significantly day-to-day, and I am not interested in the longitudinal trend from Monday to Sunday.

Contents

Depending on the contrasts you are using, the R command

``aov(Temperature~Day+Error(Subject)) ``

fits a model like

\$\$y_{ij} = mu + beta_j + b_i + epsilon_{ij},\$\$

where \$y_{ij}\$ is the response value for the \$i\$th individual at the \$j\$th period (day), \$mu\$ is global mean, \$beta_j\$ is the effect of \$j\$th day, \$b_isim N(0,sigma_b^2)\$ is the Gaussian random effect or random intercept for the \$i\$th individual and \$epsilon_{ij}sim N(0,sigma^2)\$ is the Gaussian residual term. The unknown parameters are \$(mu, beta_j,sigma_b^2, sigma^2)\$.

On the other hand, the command

``aov(Temperature~Day+Error(Subject/Day))  ``

fits the model

\$\$y_{ijk} = mu + beta_j + b_i + b_{ij} + epsilon_{ijk},\$\$

where \$b_{ij}sim N(0, sigma_1^2)\$ is a Gaussian random individual-period interaction term. As you can see from the expression, to estimate also \$sigma_1^2\$ you need to have replications for each \$i\$ and \$j\$, that's the reason for the third index \$k\$.

Rate this post