如何在R中的依赖vs预测图中添加对角线

How to add the diagonal line in depended vs predict plot in R

我进行了回归分析。 现在我需要创建图 depended vs prediction,其中 depend 是相关变量(mpg)的初始值,predict 是预测值。

 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")

如何在依赖与预测图中添加对角线(黄色)? 注意 Y 轴是依赖变量,X 轴是预测值。

我期待输出

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") +

  geom_abline(intercept = 0, slope = 1, col="yellow")