An introduction to EViews programming.

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

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: 13294
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: 13294
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: 3775
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?

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

Re: An introduction to EViews programming.

Postby startz » Wed Feb 07, 2018 11:01 am

You have two "for" statements and only one "next"

Jara
Posts: 2
Joined: Wed Feb 07, 2018 10:33 am

Re: An introduction to EViews programming.

Postby Jara » Wed Feb 07, 2018 11:02 am

Hi, I would like to run OLS for 63 time series variables based on 3 explanatory variables with lags depending on the best AIC.
I tried some of previous programs from this forum, but it does not work. It writes: For statement unterminated in "FOR !J=1 TO 4"

Code: Select all

!aic = 99999999
!maxlags = 4
!bestlag = 0
smpl @first+!maxlags @last

matrix(15,63) coefs

for !j=1 to !maxlags     
for !i=1 to 63

   equation eq{!i}.ls y{!i} c y{!i}(-1 to -!j) x(0 to -!j) z(0 to -!j)
   if eq.@aic < !aic then
      !bestlag = !j     'if this lag specification has the best AIC, then store this lag as !bestlag.
      !aic = eq{!i}.@aic
   endif

   colplace(coefs, eq{!i}.@coefs, !i)           'store coefficients into matrix
next


Thank you very much for you help. best regards, Jara

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

Re: An introduction to EViews programming.

Postby EViews Gareth » Wed Feb 07, 2018 11:17 am

You have two for statements but only one next statement. You need another one.
Follow us on Twitter @IHSEViews

Jara
Posts: 2
Joined: Wed Feb 07, 2018 10:33 am

Re: An introduction to EViews programming.

Postby Jara » Wed Feb 07, 2018 12:12 pm

ups. thank you.
it works now, but it seems to me strange that all 63 regressions have full 4 lags for all explanatory variables ...

Code: Select all

!aic = 99999999
!maxlags = 4
!bestlag = 0
smpl @first+!maxlags @last

for !j=1 to !maxlags
for !i=1 to 63
   
equation eq{!i}.ls cz_{!i} c cz_{!i}(-1 to -!j) ugap(0 to -!j) fx(0 to -!j) vatup vatdown 
   if eq{!i}.@aic < !aic then
      !bestlag = !j     'if this lag specification has the best AIC, then store this lag as !bestlag.
      !aic = eq{!i}.@aic
   endif

next
next


and is there any easy way how to download the matrix with the p-values? I used to use

Code: Select all

matrix(17,63) coefs       '  at the beginning
colplace(coefs, eq{!i}.@coefs, !i)    ' at the FOR statement after the regression


thank you very much for your help.

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

Re: An introduction to EViews programming.

Postby EViews Gareth » Wed Feb 07, 2018 2:04 pm

use eq.@pvals rather than eq.@coefs
Follow us on Twitter @IHSEViews

miharbi
Posts: 7
Joined: Mon Jun 06, 2016 5:39 pm

Re: An introduction to EViews programming.

Postby miharbi » Sat Apr 07, 2018 2:37 pm

Thnk you very much Gareth ..

COM446
Posts: 12
Joined: Wed Jul 08, 2015 2:10 pm

Writing a text message to the output file

Postby COM446 » Sat May 19, 2018 9:18 am

Hi

I want to write a text message to the output file :

output(t) c:\out.txt
text message
ls x1 c x2

Could you please help? I tried to use logmsg and logsave to the above output file. However, only regression result is written to the output file, but not the text message.

Thank you very much, Horward

abhay16dec
Posts: 3
Joined: Wed Nov 21, 2018 5:52 am

how to programming pairwise convergence test?

Postby abhay16dec » Thu Sep 23, 2021 12:57 am

I need your help with programming pairwise convergence test code the test is developed by Peseran (2007) and Phillips and Sul (2007).
Is Is there an inbuilt program in eviews to do this and if it has to be done for a large number of pairs how to write the loop for this?

Best Regards,
APS


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 16 guests