insufficient observations, fixed effect

#1
hi

when i estimate fixed effects the error "insufficient observations" occur. does anyone how i can solve this problem?

xtset lfdk wave
xtreg CCHappy sportsclub MCSex MEdu MInc MUrban CAge, fe


storage display value
variable name type format label variable label
-------------------------------------------------------------------------------------------------------------------------
CCHappy byte %12.0f l_happy
sportsclub float %9.0g
MCSex byte %8.0g
MEdu byte %8.0g
MInc float %9.0g
MUrban byte %9.0g b_urban33
CAge float %9.0g

best regards
benjamin
 
#2
First, I would suggest you to check the missing values of your variables. One way would be

Code:
count if !missing(var1, var2, ...)
You need also include panel and time variables in -xtset- in your varlist.

An alternative way to check missing value is to run

Code:
regress  CCHappy sportsclub MCSex MEdu MInc MUrban CAge lfdk
generate e_ample = e(sample)
tab e_sample
Second, note that in the model, "the number of predictors" + "number of panels" should be <= "the number of observations"
If not, you would get the error.
 
Last edited:
#3
thanks for your help:)

. tab e_sample

e_sample | Freq. Percent Cum.
------------+-----------------------------------
0 | 3,246 84.86 84.86
1 | 579 15.14 100.00
------------+-----------------------------------
Total | 3,825 100.00

what should i do with the missing values?


. xtset lfdk wave
panel variable: lfdk (strongly balanced)
time variable: wave, 1 to 3
delta: 1 unit

. xtreg CCHappy sportsclub MCSex MEdu MInc MUrban CAge lfdk wave, fe
the panel variable lfdk may not be included as an independent variable



. xtset lfdk wave
panel variable: lfdk (strongly balanced)
time variable: wave, 1 to 3
delta: 1 unit

. xtreg CCHappy sportsclub MCSex MEdu MInc MUrban CAge wave, fe
insufficient observations
 
#4
Note that I use -regress- to check the actual sample used. The model

. xtreg CCHappy sportsclub MCSex MEdu MInc MUrban CAge, fe

also involves the panel variable so I include the panel variable "lfdk" in the -regress- command.

Stata would ignore the observations where any of the variables involved in the model has missing values. So only, for example, 579 observations are used in your model. This may not be enough to trigger the error. You need to check (there is a typo in my previous reply) whether the number of predictors + number of panels <= the number of observations used. If not, the error "insufficient observations" would occur.

One way to check the number of panels:

Code:
egen group = group(lfdk) if e_sample
summarize group
di r(max)
If you want to handle missing values differently, such as imputation, that is another story.



thanks for your help:)

. tab e_sample

e_sample | Freq. Percent Cum.
------------+-----------------------------------
0 | 3,246 84.86 84.86
1 | 579 15.14 100.00
------------+-----------------------------------
Total | 3,825 100.00

what should i do with the missing values?


. xtset lfdk wave
panel variable: lfdk (strongly balanced)
time variable: wave, 1 to 3
delta: 1 unit

. xtreg CCHappy sportsclub MCSex MEdu MInc MUrban CAge lfdk wave, fe
the panel variable lfdk may not be included as an independent variable



. xtset lfdk wave
panel variable: lfdk (strongly balanced)
time variable: wave, 1 to 3
delta: 1 unit

. xtreg CCHappy sportsclub MCSex MEdu MInc MUrban CAge wave, fe
insufficient observations
 
#5
thanks for your help. but i do not know what i should do now.

. egen group = group(lfdk) if e_sample
(3246 missing values generated)

. summarize group

Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
group | 579 290 167.2872 1 579

. di r(max)
579
 
#6
the problem is solved!
the variable MEdu had to many missing values. i did a small adjustment and it works now.

thank you very much for your help:)
 
#7
Hi Benjamin and Wangwang,

I was reading through your thread with WangWang. Sadly, I get the same error message (r[2001]) when I run my fixed effects command. Any clues on how you fixed your problem?

Thanks!
chowchow