Page 1 of 1

panel workfile - random draw holding one dimension fixed?

Posted: Thu Feb 13, 2020 8:45 am
by tvonbrasch
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

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

Posted: Thu Feb 13, 2020 4:25 pm
by EViews Matt
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

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

Posted: Fri Feb 14, 2020 12:07 am
by tvonbrasch
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