Can Non-linear regression be used for time series forecasting?
Show older comments
Hey,
Matlab has an example on analyzing a sample time series: Airline passenger data ( link ). In the end of the page, the presented code works very well in incorporating the most relevant information from the input data in constructing a non-linear regression model.
My question is can I use the created model to predict the future data? How?
Answers (1)
jgg
on 14 Jan 2016
The short answer is yes. At this point in the example:
[b,bint,resid] = regress(logts.data, X);
They've returned a set of coefficients for the independent variables in X. When they plot the fitted data they do the following: X*b.
You can do the same for future, or out of sample data. Set up a new matrix X_f which is the dependent variables for the future times, whatever those might be; in their example it would be time and month dummies. Then, get the predicted values Y_f = X_f*b.
4 Comments
jgg
on 16 Jan 2016
I'm unclear why you want to fit an autoregessive model, though. This is a modeling decision which needs to be made for your actual data. If you want to do this:
X = [dummyvar(mo(:)), logts.time];
Y = logts.data;
f = @(c,x) [Y(1); c(1)*Y(1:end-1) + (x(2:end,:)- c(1)*x(1:end-1,:))*c(2:end)];
c = nlinfit(X,Y,f,[r;b]);
This code generates, exactly as before, a coefficient vector c which you can use to predict future values. The only issue is that now you need to do it iteratively.
Y_fit = @(X,Y_l,X_l)(c(1)*Y_l + (X - rho*X_l)*b)
Create a vector of future X_values X_f with the last actuals in the first place. Then, if X_last and Y_last are the last actual data you observed, compute for each future time period:
Y_f(2) = Y_fit(X_f(2),Y_f(1),X_f(1))
And repeat the process for each time period using a loop. The only issue here is you have to "kickstart" this process by setting Y_f(1) = Y_last and X_f(1) = X_last.
Ehsan na
on 18 Jan 2016
jgg
on 18 Jan 2016
Accept this answer if you think it solves your problem so other people can see it.
Categories
Find more on Linear Predictive Coding in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!