Announcement

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

  • How to resolve error message "variable _cons not found"?

    Hello Everyone,

    I have a large dataset - panel data with 156,790 observations. After running a Weibull distribution model, the result table reveals all predictor variables are significant. Correlation tests show that this is not due to multicollinearity. Therefore, I used the domme command to conduct dominance analysis to determine the relative importance of the predictors within the model. However, I receive the following error message: variable _cons not found.

    Joseph Luchman, who wrote the domme command has looked at my syntax and believes the code looks reasonable to him given the model I presented, but he is not sure why I am getting such an error message. He suggested that the error message may have something to do with the frequency weights I use. I applied the weights since otherwise, Stata cannot run the Weibull model.

    Does anyone know what the issue is and how I might resolve it?

    I have included sample data below as well as my commands for the Weibull regression and the domme command.

    Any insights would be greatly appreciated.


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float use_of_force double total_legitimacy byte leadership_power float capability_preponderance byte system_effects_isolation double core_interests_weighted
    1               .095 1 0 0 1.3
    1               .095 1 0 0 1.3
    1               .095 1 0 0   .
    1               .095 1 0 0   .
    1               .095 1 0 0 1.9
    1               .095 1 0 0 1.9
    1               .095 1 0 0 1.3
    1               .095 1 0 0 1.3
    1               .095 1 0 0   .
    1               .095 1 0 0   .
    1               .095 1 0 0 1.9
    1               .095 1 0 0 1.9
    0               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    0               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0  .8
    0               .155 2 0 0  .8
    1               .155 2 0 0  .8
    1               .155 2 0 0  .8
    1               .155 2 0 0  .8
    1               .155 2 0 0  .8
    1               .155 2 0 0  .8
    1               .155 2 0 0  .8
    1               .155 2 0 0  .8
    1               .155 2 0 0  .8
    1               .155 2 0 0  .8
    1               .155 2 0 0  .8
    1               .155 2 0 0  .8
    0               .155 2 0 0  .8
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    0               .155 2 0 0   1
    0               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0   1
    1               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    0               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    1               .155 2 0 0 1.5
    0               .155 2 0 0 1.5
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0  .8
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .17 3 0 0 1.2
    1                .24 4 0 0   1
    1 3.1641596638655467 5 0 0   0
    1 3.1641596638655467 5 0 0   0
    1 3.1641596638655467 5 0 0   0
    end
    Below are the Weibull regression results.

    Code:
    . do "C:\Users\Sunyoung\AppData\Local\Temp\STD2a90_000000.tmp"
    
    . tsset group_id seqnum
           panel variable:  group_id (unbalanced)
            time variable:  seqnum, 1 to 29318
                    delta:  1 unit
    
    . tsspell event_use_of_force
    
    . 
    . global time _seq 
    
    . global event event_use_of_force
    
    . global xlist total_legitimacy leadership_power i.capability_preponderance i.system_effects_isolation core_interests_weighte
    > d
    
    . 
    . xtset $event_use_of_force 
           panel variable:  group_id (unbalanced)
            time variable:  seqnum, 1 to 29318
                    delta:  1 unit
    
    . stset $time, failure ($event)
    
         failure event:  event_use_of_force != 0 & event_use_of_force < .
    obs. time interval:  (0, _seq]
     exit on or before:  failure
    
    ------------------------------------------------------------------------------
        156,790  total observations
              0  exclusions
    ------------------------------------------------------------------------------
        156,790  observations remaining, representing
         74,657  failures in single-record/single-failure data
       13115330  total analysis time at risk and under observation
                                                    at risk from t =         0
                                         earliest observed entry t =         0
                                              last observed exit t =     4,918
    
    . 
    . * When running xtstreg, recieved error message (r1400) "initial values not feasible". numerical overflow - You have attempt
    > ed something that, in the midst of the necessary calculations, has resulted in something too large for Stata to deal with a
    > ccurately.  Most commonly, this is an attempt to estimate a model (say, with regress) with too many effective observations.
    >   This effective number could be reached with far fewer observations if you were running a frequency-weighted model. Stata 
    > suggests using frequency weights (fweight) to address the issue.
    . 
    . xtstreg $xlist [fweight=use_of_force], dist (weibull)
    
             failure _d:  event_use_of_force
       analysis time _t:  _seq
    
    Fitting comparison model:
    
    Iteration 0:   log likelihood =  -11456980  
    Iteration 1:   log likelihood = -212771.72  
    Iteration 2:   log likelihood = -183980.49  
    Iteration 3:   log likelihood = -174021.93  
    Iteration 4:   log likelihood = -173757.77  
    Iteration 5:   log likelihood = -173756.97  
    Iteration 6:   log likelihood = -173756.97  
    
    Refining starting values:
    
    Grid node 0:   log likelihood = -173202.69
    
    Fitting full model:
    
    Iteration 0:   log likelihood = -173202.69  (not concave)
    Iteration 1:   log likelihood = -173125.16  (not concave)
    Iteration 2:   log likelihood =  -173093.7  (not concave)
    Iteration 3:   log likelihood = -173064.82  (not concave)
    Iteration 4:   log likelihood = -173038.99  (not concave)
    Iteration 5:   log likelihood =  -173028.5  
    Iteration 6:   log likelihood = -173004.69  
    Iteration 7:   log likelihood = -172905.78  
    Iteration 8:   log likelihood = -172905.54  
    Iteration 9:   log likelihood = -172905.54  
    
    Random-effects Weibull PH regression            Number of obs     =     72,401
    Group variable:        group_id                 Number of groups  =        164
    
                                                    Obs per group:
                                                                  min =          5
                                                                  avg =      441.5
                                                                  max =      9,881
    
    Integration method: mvaghermite                 Integration pts.  =         12
    
                                                    Wald chi2(5)      =   13080.31
    Log likelihood = -172905.54                     Prob > chi2       =     0.0000
    --------------------------------------------------------------------------------------------
                            _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ---------------------------+----------------------------------------------------------------
              total_legitimacy |    1.16034   .0020356    84.77   0.000     1.156357    1.164336
              leadership_power |   1.021782    .001048    21.01   0.000      1.01973    1.023838
    1.capability_preponderance |    1.97642   .1412776     9.53   0.000     1.718043    2.273655
    1.system_effects_isolation |   2.372612    .032856    62.39   0.000     2.309081     2.43789
       core_interests_weighted |   .9821228   .0095827    -1.85   0.064     .9635194    1.001085
                         _cons |   .0764842    .005695   -34.52   0.000     .0660984    .0885018
    ---------------------------+----------------------------------------------------------------
                         /ln_p |  -.1140053   .0025787                     -.1190593   -.1089512
    ---------------------------+----------------------------------------------------------------
                     /sigma2_u |   .0505792    .006482                      .0393447    .0650216
    --------------------------------------------------------------------------------------------
    Note: Estimates are transformed only in the first equation.
    Note: _cons estimates baseline hazard (conditional on zero random effects).
    LR test vs. Weibull model: chibar2(01) = 1702.86      Prob >= chibar2 = 0.0000
    
    . 
    end of do-file
    This is the command syntax I use to determine relative importance.

    Code:
    domme (_t = total_legitimacy leadership_power 1.capability_preponderance 1.system_effects_isolation core_interests_weighted) [fweight=use_of_force], reg(xtstreg total_legitimacy leadership_power i.capability_preponderance i.system_effects_isolation core_interests_weighted) ropt(distribution(weibull)) fitstat(e(), est)
    Then I receive the following error.

    Code:
    . do "C:\Users\Sunyoung\AppData\Local\Temp\STD2a90_000000.tmp"
    
    . domme (_t = total_legitimacy leadership_power 1.capability_preponderance 1.system_effects_isolation core_interests_weighted
    > ) [fweight=use_of_force], reg(xtstreg total_legitimacy leadership_power i.capability_preponderance i.system_effects_isolati
    > on core_interests_weighted) ropt(distribution(weibull)) fitstat(e(), est)
    variable _cons not found
    r(111);
    
    end of do-file

  • #2
    Your data example doesn't work. For starters, variables like group_id, seqnum, event_use_of_force are not included. Could you create a data example on which we can run your code?

    Comment


    • #3
      Hello Hemanshu. Thank you for bringing that to my attention.

      Here is another sample of my data.

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input double total_legitimacy byte leadership_power float capability_preponderance byte system_effects_isolation double core_interests_weighted float(event_use_of_force group_id seqnum) int _seq
                    .095 1 0 0   . 1 1   1  1
                    .095 1 0 0   . 1 1   2  2
                    .095 1 0 0 1.3 1 1   3  3
                    .095 1 0 0 1.3 1 1   4  4
                    .095 1 0 0 1.9 1 1   5  5
                    .095 1 0 0 1.9 1 1   6  6
                    .095 1 0 0   . 1 1   7  7
                    .095 1 0 0   . 1 1   8  8
                    .095 1 0 0 1.3 1 1   9  9
                    .095 1 0 0 1.3 1 1  10 10
                    .095 1 0 0 1.9 1 1  11 11
                    .095 1 0 0 1.9 1 1  12 12
                    .155 2 0 0   1 0 1  13  1
                    .155 2 0 0   1 1 1  14  1
                    .155 2 0 0   1 1 1  15  2
                    .155 2 0 0   1 1 1  16  3
                    .155 2 0 0   1 0 1  17  1
                    .155 2 0 0   1 1 1  18  1
                    .155 2 0 0   1 1 1  19  2
                    .155 2 0 0   1 1 1  20  3
                    .155 2 0 0   1 1 1  21  4
                    .155 2 0 0   1 1 1  22  5
                    .155 2 0 0   1 1 1  23  6
                    .155 2 0 0   1 1 1  24  7
                    .155 2 0 0   1 1 1  25  8
                    .155 2 0 0   1 1 1  26  9
                    .155 2 0 0 1.5 0 1  27  1
                    .155 2 0 0 1.5 1 1  28  1
                    .155 2 0 0 1.5 1 1  29  2
                    .155 2 0 0 1.5 1 1  30  3
                    .155 2 0 0 1.5 1 1  31  4
                    .155 2 0 0 1.5 1 1  32  5
                    .155 2 0 0 1.5 1 1  33  6
                    .155 2 0 0 1.5 1 1  34  7
                    .155 2 0 0 1.5 0 1  35  1
                    .155 2 0 0 1.5 1 1  36  1
                    .155 2 0 0 1.5 1 1  37  2
                    .155 2 0 0 1.5 1 1  38  3
                    .155 2 0 0 1.5 1 1  39  4
                    .155 2 0 0 1.5 1 1  40  5
                    .155 2 0 0  .8 1 1  41  6
                    .155 2 0 0  .8 0 1  42  1
                    .155 2 0 0  .8 1 1  43  1
                    .155 2 0 0  .8 1 1  44  2
                    .155 2 0 0  .8 1 1  45  3
                    .155 2 0 0  .8 1 1  46  4
                    .155 2 0 0  .8 1 1  47  5
                    .155 2 0 0  .8 0 1  48  1
                    .155 2 0 0  .8 1 1  49  1
                    .155 2 0 0  .8 1 1  50  2
                    .155 2 0 0  .8 1 1  51  3
                    .155 2 0 0  .8 1 1  52  4
                    .155 2 0 0  .8 1 1  53  5
                    .155 2 0 0  .8 1 1  54  6
                    .155 2 0 0   1 0 1  55  1
                    .155 2 0 0   1 0 1  56  2
                    .155 2 0 0   1 1 1  57  1
                    .155 2 0 0   1 1 1  58  2
                    .155 2 0 0   1 1 1  59  3
                    .155 2 0 0   1 1 1  60  4
                    .155 2 0 0   1 1 1  61  5
                    .155 2 0 0   1 1 1  62  6
                    .155 2 0 0   1 1 1  63  7
                    .155 2 0 0   1 1 1  64  8
                    .155 2 0 0   1 1 1  65  9
                    .155 2 0 0   1 1 1  66 10
                    .155 2 0 0   1 1 1  67 11
                    .155 2 0 0   1 1 1  68 12
                     .17 3 0 0  .8 1 1  69 13
                     .17 3 0 0  .8 1 1  70 14
                     .17 3 0 0  .8 1 1  71 15
                     .17 3 0 0  .8 1 1  72 16
                     .17 3 0 0  .8 1 1  73 17
                     .17 3 0 0  .8 1 1  74 18
                     .17 3 0 0  .8 1 1  75 19
                     .17 3 0 0 1.2 1 1  76 20
                     .17 3 0 0 1.2 1 1  77 21
                     .17 3 0 0 1.2 1 1  78 22
                     .17 3 0 0 1.2 1 1  79 23
                     .17 3 0 0 1.2 1 1  80 24
                     .17 3 0 0 1.2 1 1  81 25
                     .17 3 0 0 1.2 1 1  82 26
                     .17 3 0 0  .8 1 1  83 27
                     .17 3 0 0  .8 1 1  84 28
                     .17 3 0 0  .8 1 1  85 29
                     .17 3 0 0  .8 1 1  86 30
                     .17 3 0 0  .8 1 1  87 31
                     .17 3 0 0  .8 1 1  88 32
                     .17 3 0 0  .8 1 1  89 33
                     .17 3 0 0 1.2 1 1  90 34
                     .17 3 0 0 1.2 1 1  91 35
                     .17 3 0 0 1.2 1 1  92 36
                     .17 3 0 0 1.2 1 1  93 37
                     .17 3 0 0 1.2 1 1  94 38
                     .17 3 0 0 1.2 1 1  95 39
                     .17 3 0 0 1.2 1 1  96 40
                     .24 4 0 0   1 1 1  97 41
      3.1641596638655467 5 0 0   1 1 1  98 42
      3.1641596638655467 5 0 0   1 0 1  99  1
      3.1641596638655467 5 0 0   1 1 1 100  1
      end

      Comment


      • #4
        Hello Hemanshu Kumar. Thank you for bringing that to my attention.

        Here is another sample of my data.

        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input double total_legitimacy byte leadership_power float capability_preponderance byte system_effects_isolation double core_interests_weighted float(event_use_of_force group_id seqnum) int _seq
                      .095 1 0 0   . 1 1   1  1
                      .095 1 0 0   . 1 1   2  2
                      .095 1 0 0 1.3 1 1   3  3
                      .095 1 0 0 1.3 1 1   4  4
                      .095 1 0 0 1.9 1 1   5  5
                      .095 1 0 0 1.9 1 1   6  6
                      .095 1 0 0   . 1 1   7  7
                      .095 1 0 0   . 1 1   8  8
                      .095 1 0 0 1.3 1 1   9  9
                      .095 1 0 0 1.3 1 1  10 10
                      .095 1 0 0 1.9 1 1  11 11
                      .095 1 0 0 1.9 1 1  12 12
                      .155 2 0 0   1 0 1  13  1
                      .155 2 0 0   1 1 1  14  1
                      .155 2 0 0   1 1 1  15  2
                      .155 2 0 0   1 1 1  16  3
                      .155 2 0 0   1 0 1  17  1
                      .155 2 0 0   1 1 1  18  1
                      .155 2 0 0   1 1 1  19  2
                      .155 2 0 0   1 1 1  20  3
                      .155 2 0 0   1 1 1  21  4
                      .155 2 0 0   1 1 1  22  5
                      .155 2 0 0   1 1 1  23  6
                      .155 2 0 0   1 1 1  24  7
                      .155 2 0 0   1 1 1  25  8
                      .155 2 0 0   1 1 1  26  9
                      .155 2 0 0 1.5 0 1  27  1
                      .155 2 0 0 1.5 1 1  28  1
                      .155 2 0 0 1.5 1 1  29  2
                      .155 2 0 0 1.5 1 1  30  3
                      .155 2 0 0 1.5 1 1  31  4
                      .155 2 0 0 1.5 1 1  32  5
                      .155 2 0 0 1.5 1 1  33  6
                      .155 2 0 0 1.5 1 1  34  7
                      .155 2 0 0 1.5 0 1  35  1
                      .155 2 0 0 1.5 1 1  36  1
                      .155 2 0 0 1.5 1 1  37  2
                      .155 2 0 0 1.5 1 1  38  3
                      .155 2 0 0 1.5 1 1  39  4
                      .155 2 0 0 1.5 1 1  40  5
                      .155 2 0 0  .8 1 1  41  6
                      .155 2 0 0  .8 0 1  42  1
                      .155 2 0 0  .8 1 1  43  1
                      .155 2 0 0  .8 1 1  44  2
                      .155 2 0 0  .8 1 1  45  3
                      .155 2 0 0  .8 1 1  46  4
                      .155 2 0 0  .8 1 1  47  5
                      .155 2 0 0  .8 0 1  48  1
                      .155 2 0 0  .8 1 1  49  1
                      .155 2 0 0  .8 1 1  50  2
                      .155 2 0 0  .8 1 1  51  3
                      .155 2 0 0  .8 1 1  52  4
                      .155 2 0 0  .8 1 1  53  5
                      .155 2 0 0  .8 1 1  54  6
                      .155 2 0 0   1 0 1  55  1
                      .155 2 0 0   1 0 1  56  2
                      .155 2 0 0   1 1 1  57  1
                      .155 2 0 0   1 1 1  58  2
                      .155 2 0 0   1 1 1  59  3
                      .155 2 0 0   1 1 1  60  4
                      .155 2 0 0   1 1 1  61  5
                      .155 2 0 0   1 1 1  62  6
                      .155 2 0 0   1 1 1  63  7
                      .155 2 0 0   1 1 1  64  8
                      .155 2 0 0   1 1 1  65  9
                      .155 2 0 0   1 1 1  66 10
                      .155 2 0 0   1 1 1  67 11
                      .155 2 0 0   1 1 1  68 12
                       .17 3 0 0  .8 1 1  69 13
                       .17 3 0 0  .8 1 1  70 14
                       .17 3 0 0  .8 1 1  71 15
                       .17 3 0 0  .8 1 1  72 16
                       .17 3 0 0  .8 1 1  73 17
                       .17 3 0 0  .8 1 1  74 18
                       .17 3 0 0  .8 1 1  75 19
                       .17 3 0 0 1.2 1 1  76 20
                       .17 3 0 0 1.2 1 1  77 21
                       .17 3 0 0 1.2 1 1  78 22
                       .17 3 0 0 1.2 1 1  79 23
                       .17 3 0 0 1.2 1 1  80 24
                       .17 3 0 0 1.2 1 1  81 25
                       .17 3 0 0 1.2 1 1  82 26
                       .17 3 0 0  .8 1 1  83 27
                       .17 3 0 0  .8 1 1  84 28
                       .17 3 0 0  .8 1 1  85 29
                       .17 3 0 0  .8 1 1  86 30
                       .17 3 0 0  .8 1 1  87 31
                       .17 3 0 0  .8 1 1  88 32
                       .17 3 0 0  .8 1 1  89 33
                       .17 3 0 0 1.2 1 1  90 34
                       .17 3 0 0 1.2 1 1  91 35
                       .17 3 0 0 1.2 1 1  92 36
                       .17 3 0 0 1.2 1 1  93 37
                       .17 3 0 0 1.2 1 1  94 38
                       .17 3 0 0 1.2 1 1  95 39
                       .17 3 0 0 1.2 1 1  96 40
                       .24 4 0 0   1 1 1  97 41
        3.1641596638655467 5 0 0   1 1 1  98 42
        3.1641596638655467 5 0 0   1 0 1  99  1
        3.1641596638655467 5 0 0   1 1 1 100  1
        end

        Comment

        Working...
        X