Session Ready
Exercise

Within groups sum of squares

To calculate the F-value, you also need the variance within groups. Similar to the last exercise, we'll start by computing the within groups sum of squares, which is equal to the following:

$$\begin{aligned} ss_{s/a} & = \sum(Y_{ij} - y_j)^2 \end{aligned}$$

where \(Y_{ij}\) are the individual scores and \(y_j\) are the group means. Now you are going to apply this formula yourself!

Instructions
100 XP
  • Create a separate vector of IQ gains (wm$iq) for each training group (wm$condition) using the subset() function. The first one has been done for you. Define them in order from the least amount of training to the most amount of training.
  • Now you can easily subtract each subject's IQ gain by its corresponding group mean. You already calculated the group means in the previous exercise, so use this result. The vector containing the four group means is called y_j and will need to be subsetting using [ ] notation to extract each mean.
  • Create a new vector, s_t, to combine s_1, s_2, s_3, and s_4 back into a single vector.
  • Calculate the within groups sum of squares. You just need to square the previous result and sum up the elements of the vector using the sum() function.