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:
  • Jags error: Dimension mismatch taking subset of X when taking mean of matrix

    I received the following error

    Error in jags.model("model.txt", data = jagsdata, n.chains = 4, n.adapt = 1000)
    : 
      RUNTIME ERROR:
      Compilation error on line 21.
      Dimension mismatch taking subset of X
    

    Solution

    On line 21 of my model I was adapting some code that involved taking the mean of some data.

    The original code was set up to make the mean of a vector:

    x.bar    <- mean(X[]);
    

    However, my data was in the form of a matrix. Thus, the following modification solved the problem:

    x.bar    <- mean(X[,]);
    
    • December 7, 2012 (10:16 am)
    • #@jags
  • comments powered by Disqus