Announcement

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

  • mixed models xtreg xtmixed

    Hi All,

    I have a question about xtreg and xtmixed.

    If I enter the following command I get this result.

    xtset interven2

    xtreg difftot i.gender2


    Random-effects GLS regression Number of obs = 85
    Group variable: interven2 Number of groups = 3

    R-sq: within = 0.0015 Obs per group: min = 13
    between = 0.1840 avg = 28.3
    overall = 0.0007 max = 55

    Wald chi2(2) = 0.06
    corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.9722

    ----------------------------------------------------------------------------------
    difftot | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -----------------+----------------------------------------------------------------
    gender2 |
    Female | .0294211 .151446 0.19 0.846 -.2674076 .3262497
    Non-bin | -.0499999 .4162483 -0.12 0.904 -.8658316 .7658317
    |
    _cons | .281 .0724595 3.88 0.000 .1389819 .4230181
    -----------------+----------------------------------------------------------------
    sigma_u | 0
    sigma_e | .55706407
    rho | 0 (fraction of variance due to u_i)
    ----------------------------------------------------------------------------------


    However if I request mle with xtreg I get the following result.

    xtreg difftot i.gender2, mle

    Fitting constant-only model:
    Iteration 0: log likelihood = -72.359585
    Iteration 1: log likelihood = -72.330535
    Iteration 2: log likelihood = -72.33045

    Fitting full model:
    Iteration 0: log likelihood = -72.427795
    Iteration 1: log likelihood = -72.067824
    Iteration 2: log likelihood = -72.017598
    Iteration 3: log likelihood = -72.013335
    Iteration 4: log likelihood = -72.013311

    Random-effects ML regression Number of obs = 85
    Group variable: interven2 Number of groups = 3

    Random effects u_i ~ Gaussian Obs per group: min = 13
    avg = 28.3
    max = 55

    LR chi2(2) = 0.63
    Log likelihood = -72.013311 Prob > chi2 = 0.7282

    ----------------------------------------------------------------------------------
    difftot | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -----------------+----------------------------------------------------------------
    gender2 |
    Female | -.0463684 .1571585 -0.30 0.768 -.3543934 .2616566
    Non-bin | -.3585661 .4490142 -0.80 0.425 -1.238618 .5214855
    |
    _cons | .3761473 .1436128 2.62 0.009 .0946713 .6576232
    -----------------+----------------------------------------------------------------
    /sigma_u | .1827952 .1268277 .0469224 .7121132
    /sigma_e | .5517788 .0434 .4729487 .6437482
    rho | .0988951 .1260109 .0033984 .5520696
    ----------------------------------------------------------------------------------
    Likelihood-ratio test of sigma_u=0: chibar2(01)= 1.44 Prob>=chibar2 = 0.115



    Why should the coefficients and sigma_u variance change?
    Similarly this also occurs with xtmixed as can be seen with the following results just below.

    It has to do with the constant which I notice is mentioned in the first line of the just previous output but I don't understand how.

    Also, the results for xtmixed seem to be opposite to the results from xtreg in the sense that where I request no constant with xtmixed, the results are
    identical to where xtreg does not have a constant only model - the first model above..

    An explanation of why this is happening would be much appreciated.

    xtmixed difftot i.gender2 || interven2:, mle

    Performing EM optimization:

    Performing gradient-based optimization:

    Iteration 0: log likelihood = -72.013312
    Iteration 1: log likelihood = -72.013311

    Computing standard errors:

    Mixed-effects ML regression Number of obs = 85
    Group variable: interven2 Number of groups = 3

    Obs per group: min = 13
    avg = 28.3
    max = 55


    Wald chi2(2) = 0.77
    Log likelihood = -72.013311 Prob > chi2 = 0.6805

    ----------------------------------------------------------------------------------
    difftot | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -----------------+----------------------------------------------------------------
    gender2 |
    Female | -.0463684 .1537466 -0.30 0.763 -.3477063 .2549695
    Non-bin | -.3585661 .4175263 -0.86 0.390 -1.176903 .4597703
    |
    _cons | .3761473 .1364022 2.76 0.006 .1088039 .6434906
    ----------------------------------------------------------------------------------

    ------------------------------------------------------------------------------
    Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    interven2: Identity |
    sd(_cons) | .1827952 .1268308 .0469209 .7121365
    -----------------------------+------------------------------------------------
    sd(Residual) | .5517788 .0434 .4729487 .6437482
    ------------------------------------------------------------------------------
    LR test vs. linear regression: chibar2(01) = 1.44 Prob >= chibar2 = 0.1151


    xtmixed difftot i.gender2 || interven2:, mle noconstant

    Note: all random-effects equations are empty; model is linear regression

    Mixed-effects ML regression Number of obs = 85

    Wald chi2(2) = 0.06
    Log likelihood = -72.733388 Prob > chi2 = 0.9712

    ----------------------------------------------------------------------------------
    difftot | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -----------------+----------------------------------------------------------------
    gender2 |
    Female | .0294211 .1487494 0.20 0.843 -.2621224 .3209645
    Non-bin| -.0499999 .4088367 -0.12 0.903 -.8513052 .7513053
    |
    _cons | .281 .0711693 3.95 0.000 .1415107 .4204894
    ----------------------------------------------------------------------------------

    ------------------------------------------------------------------------------
    Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    sd(Residual) | .5693547 .0436675 .4898902 .6617091
    ------------------------------------------------------------------------------


    Thanks in advance,

    Don
    Last edited by Don Vicendese; 29 Jun 2019, 03:49.

  • #2
    If you read the Methods and Formula at the end of the xtreg documentation, you'll see the MLE and RE use different formula and ways to estimate the parameters. In your data, given the lack of association between the rhs and dv, it appears this results in very different parameter estimates. If you work through the equations you might be able to figure out exactly why this happens.

    The documentation says "The mle and re options yield essentially the same results, except when total N ... is small (200 or less) and the data are unbalanced."

    Comment


    • #3
      Don:
      as an aside to Phil's helpful advice, please note that both your -xtreg- results show no panel-wise effect; hence, you should have replaced -xtreg- with a pooled OLS.
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Thanks Phil and Carlo for taking the time to respond.

        Yes, xtreg uses a GLS estimator by default (also known as GMM) and xtmixed uses MLE by default. Once I realised this I dug around some more and found the following official StataCorp post by Vince Wiggins.
        https://www.stata.com/support/faqs/s...le-versus-gmm/

        Long story short - I think it pays to check xtreg using mle. As Vince says - "The GMM estimator does not directly consider the group predicted values as one of its moments; therefore, its predictions need not match observed group means."

        I think GLS struggled with my data. When I checked, the estimates from xtreg using GLS, correspond exactly to the outcome mean for the gender2 groups. However, GLS was not able to identify group level effects as can be seen form the output in my initial post. Using MLE, xtreg identified group level effects and hence the estimates changed once the random intercepts were identified.

        Further there is a difference in syntax between xtreg and xtmixed.

        xtreg difftot i.gender2, mle noconstant

        is equivalent to

        xtmixed difftot i.gender2, noconstant || interven2:

        where the intercept is suppressed for the fixed part. However, the following command

        xtmixed difftot i.gender2 ||interven2:, noconstant

        suppresses the intercept for the lowest level, not the fixed part. That last command gave the exact results for the xtreg command when it could not identify the random effects.

        Short story long - I am using xtmixed because of its greater flexibility and versatility.

        Thanks again and many regards,

        Don


        Comment


        • #5
          Don:
          thanks for providing further clarifications.
          However, in the example you shared with -xtreg-, there's no evidence of group-wise effect.
          Besides, as per LR test outcome, -mixed- (that replaced -xtmixed- in the most recent Stata releases) shows no evidence of a difference vs OLS.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Yes, that's right - at the 0.05 level of significance.

            Thanks again Carlo - your comments are much appreciated.

            Don

            Comment

            Working...
            X