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

  • Is Stata able to do Bayesian analysis?

    Well, hello guys, I am learning Bayesian analysis. It's not easy to understand the logic behind it. Stata can do Bayesian analysis?

  • #2
    Hi Tom
    You can watch some example as following link:
    Last edited by Myo Win; 14 Jun 2018, 07:52.


    • #3
      Thank you, Myo!


      • #4
        Welcome Tom.... May be the following code useful for you...
        webuse oxygen
        bayesmh change age group, likelihood(normal({var})) prior({change:}, flat) prior({var}, jeffreys) saving(bayes1)
        bayesmh change age group, likelihood(normal({var})) prior({change:}, flat) prior({var}, jeffreys) saving(bayes2)
        append using bayes1 bayes2, gen(chain)
        describe eq*, varl
        xtset chain _index
        twoway tsline eq1_p1 if chain==1 || tsline eq1_p1 if chain==2

        Type this "help bma" in command window ...........

        use data_mpp_small

        . bma growth gdp60 equipinv confuc school60 life60 law tropics avelf, auxiliary(mining dpop pright malaria)

        . bma growth, auxiliary(gdp60 equipinv confuc school60 life60 law tropics avelf mining dpop pright malaria)


        • #5
          sysuse cancer

          bayesmh died i.drug age, likelihood(logit) prior( {died:}, normal(0,10)) ///
          saving(both, replace)
          estimates store both

          bayesmh died age, likelihood(logit) prior( {died:}, normal(0,10)) ///
          saving(age_only, replace)
          estimates store age_only

          bayesmh died i.drug, likelihood(logit) prior( {died:}, normal(0,10)) ///
          saving(drug_only, replace)
          estimates store drug_only

          bayesmh died , likelihood(logit) prior( {died:}, normal(0,10)) ///
          saving(intercept, replace)
          estimates store intercept

          bayesstats ic intercept drug_only age_only both, basemodel(intercept)
          bayestest model intercept drug_only age_only both

          Credit to : Matt


          • #6
            Well, the Bayesian analysis method to calculate the probability is quite quite different from conventional statistical procedures.


            • #7
              If you have Stata 15.1, just type - help bayes - and you'll get great information.

              Also, there is a whole Stata Manual specifially on this matter, here.

              Logically, as it happens to the manuals, this manual approaches mostly the commands and results, hence a deep theoretical background shall be looked for elsewhere.
              Last edited by Marcos Almeida; 14 Jun 2018, 08:57.
              Best regards,



              • #8
                Hello Tom,

                I would like to add to what Marcos and Myo said. For a good overview of Bayesian analysis in Stata, this is a great resource:


                The information in the link above gives you a sense of the breadth of the tools for Bayesian analysis. You could use any of more than 50 likelihood-based estimators in Stata to do Bayesian analysis.


                The models you can fit not only include cross-sectional models but also multilevel models.


                Another cool feature is that if none of the existing models is exactly what you want you can construct your own model.



                • #9
                  Thanks guys. I learned a lot these couple of days. The guy who invented Bayesian analysis was (is) a genius. The bayesian analysis is beautiful, mathematically.