heteroscedastic model in lme4
Anna, lme4 cannot handle certain kinds of heteroscedasticity, but I believe it can handle the kind you have in mind. Search the r-sig-mixed-models archive for a discussion involving me and David Afshartous, especially the summary message titled "[R-sig-ME] random effect variance per treatment group in lmer" that David posted 07/13/2007 04:18:08 PM I can't be certain that the suggestion below would work without knowing more about your design, but if width were a factor with three levels then you might try setting up indicator variables Wind1, Wind2, and Wind3 (that each take on the value 1 when a site is at the indicator's target width and 0 otherwise) and then fit the model with something like mrem <- lmer( log(Nhat+1)~Group + GreenPerc + sess + crop + VegDensity + Group:sess + Group:VegDensity + (0+Wind1|site) + (0+Wind2|site) + (0+Wind3|site), data=all, method="REML" ) alan
r-sig-mixed-models at r-project.org on Friday, December 19, 2008 at 6:00 AM -0500 wrote:
Message: 1
Date: Thu, 18 Dec 2008 11:23:46 +0000
From: "Renwick, A. R." <a.renwick at abdn.ac.uk>
Subject: [R-sig-ME] heteroscedastic model in lme4
To: "'r-sig-mixed-models at r-project.org'"
<r-sig-mixed-models at r-project.org>
Message-ID:
<B9D1301370916C44B5874AF340C18B9B28AE890D50 at VMAILB.uoa.abdn.ac.uk>
Content-Type: text/plain; charset="us-ascii"
I have been using the nlme package to run some LMM's, however I would like to try rerunning them using the lme4 package so that I can use mcmc sampling. The data I am using shows some heteroscesdasticity of the within error group and so I have
been using the 'weights' argument and the varIdent variance function structure to allow different variances for each level of my factor (patch width).
My problem is how to code for a heteroscedastic model in lme4 and any suggestion wouuld be much apprecaited.
The code I used in the nlme package:
# model fit using "REML"
mrem<-lme(log(Nhat+1)~Group + GreenPerc + sess + crop + VegDensity + Group:sess + Group:VegDensity ,random=~1|Site, data=all,
method="REML",correlation=NULL,weights=varIdent(form=~1|width))
Many thanks,
Anna
Anna Renwick
Institute of Biological & Environment Sciences
University of Aberdeen
Zoology Building
Tillydrone Avenue
Aberdeen
AB24 2TZ
The University of Aberdeen is a charity registered in Scotland, No SC013683.
-- Alan B. Cobo-Lewis, Ph.D. (207) 581-3840 tel Department of Psychology (207) 581-6128 fax University of Maine Orono, ME 04469-5742 alanc at maine.edu http://www.umaine.edu/visualperception