Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: residuals when no variation in Y


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: residuals when no variation in Y
Date   Mon, 16 Jan 2012 08:57:51 +0000

The non-zero residuals arise because the data for the first panel
differ from the averaged relationship over all panels. Your -areg-
command doesn't mean that there is a separate regression for each
panel.

To make this clear:

predict predict
scatter y predict time if panel == 1, c(. l) sort lc(red) mc(red)  || ///
scatter y predict time if panel == 2, c(. l) sort lc(blue) mc(blue)

The predictions are the same for both panels.

Nick

On Mon, Jan 16, 2012 at 2:14 AM, Raymond Lim <rl2240@columbia.edu> wrote:
> I have 2 panels with 4 time periods. For panel A, Y=0 in every period.
> For panel B, Y has variation. I regress Y on a linear time trend.
>
> If I regress with just panel A, I get no results as expected. If I do
> a fixed effect regression with both panels, then calculate the
> residuals, panel A's residuals are non-zero. Where are these residuals
> coming from if there is no within-variation in the Y variable?
>
> CODE TO ILLUSTRATE:
> clear all
> input panel y time
> 1 0 2001
> 1 0 2002
> 1 0 2003
> 1 0 2004
> 2 4 2001
> 2 8 2002
> 2 7 2003
> 2 3 2004
> end
>
> reg y time if panel==1
> areg y time, a(panel)
> predict resid, resid
> list, sepby(panel)
>
>
>
> OUTPUT IN THE END
> . list, sepby(panel)
>
>     +--------------------------+
>     | panel   y   time   resid |
>     |--------------------------|
>  1. |     1   0   2001     -.3 |
>  2. |     1   0   2002     -.1 |
>  3. |     1   0   2003      .1 |
>  4. |     1   0   2004      .3 |
>     |--------------------------|
>  5. |     2   4   2001    -1.8 |
>  6. |     2   8   2002     2.4 |
>  7. |     2   7   2003     1.6 |
>  8. |     2   3   2004    -2.2 |
>     +--------------------------+
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index