I am trying to construct a zero inflation Poisson GLMM using MCMCglmm(). I am new to Bayesian Statistics and this function and I am struggling to understand a couple of things.

For my data I am looking at the species richness of high risk species counted around sensitive sites, I have calculated some variables to explain this distribution and I have a nested random effect structure; with the Date of the count nested within the Location of the site (in glmer terms; (Day.of.the.Year|Location) ).

I have struggled to find methods to construct nested random effects in MCMCglmm syntax (maybe I am looking in the wrong places!) but I found one method that said I needed to create a new column with both in;

HRnaomit$DaynestLoc <- paste0(HRnaomit$Day.of.the.Year,HRnaomit$Location)

Am I doing this correctly? As I said I am new to this, so if I am doing it correctly, I'd love to understand a bit more as to why I am doing it correctly.

The model below is just for looking at random effects, this is where my error code comes into play;

NESTHRRM1<-MCMCglmm(HRRich~1, random = ~DaynestLoc, data=HRnaomit, family="zipoisson", rcov=~idh(trait):units, prior=prior)

prior<-list(R=list(V=diag(2)/2,nu=0.05), G=list(G1=list(V=diag(2)/2,nu=0.05)))

Error in priorformat(if (NOpriorG) { : 
  V is the wrong dimension for some prior$G/prior$R elements

So the prior I have here is likely wrong beyond the V being in the wrong dimension as I do not fully understand how to define the V value; I understand G is for the random effects, is the V value the value of all the levels within random effects? I am right in saying the higher the value of nu the more informative the prior?

How do you decide how informative a prior should be?

If anyone has any walkthroughs on constructing priors they could point me towards I would also be grateful!


It would help if you posted a reproducible example to look at what your data looks like. I'm no expert either but will try to help.

For what I can see without looking at an example, you have two problems. One with your prior and another in your model set-up. In the prior, the dimension of V within each structure depends on the number of response variables you have. So if you have only one response variable, your R structure should be V=1 (or V=diag(1)). As for your random structure, your G structure should have V=1 for each random effect, which is only the nested effect (which counts as one). Your nested random effect is backwards I think, since the notation for nested effects in MCMCglmm works as (Larger hierarchy/Smaller hierarchy) so I would set it as:

DaynestLoc <- paste0(HRnaomit$Location,HRnaomit$Day.of.the.Year)

And your prior

prior <- list(R=list(V=diag(1),nu=0.002),

In the prior, you want to have a flat non-informative prior, unless your data is insufficient for the model to converge, in that case you may want to look at an informative prior.

The other problem you have is in the rcov determination in the model configuration. You have a single response variable, hence you can't calculate a covariance structure with other responses, because they don't exist!

Try this in the rcov:


Again, I'm no expert either but I think that should help.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.