R语言回归分析如何使用nls()拟合幂函数
x <- 1:20y <- 3x^2+ 30rnorm(20)plot(x,y)fit <- nls(y ~ a*x^b, start = list(a=2, b= 1.5))lines(seq(1, 20, by = 0.1), predict(fit, data.frame(x=seq(1, 20, by = 0.1))))fit以下为函数 output:Nonlinear
x <- 1:20
y <- 3x^2+ 30rnorm(20)
plot(x,y)
fit <- nls(y ~ a*x^b, start = list(a=2, b= 1.5))
lines(seq(1, 20, by = 0.1), predict(fit, data.frame(x=seq(1, 20, by = 0.1))))
fit
以下为函数 output:
Nonlinear regression model
model: y ~ a * x^b
data: parent.frame()
a b
3.366 1.963
residual sum-of-squares: 16158
Number of iterations to convergence: 6
Achieved convergence tolerance: 4.238e-07

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)