How to get rid of high error linear regression for log-log model
3 次查看(过去 30 天)
显示 更早的评论
I have the function D = alpha*(Pop)^b1*(Gdp)^b2*d^b3. I turn this into a log-log model: ln(D)= ln(alpha)+ b1*ln(Pop)+b2*ln(Gdp)+b3*ln(d). Now I would like to find the b coefficients and the intercept(ln(alpha)). I have the values for D and the other variables. I take the natural log of these vectors and try to find the coefficients by regression. This works only the errors are way too large. Especially when turned back to original value with exp().Any help to minimize this error or another appraoch would be greatly appreciated.
distanceln = log(distancevec); POPln = log(POPvec); GDPln = log(GDPvec);demandln = log(Demandvec);
X = [ones(size(POPln)),POPln,GDPln,distanceln];
y = demandln;
b = X\y;
Y = X*b;
err = max(abs(y-Y));
0 个评论
采纳的回答
Star Strider
2017-1-11
This might be solvable with a simple nonlinear regression using fminsearch, avoiding the need to do the log transformation (considered to be inadvisable for the reason you have discovered).
Your ‘data.mat’ file has: ‘Demandvec’, ‘GDPvec’, ‘POPvec’, and ‘distancevec’. I assume that ‘d’ is ‘distancevec’, and you want to fit to ‘Demandvec’.
What is ‘alpha’? Are we estimating it as well?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!