Announcement

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

  • Bayes in Stata: how many MCMC chains?

    Hi

    Reading help files and also when looking at Bayesian trace plots provided by Stata, it appears that Stata only uses one MCMC chain. Is this a correct understanding of Stata's Baysian analysis? We should use two ore more chains (and see how they overlap/converge), so the next question would be: if Stata uses only one chain, can this be overruled by asking for two chains?
    Last edited by sladmin; 11 Dec 2017, 09:55. Reason: anonymize poster

  • #2
    For anyone interested, I asked Stata Technical Support for advice, this is the answer I received:

    Yes, Stata uses only one chain in -bayesmh-, and there is currently no
    option to specify otherwise.

    Comment


    • #3
      Couldn't you run the chains in tandem, saving the results (discarding burn-in and adaptation samples) to separate files, and then append or merge the files for plotting the traces in parallel, computing Gelman-Rubin diagnostics or whatever?

      Somewhere (where will depend upon whether you're appending or merging), you'll need to do something like the following (details of the code will also depend upon whether you're appending or merging)
      Code:
      quietly expand _frequency
      sort _index
      quietly replace _index = _n
      in order to get the chains to align.

      Comment


      • #4
        Indeed, Joseph, you can improvise to have two chains, even though Stata currently does not offer that as part of the standard input (or as the default, which I think Stata should have, with the option to run more than two chains). Apart from telling me that my concern would be forwarded to the developers, the answer from Stata Technical Support also included this:

        ---------

        In the meantime, you can produce trace plots for two chains by doing
        something like the following:

        Code:
            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)
            clear
            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
        --------

        Your suggestion for comparing the chains is interesting.

        Comment


        • #5
          If you're doing just trace (line) plots, then you won't need to expand. The line plot continues level until the next new y-value, and the change will be made at the corresponding value of x (value of _index).

          Comment

          Working...
          X