Announcement

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

  • SIR Model

    Hi everyone!! Is there any way to fit SIR Models in Stata?

  • #2
    Perhaps this might be of help. https://www.stata.com/support/faqs/p...ear-equations/

    Comment


    • #3
      Thank you very much

      Comment


      • #4
        Hi Osella,

        I have been doing projections since April with SIR and other models (sites.google.com/site/shafiunihe). You can use NL logistic of Stata to estimate the parameters of logistic functions to make projections.

        Step 1: load data and declare the date variables ( if date is not detected by stata you can follow this: gen date=date(datevariable name in your dataset, "MDY") and then run format date %td)
        Step2: Run nl log4 (i.e. 4 parameter logistics), command: nl log4: total_cases date, you will get estimated parameters (lowest one is the lowest value of cases, highest one is the highest value, there is a value in between which is an inflection point. and you will see a growth coefficient (which is less than one usually) and this growth coefficient is equivalent to beta-gamma (I am still looking to estimate beta and gamma separately from this)
        Step 3: set observation n+i (n is your current obs number and i is the days for which you want to do projection), then gen day=n+i
        Step 4: predict total_cases_predicted
        Step 5: tsset day
        Step 6: tsline total_cases total_cases_predicted (for graph)

        From my experience, if any country is in the early stages of the epidemics then expontential/gomperzt does better job which can be easily done with stata nl command, logistic may give a false notion of early ending of epidemics

        This package (epimodels) will also be helpful if you want to do simulation, instead of estimating parameters.

        I'll be trying to write Stata program to do all these things. If I finally do, I'll definitely share.





        Comment


        • #5
          Hi Osella,

          I have been doing projections since April with SIR and other models (sites.google.com/site/shafiunihe). You can use NL logistic of Stata to estimate the parameters of logistic functions to make projections.

          Step 1: load data and declare the date variables ( if date is not detected by stata you can follow this: gen date=date(datevariable name in your dataset, "MDY") and then run format date %td)
          Step2: Run nl log4 (i.e. 4 parameter logistics), command: nl log4: total_cases date, you will get estimated parameters (lowest one is the lowest value of cases, highest one is the highest value, there is a value in between which is an inflection point. and you will see a growth coefficient (which is less than one usually) and this growth coefficient is equivalent to beta-gamma (I am still looking to estimate beta and gamma separately from this)
          Step 3: set observation n+i (n is your current obs number and i is the days for which you want to do projection), then gen day=n+i
          Step 4: predict total_cases_predicted
          Step 5: tsset day
          Step 6: tsline total_cases total_cases_predicted (for graph)

          From my experience, if any country is in the early stages of the epidemics then expontential/gomperzt does better job which can be easily done with stata nl command, logistic may give a false notion of early ending of epidemics

          This package (epimodels) will also be helpful if you want to do simulation, instead of estimating parameters.

          I'll be trying to write Stata program to do all these things. If I finally do, I'll definitely share.





          Comment


          • #6
            Hi Osella,

            I have been doing projections since April with SIR and other models (sites.google.com/site/shafiunihe). You can use NL logistic of Stata to estimate the parameters of logistic functions to make projections.

            Step 1: load data and declare the date variables ( if date is not detected by stata you can follow this: gen date=date(datevariable name in your dataset, "MDY") and then run format date %td)
            Step2: Run nl log4 (i.e. 4 parameter logistics), command: nl log4: total_cases date, you will get estimated parameters (lowest one is the lowest value of cases, highest one is the highest value, there is a value in between which is an inflection point. and you will see a growth coefficient (which is less than one usually) and this growth coefficient is equivalent to beta-gamma (I am still looking to estimate beta and gamma separately from this)
            Step 3: set observation n+i (n is your current obs number and i is the days for which you want to do projection), then gen day=n+i
            Step 4: predict total_cases_predicted
            Step 5: tsset day
            Step 6: tsline total_cases total_cases_predicted (for graph)

            From my experience, if any country is in the early stages of the epidemics then expontential/gomperzt does the better job which can be easily done with stata nl command, logistic may give a false notion of the early ending of epidemics

            This package (epimodels) will also be helpful if you want to do simulation, instead of estimating parameters.

            I'll be trying to write Stata program to do all these things. If I finally do, I'll definitely share.

            Comment


            • #7
              Hi everyone!! Is there any way to fit SIR Models in Stata?
              Yes, EPIMODELS package simulates SIR and SEIR models.
              http://www.radyakin.org/stata/epimodels/

              The version released through SSC doesn't do the fitting yet, but I have a version that is doing this already.
              If Alberto Osella wants to have an early look, please PM me.

              Click image for larger version

Name:	epifit_SIR.png
Views:	1
Size:	19.7 KB
ID:	1554353
              ​​​​​​​

              Click image for larger version

Name:	SIR-fit.png
Views:	2
Size:	145.8 KB
ID:	1554352

              Comment


              • #8
                @Sergiy Radyakin: Wow! Great. Congratulations. I would love to have it. Would you please share it with me? my email: shafiun.ihe@gmail.com; sshimul@worldbank.org

                Comment


                • #9
                  Thanks for the fantastic work Sergiy. Kindly share it with me too. I have sent you direct message through this forum too.

                  Comment


                  • #10
                    Hello Sergiy, I would also be interested in a fitting version of epimodels

                    Comment


                    • #11
                      Hi Sergiy, Could you please share it with me as well. It is a great job.

                      Comment


                      • #12
                        Hello Sergiy, can you please share it with me as well. Much thanks, and please give me an idea about how I should cite?

                        Comment


                        • #13
                          please give me an idea about how I should cite?
                          The RePEc page contains a suggested citation that clearly points any readers to the place where the program may be downloaded.

                          Comment


                          • #14
                            EPIMODELS was updated online, see info here:
                            https://www.statalist.org/forums/for...updated-at-ssc

                            Comment


                            • #15
                              Hi everyone,
                              I am trying to simulate the potential number of COVID-19 infections in a given country in absence of restrictive measures. I have data about the cumulative number of positive cases.
                              I was trying to fit a Gompertz distribution (as mentioned by @Shafiun Shimul) in the first weeks and then use it to predict the values in the subsequent days.
                              However, I notice that moving the threshold a little makes results change dramatically. Is there a method to test which is the exact threshold date which should be set? Or maybe is this method not so reliable?
                              Thanks a lot in advance!

                              Comment

                              Working...
                              X