Announcement

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

  • #16

    Sorry, I meant the codes below will give me the prenatal average for the period gen yearmonth= ym(year, month) format yearmonth %tm
    rangestat (mean) rain, interval(yearmonth -10000 -9) by(reg) With regard to the second question, yes I need the mean rainfall or (long term mean which I have already derived (under the name meanrain)), for the region of birth excluding the 9 prenatal months. Hence, it is the mean average for months before and after the prenatal period. Thanks so much for your help. Regards!

    Comment


    • #17
      Please do read and act on the FAQ Advice, especially https://www.statalist.org/forums/help#stata

      Your code is hard to read. It's in your own best interests to present questions clearly. You're relying on volunteer advice here.

      What is the possible causal relevance of rainfall after birth? This seems puzzling epidemiologically... .

      As :@Andrew Musau explains you can use rangestat to get rainfall in a 9 month window. Then you can ask for

      Code:
      rangestat (count) count1=rain (sum) sum1=rain, interval(yearmonth . -9) by(reg)
      for the past and

      Code:
      rangestat (count) count2=rain (sum) sum2=rain, interval(yearmonth 1 .)  by(reg)
      for the future and then the average you seek is

      Code:
      gen wanted = (sum1 + sum2) / (count1 + count2)
      The results will be very sensitive to length and quality of record, and you don't seem to consider the possibility of climate change. The idea of a long-term average is distinctly moot.

      Further, rainfall can be highly variable locally, and regional averages are often not worth much.

      Comment


      • #18
        Dear Nick,

        Thank you for your reply.

        Understood. Indeed, it should be the long term mean (long run average) before the prenatal period in a given region of birth.

        Sorry for being unclear with my questions.

        Thanks again for your help!

        Regards!


        Comment


        • #19
          Dear Statalist,

          I am working with rainfall and child health data. I have the month, year, historical mean and the mean rainfall for a calendar month. I am trying to generate a variable to define the "normal rainfall, as well as to measure the prenatal exposure to normal rainfall (please see below). In addition, I would like to consider the trimesters.

          I am grateful for your help with the following:

          1. I would like to define the normal rainfall for a given month if rainfall fell within one standard deviation of historical mean for that particular calendar month, however the normal rainfall should not be taken in an absolute sense as I will not be comparing the regions. Is there away to generate the normal rainfall using this approach?

          2. I have data on children born within a flood period and would like to measure prenatal exposure as the fraction of normal rainfall months occurring in the 9 months before birth.

          3. I would like to consider the first, second and third trimesters. I would like to define the 1st Trimester as the fraction of months during the 6-8 months before birth that the normal rainfall indicator equal 1. 2nd trimester as the fraction of months during the 3-5 months before birth that the normal rainfall indicator equal 1. Finally, the 3rd trimester as the fraction of months during the 0-2 months before birth that the normal rainfall indicator equal 1.

          I am very grateful for your help!

          Below is an example of the data.

          month year meanrain raininyear
          7 2004 26.33825 28.85667
          7 2004 26.33825 28.85667
          8 2004 21.87548 21.63
          8 2004 21.87548 21.63
          8 2004 21.87548 21.63
          8 2004 21.87548 21.63
          8 2004 21.87548 21.63
          8 2004 21.87548 21.63
          8 2004 21.87548 21.63
          9 2004 16.78079 13.12667
          9 2004 16.78079 13.12667
          9 2004 16.78079 13.12667
          9 2004 16.78079 13.12667
          9 2004 16.78079 13.12667
          10 2004 18.43741 19.59
          11 2004 20.09833 19.315
          11 2004 20.09833 19.315
          11 2004 20.09833 19.315
          11 2004 20.09833 19.315
          11 2004 20.09833 19.315
          12 2004 26.05887 22.55

          Thank you.

          Regards!

          Comment


          • #20
            #19 doesn't fit the thread title and is wasted here. You have also posted the same question under an equally irrelevant title in another thread.

            What you could do is start a new thread and give it a relevant title.

            That said, I don't think that the title is the major issue. I doubt that anyone can do much with the questions as they stand.

            I have worked with rainfall data but #1 is not clear to me.

            I doubt that #2 or #3 are clear to anyone as your example data say nothing about pregnancy or births. At that point a reader is just guessing wildly at what those medical data might be, and I doubt that they will want to do that

            You need Stata help, but your best way to get it is to find someone at your workplace who knows more.

            Comment


            • #21
              Dear Nick,

              Thank you for your reply.

              With regard to the first question, I would like to find the fraction of normal rainfall months in the 9 months before birth.
              I have the historical mean and the monthly rain data for the region of birth for each child (seen in #19) and I was also able to generate the average rainfall in the region of birth for the period before (9 months) birth (prenatal exposure). However, this approach also captured the flood exposure (#7 - #17); I would like to also find the normal rainfall conditions in utero.

              I have also generated a flood dummy using:

              [egen meanr = mean(raininyear), by (reg year)]

              [egen stdr = sd(raininyear), by (reg year) ]

              [gen flood = raininyear > meanr + stdr]

              I used the above to determine whether the child was born in a flood month (Dec 2004 - late Jan 2005).

              I would like to generate a "normal rainfall" representing in the months before birth that the child was exposed to "normal rainfall". I would like to define the "normal rainfall" for a given month if rainfall fell within one standard deviation of historical mean. Then, I will measure prenatal exposure as the fraction of normal rainfall months occurring 9 months before birth.

              I pray this is clearer.

              Thank you.

              Regards!

              Comment


              • #22
                Dear Andrew,

                I have a follow up question regarding post #13. I would now like to calculate the rainfall in the 12 months after birth. I am wondering if the code below would be relevant for this:

                rangestat (mean) rain, interval(yearmonth 11 0) by(reg)
                ​​​​​​

                Thanks for your reply.

                Regards!

                Comment


                • #23
                  Please copy and paste the previous data example and start a new thread with a relevant title.

                  Comment

                  Working...
                  X