Creating a Panel with X observations

For questions regarding programming in the EViews programming language.

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

jason_ll
Posts: 43
Joined: Thu Sep 01, 2011 11:38 am

Creating a Panel with X observations

Postby jason_ll » Mon Nov 12, 2012 7:22 am

Hello,
I'm trying to create a panel with a certain number of observations equal to a number in my series.

Specifically, I am trying:

pagecreate(wf=Example, page=Panel) a 2011 2030 @round(@elem(observations,"2011"))

where observations is a series that's equal to 35000 in 2011.

But instead of getting a panel with 35,000 observations, I am getting a panel with only 20 observations (which is equal to the number of observations of the active workpage).

I tried different things, but they don't seem to work. Any way to do this?

PS: My goal is to create a program for microsimulations. But the number of people in the population is set endogenously and stored in the "observations" series.

Thanks!

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

Re: Creating a Panel with X observations

Postby EViews Gareth » Mon Nov 12, 2012 8:48 am

Code: Select all

!x = @round(@elem(observations,"2011")) pagecreate(wf=Example, page=Panel) a 2011 2030 !x

jason_ll
Posts: 43
Joined: Thu Sep 01, 2011 11:38 am

Re: Creating a Panel with X observations

Postby jason_ll » Mon Nov 12, 2012 8:53 am

Works perfectly, thanks!
From a theoretical perspective, though, why doesn't putting the @elem directly in there work?

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

Re: Creating a Panel with X observations

Postby EViews Gareth » Mon Nov 12, 2012 8:56 am

The pagecreate command doesn't accept expressions.

jason_ll
Posts: 43
Joined: Thu Sep 01, 2011 11:38 am

Re: Creating a Panel with X observations

Postby jason_ll » Wed Nov 21, 2012 8:52 am

Thanks. Any thoughts about the most efficient way to go about creating microsimulations?

I guess one way is to create pool estimations: create series person1 to person1000, age1 to age1000, education1 to education1000....

But I'm wondering if there's a more efficient way.

For example, in a balanced panel workfile, how can I restrict my sample to a given number of cross-sections (people)?

Let's say that 1,000 in my sample are aged 25. How do I go about creating a variable, "age", that is equal to 25 only for this subsample?

Any thoughts/insights would be tremendously appreciated.

jason

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

Re: Creating a Panel with X observations

Postby EViews Gareth » Wed Nov 21, 2012 9:28 am

I don't really understand the question, but to set the sample to be a specific cross-section (or set of), you can use:

Code: Select all

smpl if @crossid = 3 or @crossid = 4
etc...

jason_ll
Posts: 43
Joined: Thu Sep 01, 2011 11:38 am

Re: Creating a Panel with X observations

Postby jason_ll » Wed Nov 21, 2012 11:00 am

Awesome. I didn't realize you could use smpl to restrict cross-sections (just time). I am new to this and have a lot to learn...

Thanks!

jasonrobards
Posts: 3
Joined: Mon Nov 12, 2012 7:33 pm

Re: Creating a Panel with X observations

Postby jasonrobards » Thu Nov 22, 2012 12:33 pm

Is there a way to restrict the sample in panel data by cross section identifiers in string form, instead of numerical form?

Ex, something like:
smpl if @crossid = "US" or @crossid = "Canada"

instead of
smpl if @crossid = 1 or @crossid = 2

My crossids are all text based and I want to avoid recoding them as #s, if possible. Current attempts have failed (ex: "Error in Sample: Numeric operator applied to string data" when I try the proposed method above.)

Much obliged.

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

Re: Creating a Panel with X observations

Postby EViews Gareth » Thu Nov 22, 2012 12:44 pm

@crossid is never a string. It is always a number that runs from 1 to N. If you have another series that you are using as a cross-section identifier, you can use that in the sample:

Code: Select all

smpl if country = "US" or country = "Canada"

jasonrobards
Posts: 3
Joined: Mon Nov 12, 2012 7:33 pm

Re: Creating a Panel with X observations

Postby jasonrobards » Thu Nov 22, 2012 12:51 pm

Thanks. So I guess the best way to limit the panel sample is to create dummies for each x-section and then limit the sample to instances when that dummy = 1?
Ex:
"smpl if dum_northamerica=1"

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

Re: Creating a Panel with X observations

Postby EViews Gareth » Thu Nov 22, 2012 1:26 pm

No, I'd probably just do:

Code: Select all

Smpl if country="USA" or country="Canada"


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest