Announcement

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

  • Incidence with aggregate data

    Hello everyone,

    I'm working on a dataset which contains the following variables: year sex agegroup numberofcases totalpopulation. I'm trying to compute the yearly incidence for each sex and agegroup with 95% CI.

    The
    Code:
    proportion
    or
    Code:
    ci proportions
    commands don't work as they need a binary variable to work with (e.g. case(0/1)).

    I thought the
    Code:
    expand
    command would be of use, but since totalpopulation range is in the millions it is too computationally intensive. I have seached the Statalist but found no solution.

    Anyone could help?

    Thank you in advance!

  • #2
    Maybe Poisson regression with offset? See this: https://www.stata.com/manuals/rpoisson.pdf, Example 2 starting on page 6 may be useful.

    Comment


    • #3
      This seems exactly the task for which the command -xcipoibin- was thought (if you want binomial exact CIs) (disclaimer: I am the author of this user-contributed command).

      See:
      https://github.com/anddis/xcipoibin
      https://anddis.github.io/xcipoibin/xcipoibin_ex.html

      Otherwise, you can always use a -forvalues- loop and -cii proportions-, for example

      Code:
      use https://raw.githubusercontent.com/anddis/xcipoibin/master/ex_ir.dta, clear // example data
      
      
      // loop
      gen double p = .
      gen double l = .
      gen double u = .
      
      qui forvalues i = 1/8 {
          cii proportions person_years[`i'] obs_pca_cases[`i'], exact
          replace p = r(proportion) in `i'
          replace l = r(lb) in `i'
          replace u = r(ub) in `i'
      }
      
      // xcipoibin
       xcipoibin  obs_pca_cases person_years, binomial
       
       list
      Last edited by Andrea Discacciati; 05 Dec 2023, 07:53.

      Comment


      • #4
        Thank you so much, Andrea, your solution works fine!

        Comment

        Working...
        X