【问题标题】:How to find the best regression model fit for your plot如何找到适合您的情节的最佳回归模型
【发布时间】:2021-03-07 09:23:57
【问题描述】:

假设我希望将回归模型拟合到来自 mtcars 数据集的 disp ~ drat。有没有我可以使用的包可以告诉我应该使用哪种类型的回归,例如线性、多项式、贝叶斯等?

ggplot(mtcars, aes(disp, drat)) +
  geom_point() +
  facet_wrap(~cyl)  

【问题讨论】:

  • 即使存在,你也不应该使用它。 (我很担心你的例子。它们都是相互正交的,也就是说,你可以拟合一个线性、多项式和贝叶斯的模型)。
  • 这是一本可能对Tidy Modeling with R 有帮助的书,作者是 Max Kuhn 和 Julia Silge。
  • R之外,还有一个很酷的东西'eureqa'datarobot.com/nutonian

标签: r regression tidyverse linear-regression non-linear-regression


【解决方案1】:

指出 @Roland 的建议,您应该先进行一些探索性和可视化分析,以了解您的数据。你可以试试stat_smooth(),然后决定你要适合什么样的模型:

library(ggplot2)
#Code
ggplot(mtcars, aes(disp, drat)) +
  geom_point() +
  facet_wrap(~cyl)+
  stat_smooth(se=F)+
  stat_smooth(color='magenta',method = 'lm',se=F)

输出:

【讨论】:

  • 感谢所有 cmets!因此,您将仅通过视觉分析来决定模型,而不是例如adj.R2、P 还是 AIC?
猜你喜欢
  • 2022-11-07
  • 2019-11-11
  • 1970-01-01
  • 2021-03-15
  • 2014-12-02
  • 2019-05-09
  • 1970-01-01
  • 2021-11-28
  • 2018-03-17
相关资源
最近更新 更多