scalar in smpl

For questions regarding programming in the EViews programming language.

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

rogerioms
Posts: 21
Joined: Thu Apr 16, 2009 11:33 am

scalar in smpl

Postby rogerioms » Thu Apr 16, 2009 11:47 am

I am trying to create a sample dynamics, the total sample has 8 years of data daily, and I want run a regression for each quarter, therefore, each quarter would be a new small sample...
My code lines are thus:

!i=1
while !i<32
smpl trim(!i) (trim(!i+1)-1)
equation reg1.ls alpha c ibrx
equation reg2.ls amaz c ibrx
equation reg3.ls bb c ibrx
equation reg4.ls brad c ibrx
equation reg5.ls itau c ibrx
equation reg6.ls unibanco c ibrx
!i=!i+1
wend

The code of error is "Error in Sample: Illegal date trims(1) in "SMPL aux(1) (aux(1+1)-1)""
how to access the lines of vector tim in eviews?

Thanks in Advance
Last edited by rogerioms on Thu Apr 16, 2009 11:59 am, edited 1 time in total.

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

Re: scalar in smpl

Postby EViews Gareth » Thu Apr 16, 2009 11:53 am

What is trim?

I can't really follow what you're trying to do with that while loop.

rogerioms
Posts: 21
Joined: Thu Apr 16, 2009 11:33 am

Re: scalar in smpl

Postby rogerioms » Thu Apr 16, 2009 12:01 pm

trim is a vector which says where begins each quarter

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

Re: scalar in smpl

Postby EViews Gareth » Thu Apr 16, 2009 12:04 pm

Create program variables first:

Code: Select all

!i=1 while !i<32 !first = trim(!i) !last = trim(!i+1)-1 smpl !first !last equation reg1.ls alpha c ibrx equation reg2.ls amaz c ibrx equation reg3.ls bb c ibrx equation reg4.ls brad c ibrx equation reg5.ls itau c ibrx equation reg6.ls unibanco c ibrx !i=!i+1 wend

rogerioms
Posts: 21
Joined: Thu Apr 16, 2009 11:33 am

Re: scalar in smpl

Postby rogerioms » Thu Apr 16, 2009 12:10 pm

Thank you, the code work very well. I think it strange that when I included a variable in smpl he gave a "illegal date" and with you worked all right, you know why???

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

Re: scalar in smpl

Postby EViews Gareth » Thu Apr 16, 2009 12:13 pm

EViews won't accept a vector as a valid date for a sample. Even though you were only referencing a single element of the vector (i.e. a scalar), EViews only saw it as a vector, so rejected it.

There are many cases in EViews programming (actually all programming really) where you, as a human, know that two things are equivalent (a single element of a vector is equivalent to a scalar), but the programming language does not.

tony0807
Posts: 1
Joined: Fri Oct 17, 2014 9:32 am

Re: scalar in smpl

Postby tony0807 » Mon Feb 16, 2015 4:35 am

Hi,

I got a similar problem here, with eviews sending me an error message of an illegal date.

Here's my code :

Code: Select all

'================================================================================== %debut_wf = "1998:2" ' date de debut du workfile %fin_wf = "2014:4" ' date de fin du workfile %debut_estim = "1999:1" ' date de debut de l'estimation %fin_estim = "2013:4" ' date de fin de l'estimation %fin_data = "2014:4" ' date de fin de disponibilité des données des comptes trimestriels '================================================================================== ' Chargement des données cd "S:\SPMAE\PREV\Prev3\_Fichiers_Prev3\Prod_manuf\05-Etalonnages\03-Enq_PMI\etalonnages_2014" workfile modeles_pmi.wf1 q %debut_wf %fin_wf ' Charger les données read(t=xls,b2,s=data) data_pmi.xls 27 genr dummy1 = @recode(@date=@dateval("2008:4"), 1, 0) genr dummy2 = @recode(@date=@dateval("2009:1"), 1, 0) ' Prévision de T en T-1 smpl %debut_estim %fin_estim equation eqm2t1.ls dlyman c cg_m2(-1)-sto_m2(-1)
Now if I run just this piece of code alone

Code: Select all

smpl %debut_estim %fin_estim
I get the following error message :
"Error in Sample: Illegal date %DEBUT_ESTIM in"SMPL %DEBUT_ESTIM %FIN_ESTIM"".

I did not manage to figure out why it is bugging there. Can you help me?

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: scalar in smpl

Postby trubador » Mon Feb 16, 2015 5:15 am

The code works fine.

If you run that specific line alone, then you will get error message. As far as EViews is concerned, %debut_estim and %fin_estim are not yet defined. You should provide all the necessary information:

Code: Select all

%debut_estim = "1999:1" %fin_estim = "2013:4" smpl %debut_estim %fin_estim


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest