相关疑难解决方法(0)

用ggpmisc显示nls模型的方程

Rggpmisc可用于显示lm模型和poly模型的方程ggplot2(参见此处参考).想知道如何使用nls模型方程结果.以下是我的MWE.ggplot2ggmisc

library(ggpmisc)
args <- list(formula = y ~ k * e ^ x,
             start = list(k = 1, e = 2))
ggplot(mtcars, aes(wt, mpg)) +
  geom_point() +
  stat_fit_augment(method = "nls",
                   method.args = args)
Run Code Online (Sandbox Code Playgroud)

r nls ggplot2 lm ggpmisc

14
推荐指数
2
解决办法
469
查看次数

ggplot R中的指数拟合

我一直在尝试使用 ggplot 和 geom_smooth 为我的数据拟合指数曲线。我正在尝试复制类似问题的答案(geom_smooth 和指数拟合),但不断收到以下错误消息:

> exp.model <-lm(y ~ exp(x), df)
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
  NA/NaN/Inf in 'x'
Run Code Online (Sandbox Code Playgroud)

我不明白错误,因为数据集中没有 NA/NaN/Inf 值:

>df
      x         y
1  1981  3.262897
2  1990  2.570096
3  2000  7.098903
4  2001  5.428424
5  2002  6.056302
6  2003  5.593942
7  2004 10.869635
8  2005 12.425793
9  2006  5.601889
10 2007  6.498187
11 2008  6.967503
12 2009  5.358961
13 2010  3.519295
14 2011  7.137202
15 2012 19.121631 …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 exponential

1
推荐指数
1
解决办法
5515
查看次数

标签 统计

ggplot2 ×2

r ×2

exponential ×1

ggpmisc ×1

lm ×1

nls ×1