Announcement

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

  • loglikelihood value after linear fixed effects estimation

    Dear statalist community,

    I run straightforward linear fixed effects regressions (xtreg, fe) and use the internally stored loglikelihood values (e(ll)) as a criterion to select models.
    This works well, as far as I'm aware of.
    Only I am not sure where the likelihood value comes from, since the estimation procedure is ols.
    Is it computed according to the loglikelihood formula for a normal linear regression using the transformed data?

    Thanks for an answer.
    Susanne

  • #2
    I run straightforward linear fixed effects regressions (xtreg, fe) and use the internally stored loglikelihood values (e(ll)) as a criterion to select models.
    This works well, as far as I'm aware of.
    I will call your bluff. You are probably drawing a blank value. There is no maximized log-likelihood in xtreg,fe. You can see this by typing command

    Code:
    ereturn list
    after the regression.

    Edit: Actually, you are right, there is an e(ll) value. I will look further into this.
    Last edited by Andrew Musau; 06 Jun 2018, 06:46. Reason: The OP is correct

    Comment


    • #3
      Alright, there is no difficulty in estimating a fixed effects model with maximum likelihood (ML). You just write down the likelihood function and maximize it. However, the FE estimator does not use employ ML but is able to determine what the maximized log-likelihood is in some way. To answer your question, you can have this value because it is possible to estimate linear FE using ML. Here is an example using the grunfeld dataset

      Code:
      webuse grunfeld
      *XTREG, FE (DOES NOT EMPLOY MAXIMUM LIKELIHOOD)
      xtreg invest mvalue kstock, fe
      di e(ll)
      
      *FIXED EFFECTS EMPLOYING MAXIMUM LIKELIHOOD
      mixed invest mvalue kstock i.company || company:company

      Code:
      . webuse grunfeld
      
      . xtreg invest mvalue kstock, fe
      
      Fixed-effects (within) regression               Number of obs     =        200
      Group variable: company                         Number of groups  =         10
      
      R-sq:                                           Obs per group:
           within  = 0.7668                                         min =         20
           between = 0.8194                                         avg =       20.0
           overall = 0.8060                                         max =         20
      
                                                      F(2,188)          =     309.01
      corr(u_i, Xb)  = -0.1517                        Prob > F          =     0.0000
      
      ------------------------------------------------------------------------------
            invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            mvalue |   .1101238   .0118567     9.29   0.000     .0867345    .1335131
            kstock |   .3100653   .0173545    17.87   0.000     .2758308    .3442999
             _cons |  -58.74393   12.45369    -4.72   0.000    -83.31086     -34.177
      -------------+----------------------------------------------------------------
           sigma_u |  85.732501
           sigma_e |  52.767964
               rho |  .72525012   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      F test that all u_i=0: F(9, 188) = 49.18                     Prob > F = 0.0000
      
      . di e(ll)
      -1070.781
      
      . mixed invest mvalue kstock i.company || company:company
      
      Performing EM optimization: 
      
      Performing gradient-based optimization: 
      
      Iteration 0:   log likelihood = -1071.4531  
      Iteration 1:   log likelihood = -1070.9018  
      Iteration 2:   log likelihood = -1070.7816  
      Iteration 3:   log likelihood =  -1070.781  
      Iteration 4:   log likelihood =  -1070.781  
      
      Computing standard errors:
      
      Mixed-effects ML regression                     Number of obs     =        200
      Group variable: company                         Number of groups  =         10
      
                                                      Obs per group:
                                                                    min =         20
                                                                    avg =       20.0
                                                                    max =         20
      
                                                      Wald chi2(11)     =    3376.06
      Log likelihood =  -1070.781                     Prob > chi2       =     0.0000
      
      ------------------------------------------------------------------------------
            invest |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            mvalue |   .1101238   .0114955     9.58   0.000      .087593    .1326545
            kstock |   .3100653   .0168258    18.43   0.000     .2770874    .3430433
                   |
           company |
                2  |   172.2025   30.21196     5.70   0.000     112.9882    231.4169
                3  |  -165.2751   30.80755    -5.36   0.000    -225.6568   -104.8935
                4  |    42.4874    42.5722     1.00   0.318    -40.95259    125.9274
                5  |  -44.32013   48.95406    -0.91   0.365    -140.2683    51.62806
                6  |   47.13539   45.38464     1.04   0.299    -41.81687    136.0877
                7  |   3.743212   49.02452     0.08   0.939    -92.34307     99.8295
                8  |   12.75103    42.7106     0.30   0.765    -70.96021    96.46228
                9  |  -16.92558   46.97718    -0.36   0.719    -108.9992      75.148
               10  |   63.72884   48.79697     1.31   0.192    -31.91146    159.3691
                   |
             _cons |  -70.29669   48.19365    -1.46   0.145    -164.7545    24.16114
      ------------------------------------------------------------------------------
      
      ------------------------------------------------------------------------------
        Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
      -----------------------------+------------------------------------------------
      company: Independent         |
                      var(company) |   6.31e-24          .             .           .
                        var(_cons) |   4.01e-22          .             .           .
      -----------------------------+------------------------------------------------
                     var(Residual) |   2617.391          .             .           .
      ------------------------------------------------------------------------------
      LR test vs. linear model: chi2(2) = 1.8e-12               Prob > chi2 = 1.0000
      
      Note: LR test is conservative and provided only for reference.
      
      .

      Comment


      • #4
        Thank you, Andrew,

        Originally posted by Andrew Musau View Post
        However, the FE estimator does not use employ ML but is able to determine what the maximized log-likelihood is in some way. To answer your question, you can have this value because it is possible to estimate linear FE using ML.
        Actually I wanted to make sure *how* the value is obtained, i.e. if it is computed using the likelihood function for the linear regression together with the transformed data.

        But thank you for the nice demonstration of estimating fixed effects using the mixed command - I had not been aware of this possibility.

        Best
        Susanne

        Comment


        • #5
          Actually I wanted to make sure *how* the value is obtained, i.e. if it is computed using the likelihood function for the linear regression together with the transformed data.
          Yes, #3 is just a linear regression model. Whether you use dummies or demeaned variables really does not matter. Here is the equivalent with demeaned data and ML (linear regression)

          Code:
          webuse grunfeld
            
          *GEN MEAN DEVIATED VARS
          
          local vars "invest mvalue kstock"
          foreach x of local vars{
          bys company: egen `x'm= mean(`x')
          }
          
          foreach x of local vars{
          gen `x'd= `x'-`x'm
          }
          
          *LINEAR ML
           glm investd mvalued kstockd
          Code:
          
          . glm investd mvalued kstockd
          
          Iteration 0:   log likelihood =  -1070.781  
          
          Generalized linear models                         No. of obs      =        200
          Optimization     : ML                             Residual df     =        197
                                                            Scale parameter =   2657.249
          Deviance         =   523478.127                   (1/df) Deviance =   2657.249
          Pearson          =   523478.127                   (1/df) Pearson  =   2657.249
          
          Variance function: V(u) = 1                       [Gaussian]
          Link function    : g(u) = u                       [Identity]
          
                                                            AIC             =   10.73781
          Log likelihood   = -1070.781023                   BIC             =   522434.4
          
          ------------------------------------------------------------------------------
                       |                 OIM
               investd |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
               mvalued |   .1101238   .0115827     9.51   0.000     .0874221    .1328255
               kstockd |   .3100653   .0169534    18.29   0.000     .2768372    .3432935
                 _cons |  -1.93e-08    3.64503    -0.00   1.000    -7.144128    7.144128
          ------------------------------------------------------------------------------

          Comment

          Working...
          X