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 get DIC in Jags?

    How do I obtain the DIC for model comparison purposes?

    The following provides an example:

    library(rjags)
    mod1 <- jags.model("model.jags", data=Data, n.chains=4, n.adapt=500)
    update(mod1, 500) # burn in
    dic.pD <- dic.samples(mod1, 1000, "pD") # Deviance Information Criterion
    dic.popt <- dic.samples(mod1, 1000, "popt") # Penalized expected deviance
    
    • dic.samples returns an estimate of the DIC for a given model

    And here’s an example of comparing DIC between two models where mod1 and mod2 are the jags model objects returned from jags.model() and then a burn-in update(...) as above.

    dic.mod1 <- dic.samples(mod1, 1000, "pD")
    dic.mod2 <- dic.samples(mod2, 1000, "pD")
    dic.mod1; 
    dic.mod2; 
    diffdic(dic.mod1, dic.mod2)
    

    Additional Links

    • Discussion in BUGS manual
    • December 7, 2012 (10:24 am)
    • #@jags
  • comments powered by Disqus