Announcement

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

  • Stata error "too many values"

    Dear All, I hope you all are good. I new to this forum. Actually i wnat o compute inequality (gini coefficient) in each cluster of DHS. I have cluster base cell values of DHS but the problem is observations are very high around 1 million. The following error occured when i run the following stata command ineqdeco value, by(srcid_feat) the error is "too many values
    r(134)". Any one who can help me in this? Thanks in advance

  • #2
    I am not familiar with the -ineqdeco- command, but there are other contexts where Stata says "too many values" but means "too many distinct values".

    Comment


    • #3
      I suspect the problem is that you have too many distinct values for your bygroup variable ("srcid_feat"). (I.e., nothing to do with the total number of observations.) -help limits- does not give me the answer about limits I was seeking but my guess -- from the entries there for tabdisp and tabulate -- is that the bygroup limit is between 3000 and 12000. How many distinct values of srcid_feat are there? (-distinct srcid_feat-)

      If all you want is a Gini estimate for each cluster separately, i.e., you don't require the full st of "inequality decomposition by subgroup" statistics, then the way ahead for you might be to simply loop around the distinct values of sccid_feat

      Something like:

      Code:
      egen cluster = group(srcid_feat)  // this may be subject to limits too!
      summarize cluster, meanonly
      local c_max = r(max)
      
      ge cluster_gini  = .
      forvalues c = 1/`c_max' {
        ineqdeco value if srcid_feat  == `c'
        replace cluster_gini = r(gini) if srcid_feat  == `c'
      }
      summarize cluster_gini, detail
      Also look into using -statsby- to achieve the same (or the faster community-contributed command that has the same functionality; on SSC, but I've forgotten the name)

      Instead of using -ineqdeco- (which will calculate more than just the Gini) in this sort of looping, you could use P Van Kerm's -sgini- (SSC) instead. It only calculates a Gini, and so would be faster

      Comment


      • #4
        Sorry, correction to potential code:


        Code:
        egen cluster = group(srcid_feat)  // this may be subject to limits too!
        summarize cluster, meanonly
        local c_max = r(max)
        
        ge cluster_gini  = .
        forvalues c = 1/`c_max' {
          ineqdeco value if srcid_feat  == `c'
          replace cluster_gini = r(gini) if srcid_feat  == `c'
        }
        summarize cluster_gini, detail
        Last edited by Stephen Jenkins; 15 Aug 2022, 07:30.

        Comment


        • #5
          Woops, I pasted in the code to correct it, but then didn't do the correction. Try this one:

          Code:
            
          egen cluster = group(srcid_feat)  // this may be subject to limits too!
          summarize cluster, meanonly
          local c_max = r(max)  
          ge cluster_gini = .
          
          forvalues c = 1/`c_max' {    
             ineqdeco value if cluster == `c' // change made here    
             replace cluster_gini = r(gini) if cluster == `c' // change made here
          }
          
          summarize cluster_gini, detail

          Comment

          Working...
          X