An introduction to EViews programming.

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator

maujasmin
Posts: 4
Joined: Wed Nov 25, 2009 7:40 am

Re: An introduction to EViews programming.

Postby maujasmin » Tue Jul 07, 2015 10:44 pm

xxx
Last edited by maujasmin on Fri Jul 10, 2015 12:52 am, edited 1 time in total.

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

Re: An introduction to EViews programming.

Postby EViews Gareth » Wed Jul 08, 2015 8:26 am

You could use a for loop to loop through the variables. But if you've already written it out like that, it might be simpler to just leave it as is.

The wfopen command has a "range=" argument to specify the Excel range.
Follow us on Twitter @IHSEViews

maujasmin
Posts: 4
Joined: Wed Nov 25, 2009 7:40 am

Re: An introduction to EViews programming.

Postby maujasmin » Fri Jul 10, 2015 1:58 am

How to use loop if I am going to use that for a series in a workfile?

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

Re: An introduction to EViews programming.

Postby EViews Gareth » Wed Jul 22, 2015 10:05 am

I have no idea what you're asking.
Follow us on Twitter @IHSEViews

Sammoland
Posts: 18
Joined: Tue Mar 01, 2016 6:41 am

Re: An introduction to EViews programming.

Postby Sammoland » Thu Apr 14, 2016 2:24 am

Hi All

This post is in reference to an earlier post, but I wasn't sure how to reply to that.

I am trying to create a for loop that loops through a group of variables, and then runs an auto ARMA process through each individual equation. The auto ARMA is quite basic, and the loop begins to run, but after two variables it just keeps re-iterating and it will not solve.

Here is the for loop for referring to the group, where gexp is the name of the group:

Code: Select all

   pageselect experiment

   delete *

   smpl 1980m1 2016m12

   'read(b2, s=top_ten)  {%pathread}\correl_first.xls range=B2

   'wfopen {%pathread}\correl_first.xls range=B2

   import {%pathread}\correl_first.xls range=A2

   group gexp *

      for %zz resid c

      gexp.drop {%zz}

      next   

   'copy *

   for !j=1 to gexp.@count
      %var = gexp.@seriesname(!j)



Would this be a data issue? I tried removing the problematic variable but it still encounters the same issue. Here is the auto ARMA code, which follows straight after above:

Code: Select all

%eqname = "arma" 'name of equation object that will be used.
'%dep = "y1_ind" 'dependent variable

%maxAR = "5" 'maximum number of AR terms
%maxMA = "5" 'maximum number of MA terms

%regs = "C " 'independent variables
%criterion = "@schwarz" 'which criterion to use enter "@AIC" for Akaike, "@schwarz" for Schwarz, and @HQ for Hannan-Quinn

!maxAR = @val(%maxAR)
!maxMA = @val(%maxMA)

close {%eqname}

'create table for storing critical values.
%matname = "crits"
if @isobject(%matname) then
%matname = "__crits"
if @isobject(%matname) then
delete {%matname}
endif
endif
table(!maxar+2,!maxma+2) {%matname}
{%matname}(1,1) = "AR / MA"
{%matname}.setlines(1) +b
{%matname}.setlines(a) +r

'set sample
smpl @first+!maxAR @last

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

'estimate the models
%arstring = ""
for !i=0 to !maxar
'build up string for AR terms.
if !i>0 then
%arstring = %arstring + " ar(" + @str(!i) + ")"
endif
%mastring = ""
for !j=0 to !maxma
'build up string for MA terms
if !j>0 then
%mastring = %mastring + " ma(" + @str(!j) + ")"
endif
'estimate equation

smpl 1980m1 %end
equation {%eqname}.ls dlog({%var}) {%regs} {%arstring} {%mastring}

'capture criterion
if @upper(%criterion) = "@AIC" then
!crit = {%eqname}.@aic
endif
if @upper(%criterion) = "@SCHWARZ" then
!crit = {%eqname}.@schwarz
endif
if @upper(%criterion) = "@HQ" then
!crit = {%eqname}.@hq
endif
'compare criterion
if !crit < !mincrit then
!mincrit = !crit
!bestAR = !i
!bestMA = !j
%bestARstr = %arstring 'store the best ar string
%bestMAstr = %mastring 'store the best ma string
{%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}{%var}.ls dlog({%var}) {%regs} {%bestARstr} {%bestMAstr}

'show {%eqname}
'show {%matname}

smpl 2002m1 %forend
{%var} = @nan({%var},0)

smpl if {%var} = 0
{%eqname}.forecast {%var}_f
series MAPE_{%var} = @rmse({%var},{%var}_f)

smpl %beg %forend
'plot @pca({%var}_f) @pca({%var})

next

group g1_f *_f
group g1_mape mape_*

write {%pathwrite}\res_poolbrid_sam.xls g1 g1_f g1_mape


Thanks for your help!

nemanja100
Posts: 2
Joined: Mon May 02, 2016 4:15 am

Re: An introduction to EViews programming.

Postby nemanja100 » Mon May 02, 2016 4:25 am

Dear friends, how to generate two series

Xt=2.2+0.6*Xt-1+0.3*Xt-2+e

Yt=0.5+0.3*Yt-1-0.6*Yt-2+e

where e is white noise, with using rndseed 3006?

Please help :)

startz
Non-normality and collinearity are NOT problems!
Posts: 3173
Joined: Wed Sep 17, 2008 2:25 pm

Re: An introduction to EViews programming.

Postby startz » Mon May 02, 2016 6:12 am

What have you tried so far and where are you stuck?


Return to “Programming”

Who is online

Users browsing this forum: Bing [Bot] and 5 guests