简体   繁体   English

R中的非线性回归分析

[英]Non-linear regression analysis in R

I'm a R novice but I'm looking for a way to determine the three parameters A, B and C related by the following function in R: 我是R新手,但我正在寻找一种方法来确定R中以下函数相关的三个参数A,B和C:

y = A * (x1^B) * (x2^C)

Can someone give me some hints about R method(s) that would help me to achieve such a fitting? 有人可以给我一些关于R方法的提示,这有助于我实现这样的拟合吗?

One option is the nls function as @SvenHohenstein suggested. 一个选项是@SvenHohenstein建议的nls函数。 Another option is to convert your nonlinear regression into a linear regression. 另一种选择是将非线性回归转换为线性回归。 In the case of this equation just take the log of both sides of the equation and do a little algebra and you will have a linear equation. 在这个等式的情况下,只需取两个方程的对数并做一个小代数,你将得到一个线性方程。 You can run the regression using something like: 您可以使用以下内容运行回归:

fit <- lm( log(y) ~ log(x1) + log(x2), data=mydata)

The intercept will be log(A) so use exp to get the value, the B and C parameters will be the 2 slopes. 截距将为log(A)因此使用exp得到值,B和C参数将是2个斜率。

The big difference here is that nls will fit the model with normal errors added to the original equation and the lm fit with logs assumes that the errors in the original model are from a lognormal distribution and are multiplied instead of added to the model. 这里的最大区别在于nls将适合模型,其中正常的误差被添加到原始方程中,而lm与日志拟合假设原始模型中的误差来自对数正态分布并且相乘而不是添加到模型中。 Many datasets will give similar results for the 2 methods. 许多数据集将为这两种方法提供类似的结果。

您可以使用函数nls拟合非线性最小二乘模型。

nls(y ~ A * (x1^B) * (x2^C))

Why don´t you use SVM (Suppor Vector Machines) Regression? 为什么不使用SVM(Suppor Vector Machines)回归? there´sa package in CRAN named e1071 that can handle regression with SVM. 在CRAN中有一个名为e1071软件包可以处理SVM的回归。

You can check this tutorial: http://www.svm-tutorial.com/2014/10/support-vector-regression-r/ 您可以查看本教程: http//www.svm-tutorial.com/2014/10/support-vector-regression-r/

I hope it can help you 我希望它可以帮到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM