How to create a loop that creates a set of ARIMA models and estimates the models to give LogL results

조회 수: 4 (최근 30일)
Hi there,
I have manually created 16 arima models and have estimated them to produce LogL results in order for me to select the most appropriate model for my data.
See below for how I have manually created them.
mdl20=arima(1,0,1);
mdl21=arima(1,0,2);
mdl22=arima(1,0,3);
mdl23=arima(1,0,4);
% all the way to
mdl32=arima(4,0,1);
mdl33=arima(4,0,2);
mdl34=arima(4,0,3);
mdl35=arima(4,0,4);
then I have used this function to estimate them using my dataset L_Ret:
[EstMdl20,~,logL20] = estimate(Mdl20,L_Ret);
[EstMdl21,~,logL21] = estimate(Mdl21,L_Ret);
[EstMdl22,~,logL22] = estimate(Mdl22,L_Ret);
[EstMdl23,~,logL23] = estimate(Mdl23,L_Ret);
% all the way to
[EstMdl32,~,logL32] = estimate(Mdl32,L_Ret);
[EstMdl33,~,logL33] = estimate(Mdl33,L_Ret);
[EstMdl34,~,logL34] = estimate(Mdl34,L_Ret);
[EstMdl35,~,logL35] = estimate(Mdl35,L_Ret);
Any help will be immensly appreciated

답변 (1개)

Prajit T R
Prajit T R 2018년 6월 25일
Hi Harry
A good programming approach would be to use an array to store the corresponding values in a specific index position instead of declaring a new variable each time.
However, in this case the variable is of ARIMA type, which can not be stored in arrays. You can make a class to hold these ARIMA type variables, and create an array of objects of the class to simplify your job.
However, in your case you just want to see which model suits your workflow. You can follow this crude method to obtain the model estimates:
for i=1:4
for j=1:4
disp('Estimate for values:')
%Print i and j so that you can see which model is being processed
i
j
Mdl=arima(i,0,j)
[EstMdl,~,logL] = estimate(Mdl,L_Ret)
end
end
In each iteration, the values of EstMdl and logL will be printed and you can see which estimate suits you. Note that this after each iteration, the previous value of EstMdl and logL would be replaced. This is not an elegant solution, but in your case with just 16 models, this should be helpful.
Cheers
Prajit

카테고리

Help CenterFile Exchange에서 Conditional Mean Models에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by