Announcement

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

  • CI Decmposition Results not Showing percentage contribution

    Hi All,

    I am using Stata 16 and trying to decompose the concentration index but the results show nothing for percentage contribution. My dependent variable is a binary variable, obese or not obese. My dependent variables are quintile , feedingscheme (whether a student participates in school feeding program or not), adorace(ado for adolescent, African/White/Coloured/Asian), adogender(male/female), employ_m (whether mother is employed), educ_m and wgt_m.

    The commands are as follows: using Erreygers

    Code:
    sca CI=r(CI)
    global X  quintile feedingscheme adorace adogender empl_m educ_m wgt_m
    qui sum obese [aw=wt]
    sca m_obese=r(mean)
    qui glm obese $X [aw=wt], family(binomial) link(logit)
    qui margins , dydx(*) post
    
    foreach x of varlist $X {
    sca b_`x'=_b[`x']
    }
    foreach x of varlist $X {
    qui{
    conindex `x' [aw=wt], rankvar(quintile) truezero
    sca CI_`x' = r(CI)
    sum `x' [aw=wt]
    sca m_`x'=r(mean)
    sca elas_`x' = b_`x'*m_`x'
    sca con_`x' = 4*elas_`x'*CI_`x'
    sca prcnt_`x' = (con_`x'/CI)*100
    }
    di "`x' elasticity:", elas_`x'
    di "`x' concentration index:", CI_`x'
    di "`x' contribution:", con_`x'
    di "`x' percentage contribution:", prcnt_`x'
    }
    matrix Aaa = nullmat(Aaa) \ (elas_`x', CI_`x', con_`x', prcnt_`x')
    }
    matrix rownames Caa= $X
    matrix colnames Caa = "Elasticity""CI""Absolute""%"
    matrix list Caa, format(%8.4f)
    clear matrix
    The results show just a fullstop next to each variable percentage contribution. And it also gives an error message "elas_ not found". I have defined elasticity

    quintile elasticity: .02855949
    quintile concentration index: .26154029
    quintile contribution: .02987783
    quintile percentage contribution: .
    feedingscheme elasticity: .03727037
    feedingscheme concentration index: .05987572
    feedingscheme contribution: .00892636
    feedingscheme percentage contribution: .
    adorace elasticity: -.01348892
    adorace concentration index: .01036392
    adorace contribution: -.00055919
    adorace percentage contribution: .
    adogender elasticity: .02694672
    adogender concentration index: -.00403962
    adogender contribution: -.00043542
    adogender percentage contribution: .
    empl_m elasticity: .01834728
    empl_m concentration index: .06688754
    empl_m contribution: .00490882
    empl_m percentage contribution: .
    educ_m elasticity: .02113921
    educ_m concentration index: .08112557
    educ_m contribution: .00685972
    educ_m percentage contribution: .
    wgt_m elasticity: .15021019
    wgt_m concentration index: .01183257
    wgt_m contribution: .00710949
    wgt_m percentage contribution: .

    . matrix Aaa = nullmat(Aaa) \ (elas_`x', CI_`x', con_`x', prcnt_`x')
    elas_ not found
    r(111);

    My dataex results are as follows:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte quintile float(feedingscheme adorace adogender empl_m educ_m wgt_m)
    . . . . . . .
    . . . . . . .
    . . . . . . .
    . . . . 1 1 2
    1 1 2 2 1 1 2
    . . . . . . .
    . . . . . . .
    . . . . . . .
    . . . . . . .
    . . . . 1 1 2
    . . . . . . .
    . . . . . . .
    . . . . . . .
    . . . . . . .
    . . . . 2 1 3
    . . . . 2 1 3
    . . . . 2 1 3
    . . . . . . .
    2 2 2 2 2 1 3
    . . . . 2 1 3
    . . . . . . .
    . . . . . . .
    . . . . . . .
    3 1 2 2 . . .
    3 1 2 1 . . .
    . . . . . . .
    . . . . . . .
    3 1 2 2 . . .
    . . . . 1 1 3
    . . . . . . .
    . . . . . . .
    3 1 2 1 2 1 2
    3 1 2 2 2 1 2
    . . . . 2 1 2
    . . . . 2 1 2
    1 1 2 1 . . .
    1 1 2 1 . . .
    1 . 2 1 . . .
    1 1 2 1 . . .
    . . . . . . .
    . . . . . . .
    1 . 2 2 . . .
    1 1 2 2 1 1 3
    . . . . . . .
    . . . . . . .
    . . . . . . .
    1 1 2 1 1 1 3
    1 1 2 2 1 1 2
    1 1 2 2 1 1 3
    . . . . . . .
    . . . . . . .
    . . . . . . .
    . . . . . . .
    . . . . . . .
    1 1 2 2 . . .
    . . . . . . .
    . . . . . . .
    1 1 2 2 . . .
    1 1 2 1 . . .
    . . . . . . .
    . . . . . . .
    . . . . . . .
    . . . . . . .
    . . . . 1 2 2
    . . . . . . .
    . . . . . . .
    . . . . 1 1 2
    . . . . . . .
    . . . . 1 2 2
    2 1 2 2 1 2 2
    . . . . 1 2 2
    1 . 2 1 1 1 1
    . . . . . . .
    . . . . . . .
    2 1 2 1 2 1 3
    2 2 2 2 2 1 3
    2 . 2 2 2 1 3
    . . . . . . .
    2 1 2 2 2 1 3
    . . . . 1 3 3
    2 1 2 2 2 1 3
    . . . . 1 1 3
    . . . . 1 1 3
    . . . . . . .
    . . . . 1 2 3
    . . . . 1 2 3
    . . . . 1 2 3
    . . . . 1 2 3
    . . . . 1 1 3
    . . . . . . .
    1 2 2 2 1 1 3
    . . . . . . .
    . . . . 1 2 3
    . . . . 1 2 3
    1 1 2 1 1 1 3
    1 1 2 2 1 1 3
    . . . . 1 1 3
    . . . . 1 1 3
    . . . . . . .
    1 2 2 1 1 2 3
    end
    label values feedingscheme feedingscheme5
    label def feedingscheme5 1 "fscheme", modify
    label def feedingscheme5 2 "nfscheme", modify
    Please assist.

    Regards
    Nthato

    Last edited by Nthato Ras; 27 Jun 2022, 13:42. Reason: Need to mention the type of decomposition. Erreygers

  • #2
    It seems likely that the missing percentages are because the scalar CI is in fact a missing value or zero at that point, or else you also have a variable in your dataset whose name begins with CI, which may cause it to take precedence over the scalar of the same name. You should
    Code:
    di "CI: ", CI, scalar(CI)
    immediately after it is defined, and just before the calculation of prcnt_`x', and I think you'll see that CI is not what you think it is.

    The error on the matrix command occurs because that command is outside of the loop over the local macro x, so that local macro is undefined at that point, and the variable name elas_`x' becomes elas_x.

    Comment


    • #3
      Hi William,

      Thanks for the response.

      I do not have any variable that begins with CI. I put the code below as per suggestion

      Code:
      di "CI: ", CI, scalar(CI)
      and got an error message "scalar not found".

      How do I define sca CI? I couldn't find anything on the internet.

      However, my concentration index is as per below.

      . conindex obese [aweight=wt], rankvar(quintile) erreygers bounded limits (0 1)

      Index: No. of obs. Index value Std. error p-value
      -
      Erreygers norm. CI 20341 .0467093 .00407087 0.0000



      Last edited by Nthato Ras; 27 Jun 2022, 16:47. Reason: Need to add my concentration index

      Comment


      • #4
        Hi William,

        I think you responded but the message vanished as I was about to click on it. Please re submit if you responded.

        Thanks

        Comment


        • #5
          The first line in the code in post #1 is
          Code:
          sca CI=r(CI)
          which defines the scalar CI as the concentration index returned as r(CI) by the conindex command which should be run immediately before your code in post #1.

          Comment


          • #6
            It was my mistake. I did not run conindex as part of the whole loop. I ran it first, followed by the loop from sca CI.

            Thank you William!

            Comment


            • #7
              Hi all,
              I am new for health inequity index analysis using STATA. Health variable has bivariable outcome (Yes, No) and wealth index by quantile (Poorest, poor, moderate, rich, richest). I also plan to decompose concentration index to other need and non-need categorical variables.
              I would be happy if you advise me about this issue?
              Thank you!

              Comment


              • #8
                Dear Aklilu,

                Welcome! You have come to the correct platform for advise. I am very happy with the assistance I have received from this platform. If you want to get advise quickly, please read FAQs first. This explain how to ask questions so that everyone can understand and look at you data to assist. You will also need to install ssc so that we can see your data. This increases the chance of your question being responded to quickly.

                Thanks
                Nthato

                Comment

                Working...
                X