Announcement

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

  • reg vs areg, apparent inconsistent behaviour?

    I cannot understand why the coefficient on weight is the same in reg and areg in A), but they are not the same in B).

    Code:
    sysuse auto, clear
    gen car_id = _n
    
    * A)
    reg price weight length i.mpg
    areg price weight length, absorb(mpg)
    
    * B)
    reg price weight length i.car_id
    areg price weight length, absorb(car_id)
    Last edited by dimitris karletsos; 22 May 2023, 15:10.

  • #2
    Model B cannot be estimated as written. You are including 75 variables in a model with 74 observations (73 values of car_id + weight + length). In order to estimate the model, Stata leaves out some variables and gives you a message it's due to collinearity.
    Notice that reg and areg leave out different variables, which is why the models are not comparable.

    Comment


    • #3
      Dimitris:
      as an aside to Sarah's helpfule reply, codes under B) are actually not cross-sectional regressions: there's no variation in -car_id-.
      See also:
      Code:
      . g wave=1
      
      . xtset car_id wave
      
      Panel variable: car_id (strongly balanced)
       Time variable: wave, 1 to 1
               Delta: 1 unit
      
      . xtreg price weight length, fe
      note: weight omitted because of collinearity.
      note: length omitted because of collinearity.
      
      Fixed-effects (within) regression               Number of obs     =         74
      Group variable: car_id                          Number of groups  =         74
      
      R-squared:                                      Obs per group:
           Within  =      .                                         min =          1
           Between =      .                                         avg =        1.0
           Overall =      .                                         max =          1
      
                                                      F(0,0)            =       0.00
      corr(u_i, Xb) =      .                          Prob > F          =          .
      
      ------------------------------------------------------------------------------
             price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
            weight |          0  (omitted)
            length |          0  (omitted)
             _cons |   6165.257          .        .       .            .           .
      -------------+----------------------------------------------------------------
           sigma_u |  2949.4959
           sigma_e |          .
               rho |          .   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      F test that all u_i=0: F(73, 0) = .                          Prob > F =      .
      
      . xtreg price weight length, re
      insufficient observations
      r(2001);
      
      .
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment

      Working...
      X