An introduction to EViews programming.
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
Re: An introduction to EViews programming.
xxx
Last edited by maujasmin on Fri Jul 10, 2015 12:52 am, edited 1 time in total.

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12603
 Joined: Tue Sep 16, 2008 5:38 pm
Re: An introduction to EViews programming.
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.
The wfopen command has a "range=" argument to specify the Excel range.
Follow us on Twitter @IHSEViews
Re: An introduction to EViews programming.
How to use loop if I am going to use that for a series in a workfile?

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12603
 Joined: Tue Sep 16, 2008 5:38 pm
Re: An introduction to EViews programming.
I have no idea what you're asking.
Follow us on Twitter @IHSEViews
Re: An introduction to EViews programming.
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 reiterating and it will not solve.
Here is the for loop for referring to the group, where gexp is the name of the group:
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:
Thanks for your help!
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 reiterating 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 HannanQuinn
!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!

 Posts: 2
 Joined: Mon May 02, 2016 4:15 am
Re: An introduction to EViews programming.
Dear friends, how to generate two series
Xt=2.2+0.6*Xt1+0.3*Xt2+e
Yt=0.5+0.3*Yt10.6*Yt2+e
where e is white noise, with using rndseed 3006?
Please help
Xt=2.2+0.6*Xt1+0.3*Xt2+e
Yt=0.5+0.3*Yt10.6*Yt2+e
where e is white noise, with using rndseed 3006?
Please help

 Nonnormality and collinearity are NOT problems!
 Posts: 3585
 Joined: Wed Sep 17, 2008 2:25 pm
Re: An introduction to EViews programming.
What have you tried so far and where are you stuck?

 Nonnormality and collinearity are NOT problems!
 Posts: 3585
 Joined: Wed Sep 17, 2008 2:25 pm
Re: An introduction to EViews programming.
You have two "for" statements and only one "next"
Re: An introduction to EViews programming.
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"
Thank you very much for you help. best regards, Jara
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

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12603
 Joined: Tue Sep 16, 2008 5:38 pm
Re: An introduction to EViews programming.
You have two for statements but only one next statement. You need another one.
Follow us on Twitter @IHSEViews
Re: An introduction to EViews programming.
ups. thank you.
it works now, but it seems to me strange that all 63 regressions have full 4 lags for all explanatory variables ...
and is there any easy way how to download the matrix with the pvalues? I used to use
thank you very much for your help.
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 pvalues? 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.

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12603
 Joined: Tue Sep 16, 2008 5:38 pm
Re: An introduction to EViews programming.
use eq.@pvals rather than eq.@coefs
Follow us on Twitter @IHSEViews
Re: An introduction to EViews programming.
Thnk you very much Gareth ..
Writing a text message to the output file
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
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
Who is online
Users browsing this forum: No registered users and 23 guests