Session Ready
Exercise

The systematic between-groups variance

To understand everything a bit better, you will calculate the F-ratio for a repeated measures design by yourself in the next exercises.

First, you will need the systematic between-groups variance. This is the same as in the between-groups design--the variance due to grouping by condition--so it shouldn't be totally new to you, but it can't hurt to refresh your memory.

Recall that the formula for systematic sum of squares is $$\begin{aligned} ss_a = n \sum(y_j - y_t)^2 \end{aligned} $$ where \(y_j\) are the group means, \(y_t\) is the grand mean and \(n\) is the number of items in each group with \(j\) the number of groups.

The formula for systematic variance is then $$ \begin{aligned} ms_a & = \frac{ss_a}{df_a} \end{aligned}$$ where \(df\) stands for the degrees of freedom which are set equal to the number of groups minus one.

You will keep working with the working memory example. The dataset wm is still loaded in your workspace.

Instructions
100 XP
  • Define the number of subjects n for each condition.
  • Calculate the group means for IQ gains iq by condition using the tapply() function. The tapply() function is used to group the observations for iq by the variable cond, then apply a function (in this case mean()) to each group. The first argument should be the column of data for which you want to calculate means and the second argument should be the column of data that defines the groups.
  • You also need the grand mean y_t to calculate the sum of squares. Use the mean() function to get this.
  • Now you have all the ingredients to calculate the between-groups sum of squares, ss_cond, by applying the first formula above.
  • Finally, calculate the systematic variance, ms_cond, using the second formula. You'll need to define the degrees of freedom, df, first.