### Automatic ARMA selection

Posted:

**Sun Mar 27, 2011 9:39 am**Sure.

Page **2** of **4**

Posted: **Sun Mar 27, 2011 9:39 am**

Sure.

Posted: **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?

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

Posted: **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.

Posted: **Wed Jun 27, 2012 12:13 pm**

Thank you,

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

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

Posted: **Wed Jun 27, 2012 1:29 pm**

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

where*p* is the ARCH order and *q* is the GARCH order.

Code: Select all

`equation.arch(p,q) spec`

where

Posted: **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

%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

Posted: **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?

The syntax for ARCH, as you pointed out is:

equation.ARCH(1,2, EGARCH)

What syntax are you using?

Posted: **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

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

Posted: **Thu Jun 28, 2012 1:55 pm**

You are correct - you want to generate:

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

and:

Which means that you are in fact building up this:

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.

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.

Posted: **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.

Thank you very much.

Posted: **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

%ARCHstring = "!i"

and got some results. I think this is correct solution.

thank you very much

Posted: **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

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

Thank you,

punjaphp

Posted: **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

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

Posted: **Mon Sep 02, 2013 8:11 am**

Yes.

Posted: **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

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

Please help. Thanks a lot!

Warm Regards,

Priyanshi