Announcement

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

  • Multilevel mixed-effects linear regression error: BLUP calculation failed; estimation data have changed

    Hello,

    I'm trying to perform some postestimation analysis after fitting a multilevel mixed-effects linear regression model, using xtmixed command, and then predict ..., reffects. I'm getting a code error 459 "BLUP calculation failed; estimation data have changed", even though my data haven't changed between these two commands (that are adjacent in the .do).

    I'm using Stata 16.1 on Windows 10.

    My database consists on 151 observations corresponding to food stores, with 4 variables: tip8 is the type of food store (8 categories), seccionid is an integer (1-52) which represents their census tract, affordability is my dependent variable, and ses5 is an index of socio-economic status (5 categories).

    Here is my full database:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(affordability tip8) long seccionid float ses5
     .3470162 7  1 2
     .8847362 2  1 2
    1.2732084 1  1 2
      .761627 2  1 2
     .9701622 2  2 4
     1.637232 1  2 4
     1.684274 5  2 4
            . 8  2 4
    1.2340882 2  2 4
      .895658 3  3 3
    1.3606808 4  3 3
     .5766954 1  3 3
     .6797326 5  3 3
     .8230124 3  3 3
     .8584712 2  3 3
    .59267896 1  3 3
     1.211958 4  3 3
     .8890573 2  3 3
    1.0112512 6  3 3
            . 2  3 3
     .9898938 6  4 2
    1.0591949 3  5 3
     1.367633 1  5 3
       1.1584 1  6 3
    1.7946315 1  6 3
            . 6  6 3
            . 6  6 3
    1.3316513 2  7 3
    1.2643427 4  8 4
     1.402854 2  8 4
    1.5368075 2  9 3
    1.3019353 2 10 4
     .8253586 2 11 3
    1.1899409 2 11 3
    1.0766286 2 11 3
     .9874325 8 12 4
     1.278363 2 12 4
     .9886444 3 12 4
    1.2088873 2 12 4
    1.0845821 2 12 4
    2.0370996 1 12 4
     1.575081 3 12 4
            . 7 12 4
      1.15797 1 13 2
            . 2 13 2
     .9725555 2 13 2
     .5549259 2 13 2
    1.1450877 1 14 3
    1.3744744 3 14 3
     .9235132 2 14 3
     .7059501 2 15 2
     .9723693 1 15 2
     .7696528 4 15 2
    1.4129267 2 16 4
            . 7 17 4
    .26558498 6 17 4
     .7530096 7 17 4
     .4046937 4 17 4
    1.0993522 2 18 4
    1.0162872 2 18 4
    1.8039973 2 18 4
    1.2506953 1 19 2
    1.0112356 4 19 2
     .3382055 6 19 2
     2.468209 1 20 3
    1.2541163 2 20 3
     .9272996 3 21 4
       2.2145 1 22 4
    1.3281648 2 22 4
    1.3858925 5 23 2
    1.5925432 3 23 2
            . 6 23 2
    1.0931851 1 23 2
            . 2 23 2
     .3568257 6 24 1
     .6470747 3 24 1
     .6730999 2 24 1
    .58744943 3 25 1
            . 6 25 1
     .6586046 2 25 1
    .51008946 2 25 1
     .6332879 2 26 0
     .6149406 2 26 0
     1.070049 3 27 1
    .47104555 2 27 1
     .6699582 3 27 1
    1.2817193 1 27 1
     .6765088 4 27 1
            . 6 27 1
     .7971926 1 27 1
     .9509648 2 27 1
     1.172395 3 27 1
    .58902127 2 28 0
     .4634099 2 28 0
      .821103 4 28 0
    1.1809568 1 29 0
            . 8 29 0
      .871049 2 30 0
     .6757722 2 30 0
     .5284542 8 31 0
    end
    label values tip8 tip8
    label def tip8 1 "Supermarket", modify
    label def tip8 2 "Convenience", modify
    label def tip8 3 "Fruit store", modify
    label def tip8 4 "Butcher's", modify
    label def tip8 5 "Fishmonger's", modify
    label def tip8 6 "Bakery", modify
    label def tip8 7 "Herbalist", modify
    label def tip8 8 "Other", modify
    label values ses5 ses5
    label def ses5 0 "Low SES", modify
    label def ses5 1 "Low-medium SES", modify
    label def ses5 2 "Medium SES", modify
    label def ses5 3 "Medium-high SES", modify
    label def ses5 4 "High SES", modify
    Then I run the command xtmixed to fit a 2-level regression model:
    Code:
    xtmixed affordability i.tip8 || seccionid: i.ses5, mle var
    So far, so good. But then I run the predict command to get postestimation effects:

    Code:
    ​​​​​​​
    predict u*, reffects
    And it returns the aforementioned error

    Code:
    ​​​​​​​
    BLUP calculation failed; estimation data have changed
    r(459);
    How is it possible that my data have changed? Am I missing something?

    Thank you very much,
    Regards.

  • #2
    Carlos-Fernandez:
    welcome to this forum.
    It may well be that the problem is due to the lack of standard errors in the random component:
    Code:
    . xtmixed affordability i.tip8 || seccionid: i.ses5, mle var
    
    Performing EM optimization:
    
    Performing gradient-based optimization:
    
    Iteration 0:   log likelihood = -30.478554  (not concave)
    Iteration 1:   log likelihood = -28.416965 
    Iteration 2:   log likelihood =  -27.38861  (not concave)
    Iteration 3:   log likelihood =   -27.3186 
    Iteration 4:   log likelihood = -27.162268 
    Iteration 5:   log likelihood =  -27.15817 
    Iteration 6:   log likelihood = -27.158167 
    Iteration 7:   log likelihood = -27.158167 
    
    Computing standard errors:
    
    Mixed-effects ML regression                     Number of obs     =         88
    Group variable: seccionid                       Number of groups  =         31
    
                                                    Obs per group:
                                                                  min =          1
                                                                  avg =        2.8
                                                                  max =         10
    
                                                    Wald chi2(7)      =      32.77
    Log likelihood = -27.158167                     Prob > chi2       =     0.0000
    
    -------------------------------------------------------------------------------
    affordability |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    --------------+----------------------------------------------------------------
             tip8 |
     Convenience  |  -.4062392   .0856777    -4.74   0.000    -.5741644   -.2383141
     Fruit store  |  -.1898632   .1059012    -1.79   0.073    -.3974258    .0176993
       Butcher's  |  -.2383859   .1238383    -1.92   0.054    -.4811045    .0043328
    Fishmonger's  |  -.0390908   .1762018    -0.22   0.824    -.3844399    .3062584
          Bakery  |  -.5032093     .14689    -3.43   0.001    -.7911085   -.2153102
       Herbalist  |  -.5064898    .221408    -2.29   0.022    -.9404415   -.0725381
           Other  |   -.641343   .2089263    -3.07   0.002    -1.050831    -.231855
                  |
            _cons |   1.190978   .0761077    15.65   0.000     1.041809    1.340146
    -------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
      Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    seccionid: Independent       |
                     var(1.ses5) |   .0238542          .             .           .
                     var(2.ses5) |   8.24e-25          .             .           .
                     var(3.ses5) |   .1612341          .             .           .
                     var(4.ses5) |   .2066683          .             .           .
                      var(_cons) |   1.16e-23          .             .           .
    -----------------------------+------------------------------------------------
                   var(Residual) |   .0727779          .             .           .
    ------------------------------------------------------------------------------
    LR test vs. linear model: chi2(5) = 18.74                 Prob > chi2 = 0.0021
    
    Note: LR test is conservative and provided only for reference.
    
    . predict u*, reffects
    BLUP calculation failed; estimation data have changed
    r(459);
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Adding the -nocons- option for the random component will result in the standard errors, however, the BLUP calculation still fails.

      Manually creating dummy variables from ses5 and changing the algorithm to Broyden-Fletcher-Goldfarb-Shanno (BFGS) does resulting standard errors and the BLUP is successful:

      It might be worth contacting Stata technical support to see they provide more clarity on what is causing the BLUP calculation to fail in this example.

      Code:
      . mixed affordability i.tip8 || seccionid: i.ses5, nocons  nofetable   noheader  nolog
      
      ------------------------------------------------------------------------------
        Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
      -----------------------------+------------------------------------------------
      seccionid: Independent       |
                       var(1.ses5) |   .0238542   .0521825      .0003277    1.736287
                       var(2.ses5) |   4.82e-19   8.40e-18      7.01e-34    .0003309
                       var(3.ses5) |   .1612341   .1191672      .0378738     .686397
                       var(4.ses5) |   .2066682   .1285121      .0610903    .6991571
      -----------------------------+------------------------------------------------
                     var(Residual) |   .0727779   .0128972      .0514227    .1030016
      ------------------------------------------------------------------------------
      LR test vs. linear model: chi2(4) = 18.74                 Prob > chi2 = 0.0009
      
      Note: LR test is conservative and provided only for reference.
      
      . predict u*, reffects
      BLUP calculation failed; estimation data have changed
      r(459);
      Code:
      . qui tab ses, gen(D)
      
      . mixed affordability i.tip8 || seccionid: D*, tech(bfgs) nocons  nofetable   noheader  nolog
      
      ------------------------------------------------------------------------------
        Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
      -----------------------------+------------------------------------------------
      seccionid: Independent       |
                           var(D1) |   2.19e-12   2.62e-08             0           .
                           var(D2) |   .0238537   .0521821      .0003277    1.736343
                           var(D3) |   2.26e-15   2.86e-11             0           .
                           var(D4) |   .1612336   .1191669      .0378736    .6863952
                           var(D5) |   .2066698   .1285132      .0610907    .6991632
      -----------------------------+------------------------------------------------
                     var(Residual) |   .0727779   .0128972      .0514227    .1030015
      ------------------------------------------------------------------------------
      LR test vs. linear model: chi2(5) = 18.74                 Prob > chi2 = 0.0021
      
      Note: LR test is conservative and provided only for reference.
      
      . predict u*, reffects
      
      . 
      end of do-file

      Comment

      Working...
      X