我有一个用
计算的指数模型 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
我得到:
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()
并复制并粘贴我想要的信息,但我必须做很多不同的模型,所以我想要一些自动的东西。谢谢!
答案 0 :(得分:2)
尝试这一点,第一行将生成我们可以在此示例中使用的绘图 下一行添加所需的文本:
example(nls)
legend("topleft", legend = capture.output(summary(nlmod)), cex = .5)