Setting up if conditions in panel data
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Setting up if conditions in panel data
Hi everybody,
I have a question. I have an unbalanced sample of 285 cross-sections and 67 time periods and am regressing one variable on a set of 5 independent variables (OLS). However, I also have a pool of dummy variables, indicating whether one of my cross sections has been specialised in lets say the office sector (dummy is 1 then) at any point in time.
Now I want to tell eViews that when performing the regression, it should check whether in time period t any of the cross sections was specialised in the office sector and use only those for which the dummy was one.
To illustrate what I mean an example. ADC, AEC and AFD are the cross sections and the 1 and 0 indicating whether it was specialised in 1Q1991 etc. I want to tell eViews to grab only ADC and AEC in 1Q1991 for the panel regression, only AEC in 2Q1991 and all three in 3Q1991 and so forth.
ADC AEC AFD
1Q1991 1 1 0
2Q1991 0 1 0
3Q1991 1 1 1
Can anybody help me with this ?
Thank you so much for your help.
I have a question. I have an unbalanced sample of 285 cross-sections and 67 time periods and am regressing one variable on a set of 5 independent variables (OLS). However, I also have a pool of dummy variables, indicating whether one of my cross sections has been specialised in lets say the office sector (dummy is 1 then) at any point in time.
Now I want to tell eViews that when performing the regression, it should check whether in time period t any of the cross sections was specialised in the office sector and use only those for which the dummy was one.
To illustrate what I mean an example. ADC, AEC and AFD are the cross sections and the 1 and 0 indicating whether it was specialised in 1Q1991 etc. I want to tell eViews to grab only ADC and AEC in 1Q1991 for the panel regression, only AEC in 2Q1991 and all three in 3Q1991 and so forth.
ADC AEC AFD
1Q1991 1 1 0
2Q1991 0 1 0
3Q1991 1 1 1
Can anybody help me with this ?
Thank you so much for your help.
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Setting up if conditions in panel data
Are you saying you want the regression to have different variables, or simply that some observations should be excluded? Excluding observations can be done with a smpl. The closest you can come to excluding variables would beHi everybody,
I have a question. I have an unbalanced sample of 285 cross-sections and 67 time periods and am regressing one variable on a set of 5 independent variables (OLS). However, I also have a pool of dummy variables, indicating whether one of my cross sections has been specialised in lets say the office sector (dummy is 1 then) at any point in time.
Now I want to tell eViews that when performing the regression, it should check whether in time period t any of the cross sections was specialised in the office sector and use only those for which the dummy was one.
To illustrate what I mean an example. ADC, AEC and AFD are the cross sections and the 1 and 0 indicating whether it was specialised in 1Q1991 etc. I want to tell eViews to grab only ADC and AEC in 1Q1991 for the panel regression, only AEC in 2Q1991 and all three in 3Q1991 and so forth.
ADC AEC AFD
1Q1991 1 1 0
2Q1991 0 1 0
3Q1991 1 1 1
Can anybody help me with this ?
Thank you so much for your help.
ls y c adc*aec*afd*X
Re: Setting up if conditions in panel data
Hi Startz,
thanks for your reply. Yes, I want to exclude those cross-sections, for which the dummy is not 1, from the regression.
However, when I put "industrial_?=1" in the if condition (the name of the pool is industrial and all the cross sections are in the form industrial_c_acc, industrial_c_adc etc.), eviews tells me that "industrial_? is not defined". Is the syntax for pool estimations not right ? How can I do it ?
There are 285 cross-sections and 67 time points in my regression, so I really dont want to go into excel and check every period which cross section was in there and import it again :-)
Thanks for your help
Kai
thanks for your reply. Yes, I want to exclude those cross-sections, for which the dummy is not 1, from the regression.
However, when I put "industrial_?=1" in the if condition (the name of the pool is industrial and all the cross sections are in the form industrial_c_acc, industrial_c_adc etc.), eviews tells me that "industrial_? is not defined". Is the syntax for pool estimations not right ? How can I do it ?
There are 285 cross-sections and 67 time points in my regression, so I really dont want to go into excel and check every period which cross section was in there and import it again :-)
Thanks for your help
Kai
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Setting up if conditions in panel data
Try a program along these lines to create a dummy variable you can then use in a sample.Hi Startz,
thanks for your reply. Yes, I want to exclude those cross-sections, for which the dummy is not 1, from the regression.
However, when I put "industrial_?=1" in the if condition (the name of the pool is industrial and all the cross sections are in the form industrial_c_acc, industrial_c_adc etc.), eviews tells me that "industrial_? is not defined". Is the syntax for pool estimations not right ? How can I do it ?
There are 285 cross-sections and 67 time points in my regression, so I really dont want to go into excel and check every period which cross section was in there and import it again :-)
Thanks for your help
Kai
Code: Select all
series dum = 1
for %i acc adc
dum = dum and industrial_c_{%i}
next-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Setting up if conditions in panel data
I don't think startz's suggestion quite does the trick, since from my reading, the original poster wants an unbalanced sample with a different set of time observations for each cross-section. Performing exclusions using the dummy variable as suggested will balance the sample since it requires that both cross-sections be present for a given period.
Before offering a solution, I do want to point out that this is one of those sample operations that is a bit easier to do in the panel structured workfile than in the pool setting. If you think about it, the panel structured workfile has one big long sample that spans both cross-sections and time periods and therefore can be used to describe an arbitrary set of observations to be included. A single sample exclusion on a stacked series would do the trick. The pool structure uses a single time sample which is common across cross-sections, which makes having different subsets of observations for different cross-sections a bit trickier (though as you'll see below, not that much trickier).
Having said that, the easiest way to do what you want is to modify the dependent variable in your regression so that EViews does the cross-section specific exclusions for you. This operation is easily performed using @RECODE in an inline expression.
To make things concrete, let's suppose your dependent variable is Y? and you want to regress on X? and C with the exclusions described above requiring A?=1. Then run the regression using the specification
@recode(y?, a?=1, y?, NA) x? c
The @RECODE will replace the original variable Y? with one that takes the values for Y? if the selection variable A?=1, and an NA if it does not. Then when you perform the estimation, EViews will automatically exclude observations with NAs and you will get the desired cross-section specific samples.
Note that you can use this trick whenever you want a pool operation to work on a cross-section specific subset of observations...
I hope that I understood what the original poster wanted and am not dismissing startz's suggestion without cause (though if you do want a balanced sample, you can perform the same @RECODE trick, then ask for a balanced sample in the estimation procedure -- this may be a bit easier than creating the dummy variable).
Before offering a solution, I do want to point out that this is one of those sample operations that is a bit easier to do in the panel structured workfile than in the pool setting. If you think about it, the panel structured workfile has one big long sample that spans both cross-sections and time periods and therefore can be used to describe an arbitrary set of observations to be included. A single sample exclusion on a stacked series would do the trick. The pool structure uses a single time sample which is common across cross-sections, which makes having different subsets of observations for different cross-sections a bit trickier (though as you'll see below, not that much trickier).
Having said that, the easiest way to do what you want is to modify the dependent variable in your regression so that EViews does the cross-section specific exclusions for you. This operation is easily performed using @RECODE in an inline expression.
To make things concrete, let's suppose your dependent variable is Y? and you want to regress on X? and C with the exclusions described above requiring A?=1. Then run the regression using the specification
@recode(y?, a?=1, y?, NA) x? c
The @RECODE will replace the original variable Y? with one that takes the values for Y? if the selection variable A?=1, and an NA if it does not. Then when you perform the estimation, EViews will automatically exclude observations with NAs and you will get the desired cross-section specific samples.
Note that you can use this trick whenever you want a pool operation to work on a cross-section specific subset of observations...
I hope that I understood what the original poster wanted and am not dismissing startz's suggestion without cause (though if you do want a balanced sample, you can perform the same @RECODE trick, then ask for a balanced sample in the estimation procedure -- this may be a bit easier than creating the dummy variable).
Re: Setting up if conditions in panel data
Hi there,
Could you pls help me with the following. I have a structured panel. And I would like to exclude some specific cross-sections for some of my regressions. At the same time I do not want to use if function, because I have 100 cross-sections and need to exclude only 2 of them.
Is there is a way to handle this (i.e. exclude some specific cross-sections) and how can I implement it?
Thanks a lot!
Could you pls help me with the following. I have a structured panel. And I would like to exclude some specific cross-sections for some of my regressions. At the same time I do not want to use if function, because I have 100 cross-sections and need to exclude only 2 of them.
Is there is a way to handle this (i.e. exclude some specific cross-sections) and how can I implement it?
Thanks a lot!
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Setting up if conditions in panel data
If condition is the only way. Pretty straight forward if you only want to not-include 2 of them. Something like:
Code: Select all
if @crossid<>3 and @crossid<>5
Re: Setting up if conditions in panel data
Thank you, Gareth!
Re: Setting up if conditions in panel data
Hello All,
how to write if condition in the equation object?
I want to estimate the following model:
y = b0 + b1*x(if x<500) + b2*x( if x > 500)
Can anyone help me?
Thank you.
how to write if condition in the equation object?
I want to estimate the following model:
y = b0 + b1*x(if x<500) + b2*x( if x > 500)
Can anyone help me?
Thank you.
Last edited by Santosh on Fri Oct 07, 2016 1:41 am, edited 1 time in total.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Setting up if conditions in panel data
Code: Select all
Y c x*(x<500) x*(x>500)
Re: Setting up if conditions in panel data
Thank you, Gareth!
However, if i estimate like the following:
Y c X1<500 Y1>500
it yields different result.
Is the code different from the one you wrote?
In this code, i am telling the EViews to take values for which it is less than 500.
However, if i estimate like the following:
Y c X1<500 Y1>500
it yields different result.
Is the code different from the one you wrote?
In this code, i am telling the EViews to take values for which it is less than 500.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Who is online
Users browsing this forum: No registered users and 1 guest
