在绘图中打印模型 (nls) 特征
计算的指数模型
我有一个用mod <- nls(y ~ exp(- (x/a)^b), data = DF, start = list(a = 200, b = 1.4))
我使用以下方法绘制:
plot(x,y)
lines(sort(DF$x),predict(mod, list(x=sort(DF$x))), lwd=2, col="red")
写 mod
I得到:
Nonlinear regression model
model: y ~ exp(-(x/a)^b)
data: DF
a b
211.7098 0.3908
residual sum-of-squares: 17.69
Number of iterations to convergence: 5
Achieved convergence tolerance: 1.477e-07
使用 summary(mod)
我得到:
Formula: y ~ exp(-(x/a)^b)
Parameters:
Estimate Std. Error t value Pr(>|t|)
a 2.117e+02 2.799e+00 75.64 <2e-16 ***
b 3.908e-01 9.154e-03 42.69 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.08832 on 2268 degrees of freedom
Number of iterations to convergence: 5
Achieved convergence tolerance: 1.477e-07
(8 observations deleted due to missingness)
我的问题是是否有办法将公式、参数和残差平方和添加到图中?我能想到的唯一方法是使用 text()
并复制并粘贴我想要的信息,但我必须做很多不同的模型,所以我想要一些自动的东西。谢谢!
I have an exponential model calculated with
mod <- nls(y ~ exp(- (x/a)^b), data = DF, start = list(a = 200, b = 1.4))
which I plotted using:
plot(x,y)
lines(sort(DF$x),predict(mod, list(x=sort(DF$x))), lwd=2, col="red")
writting mod
I get:
Nonlinear regression model
model: y ~ exp(-(x/a)^b)
data: DF
a b
211.7098 0.3908
residual sum-of-squares: 17.69
Number of iterations to convergence: 5
Achieved convergence tolerance: 1.477e-07
With summary(mod)
I get:
Formula: y ~ exp(-(x/a)^b)
Parameters:
Estimate Std. Error t value Pr(>|t|)
a 2.117e+02 2.799e+00 75.64 <2e-16 ***
b 3.908e-01 9.154e-03 42.69 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.08832 on 2268 degrees of freedom
Number of iterations to convergence: 5
Achieved convergence tolerance: 1.477e-07
(8 observations deleted due to missingness)
My question is if there is a way of adding the formula, the parameters and the residual sum-of-squares to the plot? The only way I could come up with was using the text()
and copy and paste the info I wanted but I will have to do lots of different models so I would like something automatic. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试一下,第一行将生成一个我们可以在本例中使用的图,
下一行添加所需的文本:
Try this where the first line will produce a plot we can use in this example and
the next line adds the desired text: