Hi everybody. In case anyone is still interested in Rodrigo's question
about xtivreg2 and why the SEs differed from the official Stata commands
in his fixed effects examples, I worked out the answer.
The issue is the treatment of singletons in a fixed effects regression.
In this panel data context, a singleton is a group in which there is
only one observation. Since singletons have zero within-group
information, the within (demeaning) transformation will zap them.
xtivreg2 takes account of these lost observations, and uses the lower
number of observations when calculating the var-cov matrix. Explicitly
excluding the singletons makes no difference to the results.
Stata's official commands that do linear fixed effects estimation
(xtreg, xtivreg, areg) do not adjust the number of observations for the
singletons. Explicitly excluding singletons can therefore affect the
SEs but will leave the coefficients unchanged (with the interesting
exception of the estimated constant, which will also change when
singletons are explicitly excluded).
I am pretty sure that xtivreg2's behavior is justifiable, and it is
correct to treat singletons as non-observations, no different from
observations that are lost because of missing values or whatever, but if
anyone thinks this is wrong, let me know!
Illustrative code follows below.
Cheers,
Mark
Prof. Mark Schaffer
Director, CERT
Department of Economics
School of Management & Languages
Heriot-Watt University, Edinburgh EH14 4AS
tel +44-131-451-3494 / fax +44-131-451-3296
email: [email protected]
web: http://www.sml.hw.ac.uk/ecomes
*** Illustration of treatment of singletons in FE estimation ***
use "http://www.stata-press.com/data/r9/abdata", clear
keep if year > 1982
tab year
* There will be 78-35=43 singleton observations
* Official xtreg
xtreg n w k, fe robust
* Official xtreg, explicitly excluding singletons
* Note all SEs and estimated constant change
* but slope coeffs are same as before.
xtreg n w k if id==F.id | id==L.id, fe robust
* Latter matches behavior of xtivreg2
xtivreg2 n w k, fe robust small
* ...which is unaffected by explicit exclusion of singletons
xtivreg2 n w k if id==F.id | id==L.id, fe robust small
******************* End illustration **************************
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> Rodrigo A. Alfaro
> Sent: 11 July 2006 20:16
> To: [email protected]
> Subject: st: xtivreg2 and singleton-cases
>
> Hello,
>
> I realized that -xtivreg2- controls for singleton-cases. Now
> I am not sure if this involves a different results than
> regular Stata comands.
>
> Below is a program (just copy+paste in an empty do-file)
> where I create artificial data and run some estimation to
> show the differences
>
> First, a simple Fixed-Effects model estimated using different
> commands (S11, S12, S13 and S14). Easy to see in the first
> table that all parameters as well standard errors are the same.
>
> In the second table I put Robust SE (S21 and S22) and Robust
> SE+ Autocorrelation correction (S31 and S32) and again
> everything is fine.
>
> But, if I restrict the sample (if t<3) I got that the new
> simple FE (R11, R12, R13 and R14) are almost the same (only
> the # of observations is lower in xtivreg2 due to singleton
> cases). A minor difference.
>
> The big one is in last table, where the Robust SE (R21 and
> R22) are not longer similar. Same for Robust SE with
> autocorrelation correction
> (R31 and R32). Funny thing is that R22 is similar to R31!!
>
> Any comment is welcome.
> Rodrigo.
>
>
> ***************************************************
> qui {
> /// Artifical data
> clear
> input id time y x
> 1 1 25 .6
> 1 2 26 .7
> 1 3 27 .8
> 2 1 28 .5
> 2 2 23 .
> 2 3 24 .5
> 3 1 25 .3
> 3 2 26 .7
> 3 3 28 .6
> 3 4 . .5
> 4 1 20 .4
> 4 2 . .6
> 4 3 22 .7
> 4 4 23 .
> end
> tsset id time
>
> /// Set 1
> xtivreg2 y x, fe small
> est store S11
> xtivreg y (x=x), fe small
> est store S12
> xtreg y x, fe
> est store S13
> areg y x, a(id)
> est store S14
>
> /// Set 2
> xtivreg2 y x, fe robust small
> est store S21
> areg y x, a(id) robust
> est store S22
>
> /// Set 3
> xtivreg2 y x, fe bw(2) robust small
> est store S31
> xi: newey y x i.id, lag(1) force
> est store S32
>
> /// Restricted Set 1
> xtivreg2 y x if time<3, fe small
> est store R11
> xtivreg y (x=x) if time<3, fe small
> est store R12
> xtreg y x if time<3, fe
> est store R13
> areg y x if time<3, a(id)
> est store R14
>
> /// Restricted Set 2
> xtivreg2 y x if time<3, fe robust small est store R21 areg
> y x if time<3, a(id) robust est store R22
>
> /// Restricted Set 3
> xtivreg2 y x if time<3, fe bw(2) robust small est store R31
> xi: newey y x i.id if time<3, lag(1) force est store R32 }
>
> est table S1*, se stats(N F) title(Fixed Effects) est table
> S2* S3*, se stats(N F) title(Fixed Effects + Robust SE) est
> table R1*, se stats(N F) title(Fixed Effects & t<3) est table
> R2* R3*, se stats(N F) title(Fixed Effects + Robust SE & t<3)
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/