Page 1 of 1

scalar in smpl

Posted: Thu Apr 16, 2009 11:47 am
by rogerioms
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

Re: scalar in smpl

Posted: Thu Apr 16, 2009 11:53 am
by EViews Gareth
What is trim?

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

Re: scalar in smpl

Posted: Thu Apr 16, 2009 12:01 pm
by rogerioms
trim is a vector which says where begins each quarter

Re: scalar in smpl

Posted: Thu Apr 16, 2009 12:04 pm
by EViews Gareth
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

Re: scalar in smpl

Posted: Thu Apr 16, 2009 12:10 pm
by rogerioms
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???

Re: scalar in smpl

Posted: Thu Apr 16, 2009 12:13 pm
by EViews Gareth
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.

Re: scalar in smpl

Posted: Mon Feb 16, 2015 4:35 am
by tony0807
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?

Re: scalar in smpl

Posted: Mon Feb 16, 2015 5:15 am
by trubador
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