[R-sig-ME] MCMCglmm function

Arianna Cecchetti arianna.cecchetti at uac.pt
Mon Aug 1 15:26:36 CEST 2016

Dear Prof. Bolker,

I am trying to find the best model to fit a set of data which are temporally correlated and which involve a factor response variable including three levels. I would like to test a GLMM and possibly compare it with a multinomial GEE.
However, all the examples I found for GLMM using a factor as response variable are binomial and family options for the glmer function in R do not include multinomial. When I run it without specifying the family it automatically performs a LMM with a Gaussian distribution and besides not being sure it is a suitable option the output doesn’t show the levels of each explanatory factor variable.
I found that the multinomial family is an option for the MCMCglmm function which also deals with temporal correlation, however when it comes to select the random effect I have a doubt and I am not sure I am understanding how to set it correctly. I have been reading the function help file in R and the paper “GLMMs in action” however I have still doubts.

The data I am using are temporally correlated at sequence level (i.e. all data are correlated within each sequence cluster) and I set this variable as random effect. Do all fixed variable need to be included at once in the random specification?

It didn’t seem so in one example, so I was trying the following code. However, it failed giving the error “unexpected input in model <- …” guessing there is a syntax error but I have not been able to detect it. I include a subset of the data.

trial <- read.csv(“swd.csv”, sep=”,” , header=T)

model <- MCMCglmm(Dolphins.response~Species + Boat.placement + Behaviour + Calves + Group.size + N.Swimmers , random=~idh(N.Swimmers):N.Sequence, data=trial, family=“multinomial”,  verbose=FALSE)

Any suggestion to get me on the right track is very much appreciated!

Thank you very much!

Best wishes,


More information about the R-sig-mixed-models mailing list