Skip to content
Prev 12531 / 20628 Next

lme4 heteroscedasticity???

I did this a few years ago for ~250 patients (nested within ~10 hospitals) being assessed by 7 adjudicators, so roughly a 250 x 6 table of crossed random effects. The aim was to look for differences in precision between clinicians rating patients on a symptoms scale. It did take a several minutes to fit on a server with 24 GB of RAM, and required a little fiddling with the control options, but was nevertheless worth the time and trouble. Looking back at my code (below), I find that your advice helped me to fit it, via a post of yours from 2004, for which thanks!

The model syntax is a little fiddly and easy to get wrong, so I?d advise anyone doing this for the first time to check that the results of the homoscedastic model match those from lme4, where the random effects syntax is straightforward, before fitting the heteroscedastic model.

       # fit models
  
        # extend number of iterations allowed
        
          control<-lmeControl(maxIter=500,msMaxIter=500,niterEM=250,msMaxEval=2000)
        
        # I want to fit three random effects, id crossed with adj and id nested within site
        # how to model this is  described by douglas bates here: http://tolstoy.newcastle.edu.au/R/help/04/02/0830.html
        # beware - lme takes several minutes to fit these models - lmer is much faster but doesn't allow heteroscedasticity to be modelled
    
          mod.sep.adj.rancrossed<-
            lme(mrs~1,random=list(Block=pdBlocked(list(pdIdent(~adj-1),pdIdent(~site-1),pdIdent(~id-1)))),
              data=cars.rep,control=control)
    
        # fit heteroscedastic model
    
          mod.sep.adj.rancrossed.w<-update(mod.sep.adj.rancrossed,weights=varIdent(form=~1|adj))

        # get p-value for heteroscedastic model vs homoscedastic model 
    
          (precision.p.val<-anova(mod.sep.adj.rancrossed.w,mod.sep.adj.rancrossed)[2,"p-value"])
On 13 Oct 2014, at 16:35, Douglas Bates <bates at stat.wisc.edu> wrote: