Automatic ARMA selection

For posting your own programs to share with others

Moderators: EViews Gareth, EViews Moderator

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11368
Joined: Tue Sep 16, 2008 5:38 pm

Automatic ARMA selection

Postby EViews Gareth » Sun Mar 27, 2011 9:39 am

Sure.
Follow us on Twitter @IHSEViews

erdinc
Posts: 6
Joined: Wed Jun 27, 2012 8:06 am

Re: Automatic ARMA selection

Postby erdinc » Wed Jun 27, 2012 8:20 am

Hi,
can we find the best EGARCH model after we find the best ARMA model by the above program?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11368
Joined: Tue Sep 16, 2008 5:38 pm

Re: Automatic ARMA selection

Postby EViews Gareth » Wed Jun 27, 2012 8:24 am

It is not written into the program, no, but there is no theoretical reason why you could not add that feature.
Follow us on Twitter @IHSEViews

erdinc
Posts: 6
Joined: Wed Jun 27, 2012 8:06 am

Re: Automatic ARMA selection

Postby erdinc » Wed Jun 27, 2012 12:13 pm

Thank you,
can you please show me a way to correct that syntax for ARCH/GARCH?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11368
Joined: Tue Sep 16, 2008 5:38 pm

Re: Automatic ARMA selection

Postby EViews Gareth » Wed Jun 27, 2012 1:29 pm

The syntax for ARCH estimation can be found in the Object Reference, but in general it is:

Code: Select all

equation.arch(p,q) spec


where p is the ARCH order and q is the GARCH order.
Follow us on Twitter @IHSEViews

erdinc
Posts: 6
Joined: Wed Jun 27, 2012 8:06 am

Re: Automatic ARMA selection

Postby erdinc » Thu Jun 28, 2012 10:43 am

'Program that calculates the "best" EGARCH specification

%eqname = "EQ02" 'name of equation object that will be used.
%maxARCH = "9" 'maximum number of ARCH terms
%maxGARCH = "9" 'maximum number of GARCH terms
%dep = "dow1" 'dependent variable
%regs = "C ar(1) ma(1)" 'independent variables
%criterion = "@AIC" 'which criterion to use enter "@AIC" for Akaike, "@schwarz" for Schwarz, and @HQ for Hannan-Quinn

!maxARCH = @val(%maxARCH)
!maxGARCH = @val(%maxGARCH)


close {%eqname}


'create table for storing critical values.
%matname = "critsegarch"
if @isobject(%matname) then
%matname = "__critsegarch"
if @isobject(%matname) then
delete {%matname}
endif
endif
table(!maxARCH +2,!maxGARCH+2) {%matname}
{%matname}(1,1) = " ARCH / GARCH"
{%matname}.setlines(1) +b
{%matname}.setlines(a) +r

'set sample
smpl @first+!maxARCH @last

!mincrit = 1e12 'set the minimum to an artificially large value to begin

'estimate the models
%Archstring = ""
for !i=1 to !maxARCH
'build up string for ARCH terms.
if !i>0 then
%ARCHstring = %ARCHstring + " ARCH(" + @str(!i) + ")"
endif
%GARCHstring = ""
for !j=0 to !maxGARCH
'build up string for GARCH terms
if !j>0 then
%GARCHstring = %GARCHstring + " GARCH(" + @str(!j) + ")"
endif
'estimate equation
equation {%eqname}.ARCH({%ARCHstring}, {%GARCHstring}, egarch) {%dep} {%regs}
'capture criterion
if %criterion = "@AIC" then
!crit = {%eqname}.@aic
endif
if %criterion = "@SCHWARZ" then
!crit = {%eqname}.@schwarz
endif
if %criterion = "@HQ" then
!crit = {%eqname}.@hq
endif
'compare criterion
if !crit < !mincrit then
!mincrit = !crit
!bestARCH = !i
!bestGARCH = !j
%bestARCHstr = %ARCHstring 'store the best ARCHstring
%bestGARCHstr = %GARCHstring 'store the best GARCHstring
{%matname}.settextcolor(@all) black 'table formatting.
!ii=!i+2
!jj=!j+2
{%matname}.settextcolor(!ii,!jj) red
endif
{%matname}(!i+2,!j+2) = !crit
{%matname}(!i+2,1) = !i
{%matname}(1,!j+2) = !j
next
next


equation {%eqname}.ARCH({%bestARCHstring}, {%bestGARCHstring},egarch) {%dep} {%regs}


show {%eqname}
show {%matname}
Follow us on Twitter @IHSEViews

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11368
Joined: Tue Sep 16, 2008 5:38 pm

Re: Automatic ARMA selection

Postby EViews Gareth » Thu Jun 28, 2012 11:19 am

Think about what you are doing.

The syntax for ARCH, as you pointed out is:

equation.ARCH(1,2, EGARCH)


