panel workfile - random draw holding one dimension fixed?

For questions regarding programming in the EViews programming language.

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

tvonbrasch
Posts: 540
Joined: Fri Apr 15, 2011 5:35 am

panel workfile - random draw holding one dimension fixed?

Postby tvonbrasch » Thu Feb 13, 2020 8:45 am

Hi

I want to make a random draw from ba gamma distribution in a panel workfile with 1,2,….N firms and 1,2,… T time periods. I want to draw from the gamma distribution for every firm (n), holding time fixed (t=1,2,...T). I would like to make a total of S (s=1,2,….S) draws or simulations:

I have made the following code

Code: Select all

   wfcreate(wf=panel, page=panel) a  2000 2100 100

   for !s=1 to 10
      genr sigmad_{!s} = @rgamma(0.5,1) 'this is not done holding time fixed...?
   next



However, this does not draw from the gamma distribution for every firm, holding time fixed. How can I draw sigmas from a gamma distribution holding time fixed in a panel workfile?

Thomas

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: panel workfile - random draw holding one dimension fixed?

Postby EViews Matt » Thu Feb 13, 2020 4:25 pm

Hello,

The distribution sampling functions are not panel-aware, so you'll need to draw the random values for one period and then copy those values to all periods. For example,

Code: Select all

wfcreate(wf=panel, page=panel) a  2000 2100 100

for !s=1 to 10
   smpl @first @first
   genr sigmad_{!s} = @rgamma(0.5,1)
   smpl @first+1 @last
   genr sigmad_{!s} = @nan(sigmad_{!s}, sigmad_{!s}(-1))
next
smpl @all

tvonbrasch
Posts: 540
Joined: Fri Apr 15, 2011 5:35 am

Re: panel workfile - random draw holding one dimension fixed?

Postby tvonbrasch » Fri Feb 14, 2020 12:07 am

Great Matt, thanks! I tried to do this in an ordinary workfile (not panel), but that is not very efficient.... this is much better!
Thanks
T


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 32 guests