Thank you so much for your answer. So I understand that you used these lines from the post I shared to calculate the residual, correct?
Step 1: fit <- lm(income ~ education + prestige, X)
Step 2: X$Residual <- residuals(fit) # Take out the effects of
educationandprestige
I am able to plot the boxplots now with your code without error :) Awesome!
Just for my understanding: In step 1 we build a model of the effect of education and prestige on income. In step 2 we remove the effect education and prestige on income
Correct?
Thanks again!
Please share example data and codes.