我在建模方面很陌生。我有三组数据(period
),我希望通过散点图上的线条显示。
我想出了如何将我的方法和公式放在geom_smooth
中,并且我能够显示一行。
但是,当我想为每个组添加行数时,可以通过ggplot(.., aes(..,group = period))
来完成,我已经回复了警告:
Warning message:
Computation failed in `stat_smooth()`:
number of iterations exceeded maximum of 50
并且不显示该行。
我的工作代码:
ggplot(tab, aes(x=distance, y=grad)) + #
geom_point() + theme_bw() +
geom_smooth(method = "nls",
formula = y ~ a*x^(-b),
method.args = list(start=c(a=20, b=0.01)), #
se = F)
结果:
代码提供错误(在group = period
中添加aes
),而不是每组显示行:
ggplot(tab, aes(x=distance, y=grad, group = period)) + #
geom_point() + theme_bw() +
geom_smooth(method = "nls",
formula = y ~ a*x^(-b),
method.args = list(start=c(a=20, b=0.01)), #
se = F)
您是否有一些想法如何通过geom_smooth函数增加ggplot2中的迭代次数?
我找到了一些信息来增加control=nls.control(maxiter=200)
https://stat.ethz.ch/pipermail/r-help/2006-June/107606.html相对于R基础建模的迭代次数,但我无法找到ggplot2的解决方案或方向。