Page 1 of 1

Bug in @elem?

Posted: Wed May 18, 2011 1:27 pm
by startz
Is this a bug in @elem, or just a misunderstanding on my part.

Code: Select all

series studentToShow = @ceiling(@obsrange*rnd) scalar student = @elem(studentToShow,1)
I get the error message
Capture.PNG
Capture.PNG (15.73 KiB) Viewed 5490 times
This is running in an undated workfile.

For what it's worth, all I really want to do is to randomly select one observation from an alpha series in the next step. Maybe there's a better way to do it?

Re: Bug in @elem?

Posted: Wed May 18, 2011 1:54 pm
by EViews Gareth
Not a bug. @elem requires that the second argument be in quotes.

Of course a better way would just be:

Code: Select all

scalar student = @floor(@runif(1,@obsrange))

Re: Bug in @elem?

Posted: Wed May 18, 2011 1:58 pm
by startz
(a) Thank you.
(b) You're right.
(c) It's not my fault. The documentation reads
@elem takes two arguments: the first argument is the name of the series, and the second is the date or observation identifier.

For example, suppose that you want to use the 1980Q3 value of the quarterly series Y, or observation 323 of the undated series X. Then the functions:

@elem(y, 1980Q3)

@elem(x, 323)

will return the values of the respective series in the respective periods.

Re: Bug in @elem?

Posted: Wed May 18, 2011 2:06 pm
by EViews Gareth
Yep, I've noticed that before.

Re: Bug in @elem?

Posted: Wed May 18, 2011 2:06 pm
by startz
Also, are you sure about @floor rather than @ceiling? Or put better, if I want the closed interval [1,@obsrange] do I need

Code: Select all

@floor(@runif(1,@obsrange+1))
?

Re: Bug in @elem?

Posted: Wed May 18, 2011 2:10 pm
by EViews Gareth
As soon as I posted the code, I thought to myself I wonder if I should change it to add the +1, or should I wait and see if he notices it.