Announcement

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

  • Help replicate a simple Bayesian model

    Hello everyone,

    I'm trying to replicate a simple example of Bayesian Analysis as in the Federal Fund Rate example on page 47-51 in this file https://www.stata.com/meeting/chicago16/slides/chicago16_balov.pdf

    Code:
    use http://www.stata-press.com/data/r15/usmacro
    
    mswitch dr fedfunds
    
    generate id=_n
    
    help fvset
    
    fvset base none id
    
    set seed 12345
    
    bayesmh fedfunds = (({state:}==1)*{mu1}+({state:}==2)*{mu2}), ///
    likelihood(normal({sig2})) redefine(state:i.id) ///
    prior({state:}, index({p1}, (1-{p1}))) ///
    prior({p1}, uniform(0, 1)) ///
    prior({mu1} {mu2}, normal(0, 100)) ///
    prior({sig2}, igamma(0.1, 0.1)) ///
    init({p1} 0.5 {mu1} 1 {mu2} 1 {sig2} 1 {state:} 1) ///
    block({sig2}, gibbs) block({p1}) block({mu1}{mu2}) ///
    exclude({state:}) dots
    However, even though I copied and and pasted the whole code in the example it keeps returning this error
    Code:
    "bayesmh fedfunds = (({state:}==1)*{mu1}+({state:}==2)*{mu2}), ///
    invalid bayesmh specification
    To fit one of the supported models, you must specify a likelihood model in option likelihood() and a prior distribution in option prior(). To fit your own model, you must specify, for example, the name of your posterior-function evaluator in option evaluator(). See bayesmh and bayesmh evaluators for details. r(198);"
    I just want to replicate this example, so that I can apply it for my other analysis. Any help on how to replicate the example would be very appreciated!

    Many thanks.

  • #2
    Repost of https://www.statalist.org/forums/for...archical-model

    Cross-posted at https://www.reddit.com/r/stata/comme...rchical_model/

    Please see FAQ https://www.statalist.org/forums/help#adviceextras #1 on repeating posts (summary: not a good idea) and https://www.statalist.org/forums/help#crossposting on our policy on cross-posting (summary: you are asked to tell us about it).

    This question is a long way away from my expertise. I would take it to StataCorp technical support on Monday if you don't get an answer before then.

    Comment


    • #3
      I'm guessing you ran this in Stata's command line and not from a do-file. Copy the whole block into a do file and then run the do file. It should work if you've copied it from the slide and not made any changes.

      Comment


      • #4
        Originally posted by Nick Cox View Post
        Repost of https://www.statalist.org/forums/for...archical-model

        Cross-posted at https://www.reddit.com/r/stata/comme...rchical_model/

        Please see FAQ https://www.statalist.org/forums/help#adviceextras #1 on repeating posts (summary: not a good idea) and https://www.statalist.org/forums/help#crossposting on our policy on cross-posting (summary: you are asked to tell us about it).

        This question is a long way away from my expertise. I would take it to StataCorp technical support on Monday if you don't get an answer before then.
        Dear Nick,

        Thank you for your advice and suggestion. I'm sorry I was in a hurry and needed to know the answer ASAP. I'll keep this in mind next time!

        Best,

        Comment


        • #5
          Originally posted by Leonardo Guizzetti View Post
          I'm guessing you ran this in Stata's command line and not from a do-file. Copy the whole block into a do file and then run the do file. It should work if you've copied it from the slide and not made any changes.
          Exactly I was being stupid for posting this tbh. Thank you for your suggestion!

          Comment

          Working...
          X