[R] How to write random effect in MCMCglmm

Ben Bolker bbolker at gmail.com
Thu Jun 2 01:29:36 CEST 2011


Belle <ping.yi <at> gmail.com> writes:

> 
> Hi All,
> 
> The data set that I have is a cluster data, and I want to run a HLM mixed
> model with multi-level response. Here is my data set:
> response:

 [snip]

> library(MCMCglmm)
> y <- MCMCglmm(factor(Level) ~ Type+factor(yr>=2006)+Male+Ethnicity+ELL+
> avgTransfers+sdTransfers+agec+Disability+ELL*pctELL+Disability*pctDisability+
>           pctMale+factor(yr>=2008)*factor(Grade),
> random=~Schoolid+Teacherid+Studentid, 
>           family="categorical", data=data[data$Grade>=4,])
> 
> Error in MCMCglmm(FCATprofLevel ~ transferTypeCat + factor(yr >= 2008) +  : 
> please use idh(trait):units, us(trait):units or trait:units for error
> structures involving catgeorical data with more than 2 categories
> 
> Does anyone know how I can fix it?
> 

  I would suggest (1) reading chapter 5 of the course notes vignette
carefully, if you haven't already [library("MCMCglmm"); 
vignette("CourseNotes")].  Especially see section 5.2 (which
begins "Multinomial models are difficult - both to fit and interpret. 
This is particularly true when each unit of observation only has a
single realisation from the multinomial.")
(2) posting this to the r-sig-mixed-models mailing list
(say that you tried here first so no-one accuses you of cross-posting).



More information about the R-help mailing list