Geom_smooth: 添加组时,迭代次数超过最大值50?
Geom_smooth: When groups added, number of iterations exceeded maximum of 50?
我是模特界的新手。我有三组数据(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)
结果:
代码提供错误(在 aes
中添加了 group = period
),并且不显示每组行:
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 中的迭代次数吗?
我找到了一些信息以相对于 R 基础建模 control=nls.control(maxiter=200)
https://stat.ethz.ch/pipermail/r-help/2006-June/107606.html 增加迭代次数,但我找不到 ggplot2 的解决方案或方向。
根据@Axeman 的评论,我将 control=nls.control(maxiter=200)
添加到
method.args = list(start=c(a=20, b=0.01),
control=nls.control(maxiter=200))
整个脚本是这样的:
ggplot(tab, aes(x=distance, y=grad, group = period, col = period)) + #
geom_point(col = "grey") + theme_bw() +
geom_smooth(method = "nls",
formula = y ~ a*x^(-b),
method.args = list(start=c(a=20, b=0.01),
control=nls.control(maxiter=200)), #
se = F)
结果是:
我是模特界的新手。我有三组数据(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)
结果:
代码提供错误(在 aes
中添加了 group = period
),并且不显示每组行:
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 中的迭代次数吗?
我找到了一些信息以相对于 R 基础建模 control=nls.control(maxiter=200)
https://stat.ethz.ch/pipermail/r-help/2006-June/107606.html 增加迭代次数,但我找不到 ggplot2 的解决方案或方向。
根据@Axeman 的评论,我将 control=nls.control(maxiter=200)
添加到
method.args = list(start=c(a=20, b=0.01),
control=nls.control(maxiter=200))
整个脚本是这样的:
ggplot(tab, aes(x=distance, y=grad, group = period, col = period)) + #
geom_point(col = "grey") + theme_bw() +
geom_smooth(method = "nls",
formula = y ~ a*x^(-b),
method.args = list(start=c(a=20, b=0.01),
control=nls.control(maxiter=200)), #
se = F)
结果是: