Announcement

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

  • how to calculate age and sex adjusted incidence rates after poisson

    Hello Everyone,
    I have data sets in the format (fage04:female ages 0-4) up to fage85+ and in similar format for males for years 1970-2013. I want to use stratum specific data not the pooled one.Then enter age and sex as covariate in the poisson. Could you please help me with the command?

    Thank you in advance.
    Mithila

  • #2
    Mithila:
    you may want to try:
    Code:
    poisson depvar i.sex##i.age_cat, exposure(n) irr///this way you will also obtain the interaction between sex and age_category
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hello Carlo,
      I do not have either sex as distinct male and female or age catagory .The data looks like this:
      f for female(fage04: female age 0-4 and corresponding number 5 is the no of cases)
      dg_y fage04 fage59 fage1014 fage1519 fage2024 fage2529 fage3034
      1970 5 5 4 1 5 2 3
      1971 2 6 2 2 0 5 5
      1972 6 3 1 4 2 4 3
      1973 4 1 6 0 4 4 8
      1974 4 1 4 3 2 10 8
      fpop04(female population 0-4)
      fpop04 fpop59 fpop1014 fpop1519 fpop2024 fpop2529
      166273 186729 194975 205481 216751 161956
      160437 184936 191684 206166 214936 170361
      153917 183210 189868 203577 213005 190829
      147585 180080 190427 200193 209255 205904
      m for male
      mage04 mage59 mage1014 mage1519 mage2024
      5 6 3 3 4
      1 4 4 1 2
      3 5 1 5 3
      2 4 3 3 5
      and population format for male similar as female.
      What will be the option for such data type?
      Thank you.
      Mithila

      Comment


      • #4
        Mithila:
        your data are very dificult to read. Please post them using the user-written command dataex (install using ssc install dataex) or code delimiters (both recommended by the FAQ). Thanks.
        That said, I would advise to -reshape- your dataset from -wide- to -long- format, first.
        Then you can deal with -poisson-.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Mithila:
          what follows should merge in the same .dta file glioma cases and population for female patients (please note that data concerning population for -fage3034- and -1974- are faked, because they were missing in your previous post. I would recommend you to cross-check them in your dataset):
          Code:
          drop _all
          input dg_y fage04 fage59 fage1014 fage1519 fage2024 fage2529 fage3034
          dg_y     fage04     fage59   fage1014   fage1519   fage2024   fage2529   fage3034
            1970 5 5 4 1 5 2 3
            1971 2 6 2 2 0 5 5
            1972 6 3 1 4 2 4 3
            1973 4 1 6 0 4 4 8
            1974 4 1 4 3 2 1 0 8
            end
          reshape long fage, i( dg_y ) j(fage_group)
          rename fage glioma_cases
          replace glioma_cases=fage04 if glioma_cases==.
          drop fage04
          save "C:\Users\user\Desktop\Glioma_cases_female.dta", replace
          drop _all
          input dg_y  fpop04 fpop59 fpop1014 fpop1519 fpop2024 fpop2529 fpop3034
          
                    dg_y     fpop04     fpop59   fpop1014   fpop1519   fpop2024   fpop2529   fpop3034
            1970 166273 186729 194975 205481 216751 161956 161956
            1971 160437 184936 191684 206166 214936 170361 170361
            1972 153917 183210 189868 203577 213005 190829 190829
            1973 147585 180080 190427 200193 209255 205904 205904
            1974 147585 180080 190427 200193 209255 205904 205904
           end
          reshape long fpop, i( dg_y ) j(fage_group)
          replace fpop = fpop04 if fpop ==.
          drop fpop04
          save "C:\Users\user\Desktop\Glioma_cases_fpopulation.dta", replace
          merge 1:1 dg_y fage_group using "C:\Users\user\Desktop\Glioma_cases_female.dta"
          label define fage_group 4 "0-4" 59 "5-9" 1014 "10-14" 1519 "15-19" 2024 "20-24" 2529 "25-29" 3034 "30-34"
          label val fage_group fage_group
          g sex=1
          label define sex 1 "Female"
          label val sex sex
          drop _merge
          save "C:\Users\user\Desktop\Glioma_cases_and_fpopulation.dta", replace
          You should follow the same approach for male patients. Then you can -append- Glioma_cases_and_fpopulation.dta and Glioma_cases_and_mpopulation.dta files via -sex- variable and save this new file.
          The last step will be to apply -poisson- code reported in post #2 to the data populating the last saved .dta file.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Hello Carlo,
            Now I have done it.I appreciate what you did for me. I could have never done it without your help. Thank you so much.


            Comment


            • #7
              Mithila:
              thanks for your kind words.
              All the best for you and your research.
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment


              • #8
                Thank you Carlo,
                Now I want to use this command
                poisson depvar i.sex##i.age_cat, exposure(n) irr
                I have mglioma_cases, fglioma_cases as depvar. For exposure mpop(male population) and fpop(female population).
                I am wondering how could I fit all those in poisson?
                I have tried with single variable in one time, it does not make any sense.
                or do I need to go with dstdize?

                Thank you.

                Comment


                • #9
                  Mithila:
                  you should -rename- fglioma_cases and fpop in the file concerning female patients:
                  Code:
                  use "C:\Users\user\Desktop\Glioma_cases_and_fpopulation.dta", replace
                  rename fglioma_cases glioma_cases
                  ​rename fpop pop
                  save "C:\Users\user\Desktop\Glioma_cases_and_fpopulation.dta", replace
                  then do the same for male patients.

                  Eventually, you should -merge- both files via-sex- variable and save this new file.
                  The last step will be to apply -poisson- code reported in post #2 to the data populating the last saved .dta file.
                  Kind regards,
                  Carlo
                  (Stata 19.0)

                  Comment


                  • #10
                    Why its saying
                    variable sex does not uniquely identify observations in the master data.


                    Comment


                    • #11
                      Mithila:
                      you're right. My mistake.
                      You should try:
                      Code:
                      use "C:\Users\user\Desktop\Glioma_cases_and_fpopulation.dta", clear
                      append using "C:\Users\user\Desktop\Glioma_cases_and_mpopulation.dta"
                      :
                      Kind regards,
                      Carlo
                      (Stata 19.0)

                      Comment


                      • #12
                        I tried with append also.
                        I am using stat12, while I use append to combine those two files(male and female), it says variable sex does not uniquely identify observations in the master data. For single male and female files, sex variables are clearly labelled.(I have given 1 for female and 2 for male) But when I append them, if I take male as a master data and append female data with it, in sex variable for female it shows 1 not female and if i take female as master data and append male data, it shows 2 for male.Why its happening like that?

                        Did you understand my question?



                        Comment


                        • #13
                          Mithila:
                          unfortunately, I cannot replicate your problem, because -append- the two files worked for me and the label for -sex-, was kept as well (this may prove that I understood your question).
                          Now the issue is: why didn't it work for you?
                          Kind regards,
                          Carlo
                          (Stata 19.0)

                          Comment


                          • #14
                            Ok. Thank you Carlo for help.I have options for appending as:
                            keep all the variables from appending data set/variables to be kept from appending data sets
                            I have tried both but still I have same problem. What did you mean to append via sex? Is there any difference between different versions of Stata

                            Comment


                            • #15
                              Mithila:
                              I don't think that the problem is that different Stata releases behave differently in this respect.
                              Probably, you should post both files you tried to -append-, so that we can take a look.
                              Kind regards,
                              Carlo
                              (Stata 19.0)

                              Comment

                              Working...
                              X