I performed regression analysis.
Now i need create plot depended vs prediction
, where depend is initial values of dependent var(mpg) and predict is predicted values.
house_test=lm(mpg ~ 1 + hp + wt, data=mtcars)
prediction <- as.data.frame(predict(house_test, mtcars,
interval = 'prediction',
level = .95))
prediction$mpg <- mtcars$mpg
ggplot(prediction) +
geom_ribbon(aes(mpg, ymin = lwr, ymax = upr), fill = 'lightskyblue', alpha = 0.5) +
geom_point(aes(mpg, fit), alpha = 0.2) +
labs(title = "interval 95%CI", y = "depend", x = "predict")
How can i add the diagonal line(yellow color) in depended vs predict plot? Note Y axis is dependent var and X asis is prediction values.