Something I’ve learned for BUGS/JAGS

Just quickly, I’m using JAGS with rjags to run some models for this fungal concentration paper I’m writing with our Finnish visitor (who leaves in a few months!). There are three levels of hierarchy in the experiment

  1. school (i = 1 to 25)
  2. measurement site within school (j = 1 to 3)
  3. sample number at measurement site (k = 1 to Kj)

which mean that I was constructing my data frame as a three dimensional array, y[i,j,k] where there were uneven numbers of samples at each site within each school. Furthermore, modelling y[i,j,k] ~ dnorm(mu[i,j,k],tau.y) was giving me problems because I couldn’t tell JAGS to monitor a three dimensional parameter.

I figured out that it’d just be easier to treat the levels of measurement site and sample number as covariates that I could use as index counters in JAGS. I’ve got much simpler code now and JAGS is monitoring mu[i] (i = 1 to 261).

Edit: It’s been a busy month. I hope to finally publish that blog post about SEB113 soon.


One thought on “Something I’ve learned for BUGS/JAGS

  1. Matt

    The BUGS manual suggests 3 different ways of handling unbalanced or “ragged” datasets – I think I’ve tried all 3 at one time or another.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s