Announcement

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

  • Calculating rate ratios with CI for directly standardized rates

    Hello,

    I have grouped data that describes cases and person years stratified by age, sex and population group. Please see the whole data set below. I calculated disease rates for each population group, directly standardized by age and sex, using this code and it worked:

    dstdize cases p_yrs age sex, by(pop) using (stan_pop) format(%16.0g)

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long p_yrs byte cases long(age sex pop)
    2415226 26 1 1 2
      63481  8 1 1 3
     106578 11 1 1 4
    2585285 45 1 1 1
    2539317 13 1 2 2
      67443  8 1 2 3
     112972 12 1 2 4
    2719732 33 1 2 1
    2292152 11 3 1 2
     142066  4 3 1 3
     135532  9 3 1 4
    2569750 24 3 1 1
    2417021  7 3 2 2
     145811  6 3 2 3
     138788 11 3 2 4
    2701620 24 3 2 1
    2293798  3 2 1 2
     186762 23 2 1 3
     125305  5 2 1 4
    2605865 31 2 1 1
    2427720  1 2 2 2
     195853 10 2 2 3
     131491  8 2 2 4
    2755064 19 2 2 1
    end
    label values age age
    label def age 1 "0to4", modify
    label def age 2 "10to14", modify
    label def age 3 "5to9", modify
    label values sex sex
    label def sex 1 "female", modify
    label def sex 2 "male", modify
    label values pop pop
    label def pop 1 "al_pop", modify
    label def pop 2 "cbo", modify
    label def pop 3 "fb", modify
    label def pop 4 "si", modify
    This data set was used as the standard population for direct standardization:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long(p_yrs age sex)
    2585285 1 1
    2719732 1 2
    2569750 3 1
    2701620 3 2
    2605865 2 1
    2755064 2 2
    end
    label values age age
    label def age 1 "0to4", modify
    label def age 2 "10to14", modify
    label def age 3 "5to9", modify
    label values sex sex
    label def sex 1 "female", modify
    label def sex 2 "male", modify
    .
    Now I would just like to calculate rate ratios and their CIs, but cannot figure out how to do that. Thanks in advance for any help.

    Jennifer

  • #2
    Hello Stata users,

    In addition to the above post, I am running Stata 11 on Windows 10. I apologize for the omission. Thanks.

    Jennifer

    Comment


    • #3
      Hello Jennifer,

      Welcome to the Stata Forum / Statalist.

      I wonder whether the command ir as well as the immediate iri from the "tables for epidemiologists" apply to your needs.
      Last edited by Marcos Almeida; 29 Mar 2017, 11:32.
      Best regards,

      Marcos

      Comment


      • #4
        Jennifer, do you want to calculate CIs for crude Incidence Rate Ratios (# cases / total person-time)? If so, a common approach is to assume that the number of events follows a Poisson distribution and calculate exact CIs (help cii).

        Comment


        • #5
          Thanks for your replies, Marcos and Andrea. I missed something else in my original post (Apologies!). I would like the the standardized rate ratios and CIs, not the crude rate ratios. To my novice understanding, the iri command needs the cases and person time, but this gives the RR and ci for the crude rates, not the standardized rates. I will look into the cii command more. Thanks again to you both.

          Jennifer

          Comment


          • #6
            Jennifer, -dstdize- gives you exactly that: standardized IRRs and CIs (columns Adj_Rate and Confidence Interval, respectively - see below).

            Code:
            dstdize cases p_yrs age sex, by(pop) using ("/Users/anddis/Desktop/stdpop") format(%16.0g)
            
            (...output omitted...)
            
            Summary of Study Populations:
                  pop             N      Crude     Adj_Rate       Confidence Interval
             --------------------------------------------------------------------------
                    1      15937316  .00001104326475 .00001104326475[ 9.411766441e-06, .00001267476306]
                    2      14385234  4.240459349e-06 4.169693966e-06[ 3.123040394e-06, 5.216347249e-06]
                    3        801416  .00007361969314 .00008116313984[ .00005779728403, .00010452900014]
                    4        750666  .00007460042149 .00007605364226[ .00005603279297, .00009607448602]

            Comment


            • #7
              Hi Andrea,

              The way I understand this output is such: it gives the crude and adjusted rates (with associated CIs) by population group, but I do not see how it gives the rate ratios. I would like to compare the adjusted rates of the population groups to each other. For example: I would like Pop 2 to be the reference or baseline, then obtain the rate ratio: pop 3 adj. rate/pop 2 adj. rate and the associated CI. I just don't see where this information is in this output or how to generate it. I very much appreciate your input and patience in the matter. Thank you.

              Jennifer

              Comment


              • #8
                I'm sorry Jennifer, I misread your posts multiple times. You're absolutely right: -dstdize- won't give you ratios of directly-standardized IRs with relative CIs.

                The user-written command -distrate- (findit distrate) will give you what you want. Look in particular at the option refrate(#)
                Last edited by Andrea Discacciati; 31 Mar 2017, 01:18.

                Comment


                • #9
                  Ok, thanks Andrea. I will look into it and see if I can figure it out. I appreciate your input.

                  Jen

                  Comment


                  • #10
                    You need to sort by age and sex the dataset with the standard population and save it first.



                    Code:
                    . distrate cases p_yrs using "/Users/anddis/Desktop/std_pop", stand(age sex) by(pop) refrate(2)
                    
                    Directly standardized rates
                    CI based on the gamma distribution (Fay and Feuer, 1997. Tiwari and al., 2006)
                    
                      +---------------------------------------------------------------------------------------------------------------------------+
                      |    pop   cases          N       crude     rateadj      lb_gam      ub_gam      se_gam         srr      lb_srr      ub_srr |
                      |---------------------------------------------------------------------------------------------------------------------------|
                      | al_pop     176   1.59e+07   .00001104   .00001104   9.472e-06    .0000128   8.348e-07   2.6484594   1.9681616   3.6049091 |
                      |    cbo      61   1.44e+07   4.240e-06   4.170e-06   3.189e-06   5.358e-06   5.385e-07           1           .           . |
                      |     fb      59     801416   .00007362   .00008116    .0000595    .0001079   .00001204   19.465013   12.987831   28.923705 |
                      |     si      56     750666    .0000746   .00007605   .00005736   .00009886    .0000103   18.239622   12.441767   26.673091 |
                      +---------------------------------------------------------------------------------------------------------------------------+

                    Comment


                    • #11
                      Hi Andrea,

                      Just wanted to say thank you for the advice. It worked!

                      Jen

                      Comment


                      • #12
                        Hello,

                        First of all I dont know if this is the proper site to publish this, correct me if its not.

                        Need some help:

                        I'd used the "distrate" command on a database "DATA.dta" before.

                        Done the cleaning on the database and then I modified the "pop.dta" file in which i had the persons-year since the catchment area was modified.

                        The original code was:
                        Code:
                        distrate cases pop using pop.dta, standstrata(age_grp) popstand(pop) by(year sex) format(%8.1f) mult(100000)
                        the results were good expressed this way
                        Code:
                         
                         | year     sex    cases  N   crude     rateadj      lb_gam      ub_gam      se_gam |
                        Did it twice with 2 different "pop.dta" and "pop2.dta" since i needed it with both.

                        The code was saved on the do-file

                        Now the issue im having is that i try to run the code and it says that

                        varibale pop not found
                        r(111);
                        Need help: tried using old data base, tried making a new pop dta file for the person-years and nothing.

                        thanks for your help.

                        Comment

                        Working...
                        X