简体   繁体   English

对 R 中的非线性 function 进行线性回归

[英]Do a linear regression on a non-linear function in R

I'm not quite sure to understand clearly how non-linear regression can be analysed in R.我不太清楚如何在 R 中分析非线性回归。 I found that I can still do a linear regression with lm by using the log of my functions.我发现我仍然可以使用函数的日志对 lm 进行线性回归。
My first function is this one, where β1 is the intercept, β2 is the slope and ε is the error term:我的第一个 function 就是这个,其中 β1 是截距,β2 是斜率,ε 是误差项:

在此处输入图像描述

I think that the following command gives me what I want:我认为以下命令给了我想要的东西:

result <- lm(log(Y) ~ log(X1), data=dataset)

The problem is with the following function:问题在于以下 function:

在此处输入图像描述

I don't know what should I put inside the lm in order to perform a linear regression on my function... Any idea?我不知道我应该在 lm 中放什么才能对我的 function 执行线性回归...知道吗?

The following math shows how to transform your equation into a linear regression:以下数学显示了如何将方程转换为线性回归:

Y = b0*exp(b1*X1 + epsilon)
log(Y) = log(b0) + b1*X1 + epsilon
log(Y) = c0 + b1*X1 + epsilon

So in R this is just所以在 R 这只是

lm(log(Y) ~ X, data = your_data)

You won't get a direct estimate for b0 , though, just an estimate of log(b0) .但是,您不会得到b0的直接估计值,而只是对log(b0)的估计值。 But you can back-transform the intercept and its confidence intervals by exponentiating them.但是您可以通过取幂来反向转换截距及其置信区间。

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

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