MATLAB: Non-linear regression

gaoptimizationregression

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.

Best Answer

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.