Observed/Fitted Values and Residuals on Categorical Variables

Learn how to draw conclusions from the results of a regression on categorical variables.

Recall that we defined the following three concepts:

  • Observed values𝑦𝑦, or the observed value of the outcome variable

  • Fitted values y^ \hat y, or the value on the regression line for a given𝑥𝑥value

  • Residuals yy^y - \hat y, or the error between the observed value and the fitted value

We obtained these values and other values using the get_regression_points() function from the moderndive package. This time, however, let’s add an argument setting ID = "country" that tells the function to use the variable country in gapminder2007 as an identification variable in the output. This will help contextualize our analysis by matching values to countries.

Get hands-on with 1200+ tech skills courses.