Error sample: range error

For questions regarding programming in the EViews programming language.

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

Caserz
Posts: 4
Joined: Sun Apr 17, 2011 11:06 am

Error sample: range error

Postby Caserz » Thu Apr 21, 2011 8:13 am

Hi!

I'm having trouble with a range error that occurs after running my program that tries to simulate ARCH.
Somehow I'm not rightly specifying the argument in the @inner-command. What I want is the inner product of the single elements of the series I'm multiplying.
This is probably (and hopefully) an easy problem to solve, but I'm just a dummy in programming.
Could anybody help me?

This is the program:

'ARCHbegin.prg
workfile c:\ectr3\archopzet.wf1 u 1 100
!R=100
!alpha0=1
!alpha1=0.5
!beta1=1
!beta2=1
!sigmax=2
smpl 1 1
genr eps=0
smpl 2 100
matrix (!R,2) simres
for !rep=1 to !R
genr u= nrnd
genr etha=rnd
genr o2= !alpha0 + !alpha1*(eps(-1)^2) + etha 'specifying the ARCH(1)-process
genr o=@sqrt(o2)
genr eps= @inner(u,o, !rep !rep)
genr x= nrnd*!sigmax
genr y= !beta1 + !beta2*x + eps
equation eq1.ls y c x
simres(!rep,1)=eq1.@coefs(1)
simres(!rep,2)=eq1.@coefs(2)
next

Many thanks in advance,

Casper

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

Re: Error sample: range error

Postby EViews Gareth » Thu Apr 21, 2011 8:22 am

Code: Select all

%smpl = @str(!rep) + " " + @str(!rep)
genr eps= @inner(u,o, %smpl)
Follow us on Twitter @IHSEViews

Caserz
Posts: 4
Joined: Sun Apr 17, 2011 11:06 am

Re: Error sample: range error

Postby Caserz » Thu Apr 21, 2011 9:02 am

Thanks!
The program doesn't give any error now anymore :D
However the 100 values for 'eps' are all the same, namely the inner product of the last two values for u and o:
...
obs 95 1.43377935715309
obs 96 1.43377935715309
obs 97 1.43377935715309
obs 98 1.43377935715309
obs 99 1.43377935715309
obs 100 1.43377935715309

What I was actually after, was 100 different values for 'eps', namely the inner product of the first elements of u and o, then the inner product of the second elements of u and o, and so on... You would say that would automatically happen since it's in the generated in the loop right?

Many thanks,

Casper

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

Re: Error sample: range error

Postby EViews Gareth » Thu Apr 21, 2011 9:05 am

You're over-writing all observations of eps every time you go through the loop. You might want to set the workfile sample so that you only assign to whatever observations you want.
Follow us on Twitter @IHSEViews

Caserz
Posts: 4
Joined: Sun Apr 17, 2011 11:06 am

Re: Error sample: range error

Postby Caserz » Thu Apr 21, 2011 9:22 am

Ah I see.
Thanks for the help.

spain34
Posts: 1
Joined: Wed Jun 22, 2016 2:44 am

Re: Error sample: range error

Postby spain34 » Wed Dec 19, 2018 1:50 am

Hi,

I have a panel data with observations for 1960, 1970, 1980, 1990, 2000, 2010 and 2015. That is, my data goes every 10 years except of the last observation. I estimated my models in two different manners: 1) using smpl 1960 2010; and 2) using smpl 1960 2015.

The aim of my program is to forecast from 2020 to 2050, every 10 years. I want to do so using the two different models I have set above. If I choose the decennial sample 1960 2010 and forecast based on that estimation, that's done correctly. The problem is when I include 2015 in the sample. I'm unable to create a page with 2015, 2020, 2030, 2040 and 2050. This is because 2015 is not following the same frequency. When I try to first create a range of 2020 to 2050 every ten years and then try to append data for 2015, I get the "error sample: range error".

Any assistance would be greatly appreciated.

Thanks.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 28 guests