Can the if option of xtreg unbalance Panel Data?

#1
Hi everyone,

I have a tricky question regarding the way xtreg works. It amy also be a very simple question

Using a balanced Panel Data with 10 observations per id, I want to use option if after regression command in xtreg, fe to use only observation with specific criteria.
The problem is - not all the ids have this criteria, eg.:

xtreg x z if z == "yes", fe robust

id | time | z
1 | 2000 | yes
1 | 2001 | yes
1 | 2002 | no
2 | 2000 | yes
2 | 2001 | no
2 | 2002 | yes

First, I assumed that xtreg would automatically dismiss all the ids with missing values, but then realised that since the observations are not missing, but excluded manually this may actually manually unbalance my panel and bias the results. On the other hand the x-values are already within values and therefore the results should correctly describe the regression for case in which z == "yes". Im confused. :confused:

So does it unbalance my panel or not and I can still safely use xtreg?

Thank you in advance
Alexandra
 

maartenbuis

TS Contributor
#2
Remember that computer programs do what you say not what you want. You say: run this regression with observation that contain the value "yes" on the variable z, so Stata will do that. In your example that will lead to an unbalanced sample. Depending on your exact model this may or may not lead to biased estimates. In the simple model you used in your example, the estimates will not be biased.