Hi, I am totally newly in Matlab and I have a question.
I have a time series and I want to apply an AR(8) model to forecast the next 12 observations.
I dont think that I could understand/follow the Mathworks instructions.
Any help??
Thank you!

7 commentaires

José-Luis
José-Luis le 9 Juil 2014
Modifié(e) : José-Luis le 9 Juil 2014
What sort of system has so long a memory? Have you tried with simpler models first and checked that their parameters are significant?
Panty
Panty le 10 Juil 2014
Is GDP. I need to follow this AR(8) because is what I replicate from a paper.
Shashank Prasanna
Shashank Prasanna le 10 Juil 2014
Did you try the link I shared below? If you provide more information you may be able to get targetted replies.
José-Luis
José-Luis le 10 Juil 2014
Please state what specific problems you are running into or what particular aspect you don't understand. Trying to explain everything from scratch would be a painful exercise for both parts concerned.
If you are not familiar with Matlab, I recommend you to read the "Getting started" part of the documentation.
Panty
Panty le 10 Juil 2014
Well...I have a time series of 100 actual GDP. And I want to use an AR(8) model to recursively forecast the next period's GDP. At the end of the day, I want to get 12 forecasts of the next 12 periods ahead. I was thinking using something like:
yf = forecast(model,past_data,K) command, looping 12 times recursively.
So the first time I forecast, I add the GDP_101_forecasted into the sample and go forecasting the GDP_102. And do that recursively until I get forecasts for the next 12 periods ahead.
@Shashank Prasanna I dont know if your link is what I need. Maybe I couldnt understand what I read there.
By the way I am doing that, because I want to detrend (using HP filter) the actual GDP and get the potential GDP. But in the HP filter we face the end-of-sample problem which we may overcome by forecasting the next 12 observations before detrending.
Much appreciated.
Panty
Panty le 10 Juil 2014
By the way, do I need the 'System Identification Toolbox' for my case ???
I have the student version of Matlab&Simulink R2013a.
Guys.. Could you please help me??? I tried to wrote the script for what I wanted but I got some errors. Probably is wrong. I wrote the following: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[rows,columns]=size(NEW_ROUTPUTQVQ196520014)
for column=1:columns
InSampleData=NEW_ROUTPUTQVQ196520014(1:end,column)
for periods_ahead = 1:12
Mdl=arima(2,0,0);
EstMdl = estimate(Mdl,InSampleData);
[Yhat] = forecast(m1,1);
Yhat=NEW_ROUTPUTQVQ196520014(end+1,column);
InSampleData=NEW_ROUTPUTQVQ196520014(1:end,column);
end;
end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I am repeating these time-series forecating for all the columns of my dataset. I got the following error:
Error in End_of_sample_AR8_model (line 7) Mdl=arima(2,0,0);
Any help please??????
Much appreciated!!

Connectez-vous pour commenter.

 Réponse acceptée

Shashank Prasanna
Shashank Prasanna le 9 Juil 2014

0 votes

Have you seen the doc already? If you haven't here's the link to ARIMA models:
You can estimate your AR coefficients from data and then use the model to forecast. Give it a try and if you have specific question let us know.

6 commentaires

Panty
Panty le 10 Juil 2014
Hi Prasanna
I dont know if your link is what I need. Maybe I couldnt understand what I read there. I explain my case in my comment before. Any help is welcome.
Much appreciated
It is not clear what you are attempting, I am going to share some code with you which I wrote for a different reason. The following does a moving window on step ahead prediction. Depending on your computer this may take several seconds to minutes.
Create simulated data for demonstration
data = simulate(arima('AR',0.1,'MA',{0.2,0.3},'Constant',0,'Variance',0.1),2000);
% Windowed 1 step ahead prediction
mdl = arima(1,0,2);
% Window Size and then move ahead in the loop
w = 1950;
forecastY = zeros(length(data)-w,1);
for ii = 0:length(data)-w-1
RollingData = data((1:w)+ii,:);
mdlEstimate = estimate(mdl,RollingData,'print',false);
[Y,YMSE,~] = forecast(mdlEstimate,1,'Y0',RollingData);
forecastY(ii+1,:) = Y;
end
figure, plot(1:length(data),data);hold on
plot(w+1:length(data),forecastY,'.-r','MarkerSize',15)
legend('Original TS','1 step prediction')
xlim([1900 2000])
Panty
Panty le 13 Juil 2014
Hi Shashank Prasanna, Could you please explain me what do you do in these lines %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [Y,YMSE,~] = forecast(mdlEstimate,1,'Y0',RollingData);
forecastY(ii+1,:) = Y; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
You just forecast the 1951th observation?? using the data sample of 1950 (out of 2000)observations that you simulated before?? but before you created 2000 data sample using an ARMA(1,2)..correct? why dont you just simulate 1950 observations and forecast the 1951th??
Many thanks
Shashank Prasanna
Shashank Prasanna le 14 Juil 2014
So that you can compare what the original data and the moving window forecasted data looks like when compared to each other.
Panty
Panty le 14 Juil 2014
Could you please check here??
I am repeating my issue with more details.. Can you please have a look?
Many thanks.
Shashank Prasanna
Shashank Prasanna le 14 Juil 2014
What is your question? What is the issue you are facing?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by