What syntax are you using?
Follow us on Twitter @IHSEViews

erdinc
Posts: 6
Joined: Wed Jun 27, 2012 8:06 am

Re: Automatic ARMA selection

Postby erdinc » Thu Jun 28, 2012 1:45 pm

Dear Gareth,
I donot have any programing experience,
I just try to use my logic and adopt your program, so I think the syntax is presented at the line “ ‘estimate equation” (?). If so, it should be like this,
equation {%eqname}.ARCH({%ARCHstring}, {%GARCHstring}, egarch) {%dep} {%regs}
so I think each time program should try the following EGARCH models:
ARCH(1,1,egarch) dow1 c
ARCH(2,1,egarch) dow1 c
ARCH(3,1,egarch) dow1 c
...
...
...
ARCH(1,2,egarch) dow1 c
ARCH(1,3,egarch) dow1 c
...
...
...
And record the resulting AIC to the resulting table.
I think this is also what the ARMA program does.
But I see each time program runs ARMA(1,1)EGARCH(1,1,1) and record the AIC’s to the table instead of changing the ARCH and GARCH terms,
Or indeed it changes bur record always the first ones AIC.

Should I rite something else or which part of the program should I change please?
Thank you very much

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11368
Joined: Tue Sep 16, 2008 5:38 pm

Re: Automatic ARMA selection

Postby EViews Gareth » Thu Jun 28, 2012 1:55 pm

You are correct - you want to generate:

Code: Select all

ARCH(1,1,egarch) dow1 c
ARCH(2,1,egarch) dow1 c
ARCH(3,1,egarch) dow1 c
...
...
...
ARCH(1,2,egarch) dow1 c
ARCH(1,3,egarch) dow1 c


And you do that by building %archstring and %garchstring. However, currently you have:

Code: Select all

%ARCHstring = %ARCHstring + " ARCH(" + @str(!i) + ")"

and:

Code: Select all

%GARCHstring = %GARCHstring + " GARCH(" + @str(!j) + ")"

Which means that you are in fact building up this:

Code: Select all

ARCH(ARCH(1),GARCH(1),egarch) dow1 c
ARCH(ARCH(1) ARCH(2),GARCH(1),egarch) dow1 c
ARCH(ARCH(1) ARCH(2) ARCH(3),GARCH(1),egarch) dow1 c
...
...
...
ARCH(ARCH(1), GARCH(1) GARCH(2),egarch) dow1 c
ARCH(ARCH(1), GARCH(1) GARCH(2) GARCH(3),egarch) dow1 c


Which is why you're getting the errors.

So you need to change your specification of %archstring and %garchstring so that they create the correct syntax.
Follow us on Twitter @IHSEViews

erdinc
Posts: 6
Joined: Wed Jun 27, 2012 8:06 am

Re: Automatic ARMA selection

Postby erdinc » Thu Jun 28, 2012 2:08 pm

Sorry it may be very easy or basic for you but the situation is different for me. If it is possible may I ask the solution to get the correct specification if it is not a problem for you?
Thank you very much.

erdinc
Posts: 6
Joined: Wed Jun 27, 2012 8:06 am

Re: Automatic ARMA selection

Postby erdinc » Thu Jun 28, 2012 10:37 pm

I made
%ARCHstring = "!i"

and got some results. I think this is correct solution.
thank you very much

punjaphp
Posts: 8
Joined: Fri Nov 30, 2012 2:35 am

Re: Automatic ARMA selection

Postby punjaphp » Tue Dec 18, 2012 5:25 am

Dear Gareth

How can I set a criterion of AIC for ARMA selection in x12 seasonal adjustment?

Thank you,
punjaphp

priyanshi
Posts: 11
Joined: Wed Jun 19, 2013 12:36 pm

Re: Automatic ARMA selection

Postby priyanshi » Mon Sep 02, 2013 6:48 am

Hi Gareth,

This code is actually very useful. Thank you for sharing.

However, as I tried running it, I am getting an error message "%matname is not a valid string or scalar name.". I am using Eviews 7. Will this code won't work on Eview 7?

Thank you in advance.

Warm Regards,
Priyanshi

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11368
Joined: Tue Sep 16, 2008 5:38 pm

Re: Automatic ARMA selection

Postby EViews Gareth » Mon Sep 02, 2013 8:11 am

Yes.
Follow us on Twitter @IHSEViews

priyanshi
Posts: 11
Joined: Wed Jun 19, 2013 12:36 pm

Re: Automatic ARMA selection

Postby priyanshi » Mon Sep 02, 2013 11:39 pm

Thank you Gareth.

I tried running this in Eviews 6. It says "{%MATNAME} is not defined".

Please help. Thanks a lot!

Warm Regards,
Priyanshi


Return to “Program Repository”

Who is online

Users browsing this forum: No registered users and 1 guest