Announcement

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

  • Run Bayesmh for unstructured covariance structure for the random effects

    Dear all

    I am following Bayesmh's document to run example 25 that deals with unstructured covariance structure for the random effects. The code on P.95 that uses pig example is below

    bayesmh weight i.id i.id#c.week, likelihood(normal({var_0})) noconstant prior({weight:i.id i.id#c.week}, mvnormal(2,{weight:_cons}, {weight:week}, {Sigma,m})) prior({weight:week _cons}, normal(0, 1e2)) prior({var_0}, igamma(0.001,0.001)) prior({Sigma,m}, iwishart(2,3,I(2))) block({var_0}, gibbs) block({Sigma,m}, gibbs) block({weight:_cons}) block({weight:week}) block({weight:i.id}, reffects) block({weight:i.id#c.week}, reffects) noshow({weight:i.id i.id#c.week}) mcmcsize(5000) dots

    However, Stata reports error message "prior mvnormal must have dimension 95 r(503);".

    Does any one know what wrong is with the code, or how to run Bayes for unstructured covariance structure for the random effects in a right way? Thanks.

    Best,
    Jack

  • #2
    Or if anyone run this code successfully? Thanks.

    The full code is below

    . webuse pig
    (Longitudinal analysis of pig weights)

    . set seed 14

    bayesmh weight i.id i.id#c.week, likelihood(normal({var_0})) noconstant
    > prior({weight:i.id i.id#c.week},
    > mvnormal(2, {weight:_cons}, {weight:week}, {Sigma,m}))
    > prior({weight:week _cons}, normal(0, 1e2))
    > prior({var_0}, igamma(0.001,0.001))
    > prior({Sigma,m}, iwishart(2,3,I(2)))
    > block({var_0}, gibbs) block({Sigma,m}, gibbs)
    > block({weight:_cons}) block({weight:week})
    > block({weight:i.id}, reffects)
    > block({weight:i.id#c.week}, reffects)
    > noshow({weight:i.id i.id#c.week})
    > mcmcsize(5000) dots

    prior mvnormal must have dimension 95
    r(503);

    Comment


    • #3
      Perhaps StataCorp inadvertently broke something in bayesmh or the mvnormal() prior since that section of the user's manual was first produced.

      This seems to be a bug.

      You should contact Stata Technical Support about this.

      Comment


      • #4
        Thanks, Joseph. I will contact Stata as you suggest.

        Happy Weekend!
        Jack

        Comment


        • #5
          Jack,

          to run the code it is essential to keep all levels of the group variable id. Before bayesmh you must run
          Code:
          fvset base none id
          Otherwise the mvnormal prior does not have the right dimensions.

          Nikolay

          Comment


          • #6
            Thanks, Nikolay. The code works! I noticed this commend in previous samples but ignored it in example 25.

            Also thank Joseph for the suggestion. It is a know-how that maybe only Statacorp can answer.

            Comment

            Working...
            X