Non-linear regression
1 次查看(过去 30 天)
显示 更早的评论
Hey everyone,
I want to make long-term load forecasting using GA. So the first step is to come up with a model, in one of the papers the objective function is a polynomial of tenth order:
obj= c10*x.^10 + c9*x.^9 + c8*x.^8 + c7*x.^7 + c6*x.^6 + c5*x.^5 + c4*x.^4 + c3*x.^3 + c2*x.^2 + c1*x.^1 + c0*x.^0;
In order to make the obj function ready for the GA I need to estimate the coefficients.
The rest of my code is as follows:
>> f = @(c,x) 1 + c(1)*x.^1 + c(2)*x.^2 + c(3)*x.^3 + c(4)*x.^4 + c(5)*x.^5 + c(6)*x.^6 + c(7)*x.^7 + c(8)*x.^8 + c(9)*x.^9 + c(10)*x.^10;
>> cfit = nlinfit(xdata,ydata,f,c)
all the data that I have are the years from 1982 till 1991 and the corresponding demand in each year.
I didn't understand nlinfit quite well,, what I am supposed to put in place of xdata, ydata and c.
Any help will be appreciated.
0 个评论
采纳的回答
Image Analyst
2011-12-19
Why do you call that non-linear regression? It's just a regular polynomial and it's linear in the coefficients, c. You don't have c(6)^2 or log(c(5)) or anything non-linear like that. It's just c(#) to the first power multiplied by the x to some power. Because your x are non-linear does not make it non-linear regression. All your c's are linear so it's linear regression. So you can simply use polyfit() and simplify your life.
9 个评论
Walter Roberson
2011-12-20
Hmmm, that's probably provable, too -- though it could plausibly be the case that if the zeros were carefully positioned at decreasing intervals that at least one measure of the swing might decrease.... Yes, indeed, I have just constructed a sequence whose zeros do not change, but whose maximums swing less and less as the length of the sequence increases. Certainly, though, in my first trial series the maximums increased distinctly as the length of the sequence increased.
Ho Nam Ernest Yim
2018-4-4
Can I know are there any other methods I can use also to compare the performances among methods. I used nlinfit and lsqcurvefit, I looked up and found fitnlm and lsqnonlin are same as the about methods. And I have looked into different methods such as ridge , robust , polyfit but none of them fit the case that lsqcurvefit is considering : as in lsqcurvefit(fun,x0,xdata,ydata) *nonlinear case Please help me =( , I have been looking at it for a while
更多回答(4 个)
Richard Willey
2011-12-19
I'd strongly suggestion that you watch a webinar titled "Electricity Load and Price Forecasting with MATLAB". The webinar is available at: http://www.mathworks.com/company/events/webinars/wbnr51423.html
All of the code and the data sets are available on MATLAB Central.
This webinar shows two different ways to model the demand for electric power. The first is based on a neural network. The second uses bagged decision trees. The code also includes safeguards to protect against overfitting.
I'm also going to point you at a blog posting that I wrote on data driven fitting. If you are primarily worried about interpolation you might find this a useful alternative to high order polynomials
Greg Heath
2011-12-19
You definitely do not want a high order polynomial for prediction.
Check out Richard's references.
Greg
0 个评论
Richard Willey
2011-12-20
For what its worth, I just took a very quick look at the data set that you provided.
years = [1982 1983 1984 1985 1986 1987 1988 1989 1990 1991];
load = [1702 2344 2097 2313 2588 2885 4341 4779 5251 5721];
You can fit the years 1988 --> 1991 with an almost perfectly straight line. In a similar fashion, the years 1984 --> 1987 with another straight line. In both cases the R^2 is over .995.
I really don't understand that approach that you're taking... I feel like you're trying to force Genetic Algorithms into the solution space regardless of whether this is warranted.
Given that you're primarily interested in using GA, there's one last resource that I'd recommend looking at:
The "Global Optimization with MATLAB Products" provides a very good introduction to GA. You can watch the webinar at: http://www.mathworks.com/company/events/webinars/wbnr43346.html?seq=1
All of the code is available for download from MATLAB Central.
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!