Benjamin Caldwell
2011-May-13 22:01 UTC
[R] using glmer to fit a mixed-effects model with gamma-distributed response variable
Sub: using glmer to fit a mixed-effects model with gamma-distributed response variable Hello, I'm currently trying to fit a mixed effects model , i.e.:> burnedmodel1.2<-glmer(gpost.f.crwn.length~lg.shigo.av+dbh+leaf.area+bark.thick.bh+ht.any+ht.alive+(1|site/transect/plot), family=gaussian, na.action=na.omit, data=rws30.BL) If I run this code, I get the error below: Error: length(f1) == length(f2) is not TRUE In addition: Warning messages: 1: In plot:(transect:site) : numerical expression has 175 elements: only the first used 2: In plot:(transect:site) : numerical expression has 175 elements: only the first used Someone on this forum made the following suggestion,> rws30.BL$site <- factor(rws30.BL$site) > rws30.BL$transect <- interaction(rws30.BL$site, rws30.BL$transect, drop TRUE) > rws30.BL$plot <- interaction(rws30.BL$site, rws30.BL$transect,rws30.BL$plot, drop = TRUE) Which once run allows the above code to run for a gaussian family. However, if I try to fit a gamma family model (my goal), i.e.> burnedmodel1.2<-glmer(gpost.f.crwn.length~lg.shigo.av+dbh+leaf.area+bark.thick.bh+ht.any+ht.alive+(1|site/transect/plot), family=Gamma, na.action=na.omit, data=rws30.BL) I get: Error: no valid set of coefficients has been found: please supply starting values In addition: Warning message: In log(ifelse(y == 0, 1, y/mu)) : NaNs produced How do I determine what reasonable starting values are? And what's up with the NaNs? Thanks for taking a look. *Ben Caldwell* PhD Candidate University of California, Berkeley [[alternative HTML version deleted]]
Ben Bolker
2011-May-14 02:06 UTC
[R] using glmer to fit a mixed-effects model with gamma-distributed response variable
Benjamin Caldwell <btcaldwell <at> berkeley.edu> writes:> > Sub: using glmer to fit a mixed-effects model with gamma-distributed > response variable > > Hello, > I'm currently trying to fit a mixed effects model , i.e.: > > > burnedmodel1.2<-glmer(gpost.f.crwn.length~lg.shigo.av+dbh+leaf.area+ > bark.thick.bh+ht.any+ht.alive+(1|site/transect/plot), family=gaussian, > na.action=na.omit, data=rws30.BL)[stuff about turning site, transect, plot into factors snipped]> > burnedmodel1.2<-glmer(gpost.f.crwn.length~lg.shigo.av+dbh+leaf.area+ > bark.thick.bh+ht.any+ht.alive+(1|site/transect/plot), family=Gamma, > na.action=na.omit, data=rws30.BL) >Alas, Gamma GLMMs are not yet feasible in glmer -- this is in the works but I wouldn't hold my breath (try searching the r-sig-mixed-model archives for this topic). At this point your options are somewhat limited, to 'build your own model' tools such as WinBUGS or AD Model Builder (it is conceivable that Gamma GLMMs could be added in the development version of glmmADMB, but again I wouldn't hold my breath). If I may ask, is there a reason you need Gamma GLMMs and not log-normal GLMMs? At least qualitatively, the properties of Gamma and lognormal distributions are reasonably similar (2-parameter families, domain = non-negative reals, distribution ranges from 'L-shaped' to approximately normal ...) You can fit a log-normal GLMM by simply log-transforming your data (dealing with zeros appropriately) and fitted a regular, linear mixed model ... Further discussions on this topic would probably be better on the r-sig-mixed-models list. Ben Bolker
Apparently Analagous Threads
- using lme4 with three nested random effects
- using hglm to fit a gamma GLMM with nested random effects?
- hierarchical gamma model in lme4
- graphs of gamma, normal fit to a histogram are about half as large as they should be
- Multivariate regression tree: problems with surrogate splits