嗨我想知道如何检索ggplot2中或矢量或其他地方的stat_smooth方程。我使用的代码是:接收ggplot2中stat_smooth的等式R mtcars示例
p <- ggplot(data = mtcars, aes(x = disp, y = drat))
p <- p + geom_point() + stat_smooth(method="loess")
p
感谢
嗨我想知道如何检索ggplot2中或矢量或其他地方的stat_smooth方程。我使用的代码是:接收ggplot2中stat_smooth的等式R mtcars示例
p <- ggplot(data = mtcars, aes(x = disp, y = drat))
p <- p + geom_point() + stat_smooth(method="loess")
p
感谢
的ggpmisc
包可以是非常有用的。但是,由于黄土不能提供配方,因此它不适用于黄土。在这里看到:Loess Fit and Resulting Equation
library(ggplot2)
library(ggpmisc)
p <- ggplot(data = mtcars, aes(x = disp, y = drat)) +
geom_point() +
geom_smooth(method="lm", formula=y~x) +
stat_poly_eq(parse=T, aes(label = ..eq.label..), formula=y~x)
p
那么是否有其他替代黄土功能?或不是 –
黄土是您的数据趋势的可视化。如果你想要一个方程,我会推荐应用线性模型,多项式回归或广义自适应模型(GAM)等回归技术。但是,在大多数情况下,您需要先定义_a先验数据,例如y〜x或y〜x + x^2之间的关系。这里是关于你的问题很好的不满:[链接](https://stackoverflow.com/questions/7550582/when-to-choose-nls-over-loess) – MikolajM
我认为你唯一的选择就是直接进入stat_smooth'的'代码。首先你的目标是什么? –
使用公式(最佳拟合)并将其推广到类似的数据拟合 –