Announcement

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

  • How to interpret results from a two-level mixed effects model?

    Hello member,

    Can you please help to describe the model and interpret the results below correctly? I found the literature on multilevel model quite confusing as the same model appear called and interpreted differently.

    Am right to state that:

    1. This is a random slope model where by overall model intercept (_cons) is shifted by magnitude of the standard error of the variance of the variable new-retai? In effect,estimated coefficient for new-retai is fixed but clustered data at a panel identified level (SKUCode) and at new-retai mean that the model intercept is no longer constant.

    2. Such model allows to get more efficient estimates than OLS even if variance of new-retai is not constant over time?

    Thanks,
    Mohmaud

    Code:
    xtmixed price_ad d##ib1.cool ib1.branv ib1.new_packz ib1.new_retai ib1.new_eatq    ib1.speci    s1    s2    s3    if    price_ad>0SKUCode:retai,    nolog    mle
    >  cov(unstructured) variance
    note: 3.speci omitted because of collinearity
    
    Mixed-effects ML regression                     Number of obs     =        881
    Group variable: SKUCode                         Number of groups  =         19
    
    Obs per group:
    min =         28
    avg =       46.4
    max =         60
    
    Wald chi2(22)     =     744.82
    Log likelihood = -1408.9143                     Prob > chi2       =     0.0000
    
    
    price_ad       Coef.   Std. Err.      z    P>z     [95% Conf. Interval]
    
    1.d   -.0676438   .1142086    -0.59   0.554    -.2914885    .1562008
    
    cool 
    English     .8446842   .7522606     1.12   0.261    -.6297195    2.319088
    Irish    -.8442959   .6345829    -1.33   0.183    -2.088055    .3994636
    New Zealand       3.0832   .6348334     4.86   0.000      1.83895    4.327451
    Undeclared     -3.05322     .79554    -3.84   0.000     -4.61245    -1.49399
    
    d#cool 
    1#English     1.414085   .4242636     3.33   0.001     .5825437    2.245627
    1#Irish     1.490209   .2787894     5.35   0.000      .943792    2.036626
    1#New Zealand     .4875265   .3287033     1.48   0.138    -.1567202    1.131773
    1#Undeclared     .3319101   .2004654     1.66   0.098    -.0609949    .7248152
    
    branv 
    Mid range    -2.335512   .8236805    -2.84   0.005    -3.949896   -.7211273
    Value     -2.34774   .8840788    -2.66   0.008    -4.080503   -.6149777
    
    new_packz 
    2      1.62276   .7776197     2.09   0.037     .0986534    3.146866
    3     2.540382   .2145492    11.84   0.000     2.119873    2.960891
    
    new_retai 
    2    -2.821306   .9139832    -3.09   0.002    -4.612681   -1.029932
    3    -.8948616   .7698844    -1.16   0.245    -2.403807    .6140842
    4    -1.321566   1.100434    -1.20   0.230    -3.478376    .8352452
    
    2.new_eatq      .55709   .5786807     0.96   0.336    -.5771033    1.691283
    
    speci 
    Chicken     2.712263   1.200454     2.26   0.024     .3594168    5.065109
    Lamb            0  (omitted)
    Pork     .7339984   .5613633     1.31   0.191    -.3662534     1.83425
    
    s1   -.0226442   .1140905    -0.20   0.843    -.2462574    .2009691
    s2    .1004148   .1117495     0.90   0.369    -.1186102    .3194398
    s3   -.0045074   .1111552    -0.04   0.968    -.2223676    .2133527
    _cons    7.042653   1.402746     5.02   0.000     4.293321    9.791986
    
    
    
    Random-effects Parameters     Estimate   Std. Err.     [95% Conf. Interval]
    
    SKUCode: Unstructured        
    var(retai)    .0764931   .0392668      .0279684    .2092072
    var(_cons)    1.899935   .9071493      .7452827    4.843466
    cov(retai,_cons)   -.3812243   .1881468     -.7499853   -.0124633
    
    var(Residual)    1.386305   .0665228      1.261866    1.523016
    
    LR test vs. linear model: chi2(3) = 78.02                 Prob > chi2 = 0.0000
    
    Note: LR test is conservative and provided only for reference.

  • #2
    Code:
    . xtmixed price_ad d##ib1.cool ib1.branv ib1.new_packz ib1.new_retai ib1.new_eatq ib1.speci s1 s2 s3 if price_ad>0||SKUCode:retai, nolog mle
    >  cov(unstructured) variance
    note: 3.speci omitted because of collinearity
    
    Mixed-effects ML regression                     Number of obs     =        881
    Group variable: SKUCode                         Number of groups  =         19
    
                                                    Obs per group:
                                                                  min =         28
                                                                  avg =       46.4
                                                                  max =         60
    
                                                    Wald chi2(22)     =     744.82
    Log likelihood = -1408.9143                     Prob > chi2       =     0.0000
    
    --------------------------------------------------------------------------------
          price_ad |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ---------------+----------------------------------------------------------------
               1.d |  -.0676438   .1142086    -0.59   0.554    -.2914885    .1562008
                   |
              cool |
          English  |   .8446842   .7522606     1.12   0.261    -.6297195    2.319088
            Irish  |  -.8442959   .6345829    -1.33   0.183    -2.088055    .3994636
      New Zealand  |     3.0832   .6348334     4.86   0.000      1.83895    4.327451
       Undeclared  |   -3.05322     .79554    -3.84   0.000     -4.61245    -1.49399
                   |
            d#cool |
        1#English  |   1.414085   .4242636     3.33   0.001     .5825437    2.245627
          1#Irish  |   1.490209   .2787894     5.35   0.000      .943792    2.036626
    1#New Zealand  |   .4875265   .3287033     1.48   0.138    -.1567202    1.131773
     1#Undeclared  |   .3319101   .2004654     1.66   0.098    -.0609949    .7248152
                   |
             branv |
        Mid range  |  -2.335512   .8236805    -2.84   0.005    -3.949896   -.7211273
            Value  |   -2.34774   .8840788    -2.66   0.008    -4.080503   -.6149777
                   |
         new_packz |
                2  |    1.62276   .7776197     2.09   0.037     .0986534    3.146866
                3  |   2.540382   .2145492    11.84   0.000     2.119873    2.960891
                   |
         new_retai |
                2  |  -2.821306   .9139832    -3.09   0.002    -4.612681   -1.029932
                3  |  -.8948616   .7698844    -1.16   0.245    -2.403807    .6140842
                4  |  -1.321566   1.100434    -1.20   0.230    -3.478376    .8352452
                   |
        2.new_eatq |     .55709   .5786807     0.96   0.336    -.5771033    1.691283
                   |
             speci |
          Chicken  |   2.712263   1.200454     2.26   0.024     .3594168    5.065109
             Lamb  |          0  (omitted)
             Pork  |   .7339984   .5613633     1.31   0.191    -.3662534     1.83425
                   |
                s1 |  -.0226442   .1140905    -0.20   0.843    -.2462574    .2009691
                s2 |   .1004148   .1117495     0.90   0.369    -.1186102    .3194398
                s3 |  -.0045074   .1111552    -0.04   0.968    -.2223676    .2133527
             _cons |   7.042653   1.402746     5.02   0.000     4.293321    9.791986
    --------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
      Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    SKUCode: Unstructured        |
                      var(retai) |   .0764931   .0392668      .0279684    .2092072
                      var(_cons) |   1.899935   .9071493      .7452827    4.843466
                cov(retai,_cons) |  -.3812243   .1881468     -.7499853   -.0124633
    -----------------------------+------------------------------------------------
                   var(Residual) |   1.386305   .0665228      1.261866    1.523016
    ------------------------------------------------------------------------------
    LR test vs. linear model: chi2(3) = 78.02                 Prob > chi2 = 0.0000
    
    Note: LR test is conservative and provided only for reference.

    Comment


    • #3
      No. Actually, your model appears to be mis-specified and not interpretable, because you have asked for random slope estimation on a variable retai which does not appear anywhere in the lowest-level fixed portion of the regression. Unless you have good theoretical reasons to constrain the mean slope of retai to zero, this is wrong and you need to add retai to the lowest-level predictors. Then you will have a correctly specified two-level model with random slope estimation for the retai variable.

      Comment


      • #4
        Many thanks Clyde. How I can re-write the code to the retai to the lowest-level predictors please?

        Comment


        • #5
          Apologies Clyde. I think I misinterpreted your message. I now follow your explantion. I have to add new-retai in the left side, and removed the wrong one, i.e. retai!

          Comment


          • #6
            Just to be clear, the variable -retai- has to appear in both places, at the bottom level and at the higher level, to correctly specify a random slopes model.

            Comment


            • #7
              Clyde,

              It looks that the correction of the misspecfication above has led to another serious problem. The correct model seem to have failed due to a collinearity involving another explanatory variable, speci. This is a categorical variable with three subcategory levels, and when the Stata operator ib1 is used coefficient for subcategory is dropped.

              Code:
              xtmixed price_ad d##ib1.cool ib1.branv ib1.new_packz ib1.new_retai ib1.new_eatq ib1.speci s1 s2 s3 if price_ad>0||SKUCode:new_retai, nolog
              >  mle cov(unstructured) variance
              note: 3.speci omitted because of collinearity
              Hessian is not negative semidefinite
              conformability error
              r(503);
              Any advice as to how to overcome this problem please? Does it make sense using speci without the operator, unlike other variables to avoid the problem? This appears to resolve the issues, see results which overall seem to be consistent.

              Thanks, M.

              Code:
              xtmixed price_ad d##ib1.cool ib1.branv ib1.new_packz ib1.new_retai ib1.new_eatq speci s1 s2 s3 if price_ad>0||SKUCode:new_retai, nolog mle
              >  cov(unstructured) variance
              
              Mixed-effects ML regression                     Number of obs     =        881
              Group variable: SKUCode                         Number of groups  =         19
              
                                                              Obs per group:
                                                                            min =         28
                                                                            avg =       46.4
                                                                            max =         60
              
                                                              Wald chi2(21)     =     735.66
              Log likelihood = -1409.8614                     Prob > chi2       =     0.0000
              
              --------------------------------------------------------------------------------
                    price_ad |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
              ---------------+----------------------------------------------------------------
                         1.d |  -.0745518   .1142543    -0.65   0.514     -.298486    .1493824
                             |
                        cool |
                    English  |   -.027742   .7667515    -0.04   0.971    -1.530547    1.475063
                      Irish  |   .1232678   .6136375     0.20   0.841     -1.07944    1.325975
                New Zealand  |   4.005565   .8893842     4.50   0.000     2.262404    5.748726
                 Undeclared  |  -2.980843   .6460403    -4.61   0.000    -4.247059   -1.714628
                             |
                      d#cool |
                  1#English  |   1.420997   .4243219     3.35   0.001     .5893412    2.252653
                    1#Irish  |   1.529675   .2781819     5.50   0.000     .9844484    2.074902
              1#New Zealand  |   .4943917   .3287526     1.50   0.133    -.1499516    1.138735
               1#Undeclared  |   .3506519   .2004006     1.75   0.080    -.0421261    .7434298
                             |
                       branv |
                  Mid range  |    -2.3371    .676916    -3.45   0.001    -3.663831   -1.010369
                      Value  |   -1.02987   .4609099    -2.23   0.025    -1.933237    -.126503
                             |
                   new_packz |
                          2  |   .3502544   .6982622     0.50   0.616    -1.018314    1.718823
                          3  |   2.457283   .2101432    11.69   0.000      2.04541    2.869156
                             |
                   new_retai |
                          2  |  -3.170375   .9588037    -3.31   0.001    -5.049595   -1.291154
                          3  |  -1.287413   .7445251    -1.73   0.084    -2.746656     .171829
                          4  |  -2.583689   1.082028    -2.39   0.017    -4.704424   -.4629534
                             |
                  2.new_eatq |   1.415918   .5788221     2.45   0.014     .2814476    2.550389
                       speci |   .0083508    .187468     0.04   0.964    -.3590798    .3757813
                          s1 |  -.0210842   .1141065    -0.18   0.853    -.2447288    .2025604
                          s2 |   .1019654   .1117613     0.91   0.362    -.1170827    .3210134
                          s3 |  -.0038751   .1111684    -0.03   0.972    -.2217613     .214011
                       _cons |   7.441129   1.389133     5.36   0.000     4.718478    10.16378
              --------------------------------------------------------------------------------
              
              ------------------------------------------------------------------------------
                Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
              -----------------------------+------------------------------------------------
              SKUCode: Unstructured        |
                             var(new_re~i) |   .1267583   .0597075      .0503537    .3190963
                                var(_cons) |   1.991329   .8862054      .8323976    4.763817
                       cov(new_re~i,_cons) |  -.5024116   .2289879     -.9512196   -.0536036
              -----------------------------+------------------------------------------------
                             var(Residual) |   1.386629   .0665416      1.262155    1.523378
              ------------------------------------------------------------------------------
              LR test vs. linear model: chi2(3) = 115.14                Prob > chi2 = 0.0000
              
              Note: LR test is conservative and provided only for reference.

              Comment


              • #8
                No, this has other problems now FIrst of all, you have removed the variable retai altogether, and in your random effects you have substituted a different variable new_retai, which, from your lowest level I gather is actually a discrete variable with 4 levels. This model is altogether mis-specified. You cannot treat the same variable as continuous in one place and discrete in another. If it is sensible to treat it as continuous, use it that way in both places. If it only makes sense to treat it as discrete, then you will need to create three new variable for it: this is one of the situations in Stata where you will not be able to rely on factor-variable notation. so

                Code:
                forvalues i = 2/4 {
                    gen byte new_retai`i' = `i'.new_retai
                }
                
                mixed price /*other predictors here*/ new_retai2 new_retai3 new_retai4 if price_ad > 0 || SKUCode: new_retai2 new_retai3 new_retai4, nolog cov(unstructured) variance
                Notes:
                1. This will give you a model estimatng random slopes for the effects of each of levels 2 through 4 (relative to level 1) of new_retai.
                2. I've omitted the -mle- option because in current Stata that is the default.
                3. I think trying to get cov(unstructured) is going to be a problem no matter how you slice it. You have a random intercept and 3 random slopes. WIth unstructured covariance that's 10 covariance parameters to estimate. But you only have 19 groups. So you don't really have enough information to meaningfully estimate that many parameters in any but the coarsest terms, and it can easily make your estimation unstable and cause convergence problems. It may well be the reason that you are getting that message about the Hessian not being negative semidefinite. I don't know what the context is or what the variables mean, but you should discuss this situation with somebody who does, and who understands your field, to consider what more structured covariance estimation might be suitable.


                As for the variable speci, again, you need to decide, not based on convenience of analysis, but on the meaning of the variable, whether it is continuous or categorical. If the latter, you must stick with i.speci. If it is continuous then you should use speci. But I also don't understand why you have suddenly become concerned just now about the collinearity issue with 3.speci: looking at the earlier posts, this has been here all along. Whether it's a problem, or not, I don't know. But doesn't seem to have anything to do with the changes you made most recently; it's been there all along.

                You should create a new variable: -gen speci3 = 3.speci- and regress that variable (in the estimation sample from -mixed-) against all the other predictors in your model. That way you will find out which variables it is colinear with. Then you might decide that this is something that makes sense given what the variables are, and is not a problem at all. For example, maybe speci is never 3 when price_ad > 0 and it is supposed to be that way. Or perhaps this colinearity will enable you to unearth some errors in the data that are causing it and you will have the opportunity to correct those errors.

                Comment


                • #9
                  Thanks Clyde. Much appreciated.

                  Comment

                  Working...
                  X