Session Ready
Exercise

Residuals

Your null hypothesis is that there is no difference in ad preference accross categories of people. If this is the case then your values will be relatively even accross groups.

We now have a table with your expected values - called exptDat. These values represent what your data would look like under the null hypothesis. You also have a table with your observed values - called data. These values are what actually happened. Let's have a look at the difference between these values - known as the residuals.

While in real life you might have to calculate each value individually, in R you can do it in one line. Let's say you have table1 containing observed values and table2 containing expected values. To get the residuals, you would simply type residuals <- table1 - table2 and R would calculate the residuals for every cell at once, and assign it to a new object called "residuals" - cool, right?

Instructions
100 XP
  • Your observed values are saved in your console as data, and your expected values are saved as expDat.
  • Use expDat and data to calculate a table of residuals.
  • Assign your table of residuals to object resid.
  • Print resid and examine the output.