Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • FIRST DIFFERENCE REGRESSION

    Hi,

    I have run the regression as a fixed effects model xtreg log_Individual_Consumption log_Individual_Income c.log_Village_average_Consumption##c.EFL, fe

    But would also like to run the same regression using the first difference approach. I know that FE and FD are essentially the same, but I have read that there are differences in their efficiency so I would like to compare both results. My data is organised two rows for each household observation as I have two years. For example:

    Unique_id Year individual consumption village average
    1 2002 8 9
    1 2005 12 15
    2 2002 5 10
    2 2005 9 12

    I have searched through the internet but couldnt find any clear commands, any ideas on how I could do this?

    many thanks

  • #2
    Guy:
    what follows can do the trick.

    Code:
    xtset unique_id year
    xtreg individualconsumption villageaverage, fe
    reshape wide individualconsumption villageaverage , i( unique_id ) j(year)
    g diff_individualconsumption= individualconsumption2005- individualconsumption2002
    g diff_villageaverage= villageaverage2005 - villageaverage2002
    reg diff_individualconsumption diff_villageaverage, nocons
    As an aside FE and FD estimators give back the same results when T=2.
    When T>2, things get more cumbersome (and FD is side-tracked in favour of FE).

    Two textbooks may be interesting about this topic, as both of them provide the reader with comprehensive theoretical coverage along with Stata codes:
    - Allison PD. Fixed effect regression models. Thousand Oaks, CA: Sage, 2009.
    - Hans-Jürgen Andreß, Katrin Golsch, and Alexander W. Schmidt. Applied panel data analysis for economic and social surveys. Berlin Heidelberg: Springer, 2013.

    I hope this helps.

    Kind regards,
    Carlo
    Last edited by Carlo Lazzaro; 07 Sep 2014, 08:00. Reason: Error in brackets tagging Stata code
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      would this work more simply?

      Code:
      xtset unique_id year
      xtreg individualconsumption villageaverage, fe
      xtreg d.individualcomsumption d.villageaverage

      Comment


      • #4
        George's solution is smarter than mine, but has two drawbacks:
        -d.- will not work for Guy's dataset, in that there are gaps between 2002 and 2005. This drawback can be easily worked around via:

        Code:
        replace year=1 if year==2002
        
        replace year=2 if year==2005 
          
               
          xtset unique_id year
        - given the previous remark, the last line of George's code should be amended as follows:

        Code:
        reg d.individualconsumption d.villageaverage, nocons
        or, in a more compact way:

        Code:
        reg D.( individualconsumption villageaverage), nocons
        Kind regards,
        Carlo
        Last edited by Carlo Lazzaro; 08 Sep 2014, 05:24.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          xtset with delta(3) avoids later fixes.

          Comment


          • #6
            Thanks Nick for this (for me unknown) further clarification.

            Kind regards,
            Carlo
            Kind regards,
            Carlo
            (StataNow 18.5)

            Comment


            • #7
              Do I have to put every variable into first difference or is it also possible to just change the DV?

              Comment


              • #8
                Konstantin: I guess that your question is too vague and general to allow good answers. Depends on what you want to do. Add more detail to get better answers.

                Comment


                • #9
                  Originally posted by Carlo Lazzaro View Post
                  George's solution is smarter than mine, but has two drawbacks:
                  -d.- will not work for Guy's dataset, in that there are gaps between 2002 and 2005. This drawback can be easily worked around via:

                  Code:
                  replace year=1 if year==2002
                  
                  replace year=2 if year==2005
                  
                  
                  xtset unique_id year
                  - given the previous remark, the last line of George's code should be amended as follows:

                  Code:
                  reg d.individualconsumption d.villageaverage, nocons
                  or, in a more compact way:

                  Code:
                  reg D.( individualconsumption villageaverage), nocons
                  Kind regards,
                  Carlo
                  Hi! Find this super old post. Does anyone know why here need to add no constant option? Is it because here is perfect collinearity problem, if so where is it? Maybe caused by having only one observation, so the value of this observation and constant will have multicollinearity, if there are more observation it will be fine?

                  Thanks a lot!

                  Comment


                  • #10
                    Lucrecia:
                    the -nocons- option was added because the OLS considered two observations only.
                    See the following toy-example that replicates the issue on a different dataset:
                    Code:
                    . sysuse auto.dta
                    (1978 automobile data)
                    
                    . reg price mpg if _n<=2
                    
                          Source |       SS           df       MS      Number of obs   =         2
                    -------------+----------------------------------   F(1, 0)         =         .
                           Model |      211250         1      211250   Prob > F        =         .
                        Residual |           0         0           .   R-squared       =    1.0000
                    -------------+----------------------------------   Adj R-squared   =         .
                           Total |      211250         1      211250   Root MSE        =         0
                    
                    ------------------------------------------------------------------------------
                           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
                    -------------+----------------------------------------------------------------
                             mpg |       -130          .        .       .            .           .
                           _cons |       6959          .        .       .            .           .
                    ------------------------------------------------------------------------------
                    
                    . reg price mpg if _n<=2, nocons
                    
                          Source |       SS           df       MS      Number of obs   =         2
                    -------------+----------------------------------   F(1, 1)         =     24.13
                           Model |  37788576.9         1  37788576.9   Prob > F        =    0.1279
                        Residual |  1566225.13         1  1566225.13   R-squared       =    0.9602
                    -------------+----------------------------------   Adj R-squared   =    0.9204
                           Total |    39354802         2    19677401   Root MSE        =    1251.5
                    
                    ------------------------------------------------------------------------------
                           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
                    -------------+----------------------------------------------------------------
                             mpg |   221.1009   45.01294     4.91   0.128    -350.8427    793.0445
                    ------------------------------------------------------------------------------
                    
                    .
                    Kind regards,
                    Carlo
                    (StataNow 18.5)

                    Comment


                    • #11
                      Originally posted by Lucrecia Lei View Post

                      Does anyone know why here need to add no constant option?
                      Also, the intercept is eliminated after differencing, so there is no need to have the software attempt to estimate one if there is none present.



                      Comment


                      • #12
                        To Professor Lazzaro and Musau: It is clear, thanks a lot!

                        Comment

                        Working...
                        X