If we have a multiple linear regression model:
lm(life ~ male + birth + divo + beds + educ + inco, data =
DATA)
(1) What R command should we use to plot it standardized residuals
against the FITTED values?
(2) What R command should we use to compute and plot the leverage
of each point and identify the points that have a leverage larger
than 0.5?
(3) What R command should we use to compute the Cook's distance for
each point and identify the points that have Cook's distance larger
than 1?
I didn't attach the actual data here as I only want to know the R command need to accomplish the above tasks. Thanks
As you have a R code for a multiple linear regression model
model = lm(life ~ male + birth + divo + beds + educ + inco, data = DATA)
# (1) What R command should we use to plot it standardized residuals against the FITTED values?
Solution:
standarized_val = rstandard(model)
plot(standarized_val, DATA$life,
ylab="Standardized Residuals",
xlab="FITTED values",
main="Plots: Std residuals vs FITTED values")
# (2) What R command should we use to compute and plot the leverage of each point and identify the points that have a leverage larger than 0.5?
Solution:
lev = hatvalues(model)
plot(lev,col=ifelse(lev>0.5,"red","black"))
#(3) What R command should we use to compute the Cook's distance
for each point and identify the points that have Cook's distance
larger than 1?
Solution:
cook <- cooks.distance(model)
plot(cook,col=ifelse(cook>1,"red","black"))
Get Answers For Free
Most questions answered within 1 hours.