Jeromy Anglim's Notes

Assorted notes on statistics, R, psychological research, LaTeX, computing, etc. See also my primary blog for more substantive posts: jeromyanglim.blogspot.com
  • rss
  • archive

Tags:
  • R
  • LaTeX
  • Linux / Ubuntu
  • OSX
  • Jags
  • Tumblr

Previous Notes:
Main Blog:
  • How to assign a vector to a variable in Jags?

    • How do I assign a vector to a variable in JAGS?

    For example,

    pi[] <- [Beta1, Beta2, Beta3]
    pi <- [Beta1, Beta2, Beta3]
    

    are both invalid in JAGS, yielding the error:

    Error parsing model file:
    syntax error on line ... near "["
    

    One option is just to assign the values one row at a time:

    pi[1] <- Beta1
    pi[2] <- Beta2
    pi[3] <- Beta3
    

    Another option in the above case is to make Beta1, Beta2, and Beta3 a vector to begin with: e.g., Beta[1], Beta[2], and Beta[3]. Then it is possible to to assign the whole vector at once.

    pi <- Beta
    

    This even removes the need for pi in my particular case.

    • December 7, 2012 (10:26 am)
    • #@jags
  • comments powered by Disqus