Quantcast

using lme4 with three nested random effects

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

using lme4 with three nested random effects

btc1
Hi all,
I'm trying to fit models for data with three levels of nested random
effects: site/transect/plot. For example,

modelincrBS<-glmer(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bark.thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num+(1|site/transect/plot),
data=rws30.UL, family=gaussian, na.action=na.omit)

but I get the following error:

Error: length(f1) == length(f2) is not TRUE
In addition: Warning messages:
1: In plot:(transect:site) :
  numerical expression has 92 elements: only the first used
2: In plot:(transect:site) :
  numerical expression has 92 elements: only the first used

The formulation works for two nested effects (e.g. 1|site/transect)

I can get it to run in lme
modelincrBS<-lme(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bark.thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num,
data=rws30.UL, random=(~1| site/transect/plot),na.action=na.omit)

but I can't specify a distribution family in that package.

Any help much appreciated.

Ben Caldwell

*
*

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using lme4 with three nested random effects

ONKELINX, Thierry
Dear Ben,

Are site, transect and plot factors? And do they have unique id's?

You could try this

rws30.UL$site <- factor(rws30.UL$site)
rws30.UL$transect <- interaction(rws30.UL$site, rws30.UL$transect, drop = TRUE)
rws30.UL$plot <- interaction(rws30.UL$site, rws30.UL$transect, rws30.UL$plot, drop = TRUE)
modelincrBS<-glmer(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bak.thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num +(1|site/transect/plot),
 data=rws30.UL, family=gaussian, na.action=na.omit)

Or

modelincrBS<-glmer(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bak.thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num +(1|site) + (1|transect) + (1|plot),
 data=rws30.UL, family=gaussian, na.action=na.omit)

Best regards,

Thierry

----------------------------------------------------------------------------
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
[hidden email]
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
 

> -----Oorspronkelijk bericht-----
> Van: [hidden email]
> [mailto:[hidden email]] Namens Benjamin Caldwell
> Verzonden: vrijdag 29 april 2011 0:37
> Aan: r-help
> Onderwerp: [R] using lme4 with three nested random effects
>
> Hi all,
> I'm trying to fit models for data with three levels of nested random
> effects: site/transect/plot. For example,
>
> modelincrBS<-glmer(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bar
> k.thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num
> +(1|site/transect/plot),
> data=rws30.UL, family=gaussian, na.action=na.omit)
>
> but I get the following error:
>
> Error: length(f1) == length(f2) is not TRUE In addition:
> Warning messages:
> 1: In plot:(transect:site) :
>   numerical expression has 92 elements: only the first used
> 2: In plot:(transect:site) :
>   numerical expression has 92 elements: only the first used
>
> The formulation works for two nested effects (e.g. 1|site/transect)
>
> I can get it to run in lme
> modelincrBS<-lme(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bark.
> thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num,
> data=rws30.UL, random=(~1| site/transect/plot),na.action=na.omit)
>
> but I can't specify a distribution family in that package.
>
> Any help much appreciated.
>
> Ben Caldwell
>
> *
> *
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using lme4 with three nested random effects

btc1
Thierry,
The first suggestion worked. Thank you very much.
*Ben Caldwell*

University of California, Berkeley
137 Mulford Hall #3114
Berkeley, CA 94720
Office 223 Mulford Hall
(510)859-3358



On Fri, Apr 29, 2011 at 1:52 AM, ONKELINX, Thierry <[hidden email]
> wrote:

> Dear Ben,
>
> Are site, transect and plot factors? And do they have unique id's?
>
> You could try this
>
> rws30.UL$site <- factor(rws30.UL$site)
> rws30.UL$transect <- interaction(rws30.UL$site, rws30.UL$transect, drop =
> TRUE)
> rws30.UL$plot <- interaction(rws30.UL$site, rws30.UL$transect,
> rws30.UL$plot, drop = TRUE)
> modelincrBS<-glmer(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bak.thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num
> +(1|site/transect/plot),
>  data=rws30.UL, family=gaussian, na.action=na.omit)
>
> Or
>
> modelincrBS<-glmer(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bak.thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num
> +(1|site) + (1|transect) + (1|plot),
>  data=rws30.UL, family=gaussian, na.action=na.omit)
>
> Best regards,
>
> Thierry
>
>
> ----------------------------------------------------------------------------
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek
> team Biometrie & Kwaliteitszorg
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
>
> Research Institute for Nature and Forest
> team Biometrics & Quality Assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
>
> tel. + 32 54/436 185
> [hidden email]
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
>
> > -----Oorspronkelijk bericht-----
> > Van: [hidden email]
> > [mailto:[hidden email]] Namens Benjamin Caldwell
> > Verzonden: vrijdag 29 april 2011 0:37
> > Aan: r-help
> > Onderwerp: [R] using lme4 with three nested random effects
> >
> > Hi all,
> > I'm trying to fit models for data with three levels of nested random
> > effects: site/transect/plot. For example,
> >
> > modelincrBS<-glmer(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bar
> > k.thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num
> > +(1|site/transect/plot),
> > data=rws30.UL, family=gaussian, na.action=na.omit)
> >
> > but I get the following error:
> >
> > Error: length(f1) == length(f2) is not TRUE In addition:
> > Warning messages:
> > 1: In plot:(transect:site) :
> >   numerical expression has 92 elements: only the first used
> > 2: In plot:(transect:site) :
> >   numerical expression has 92 elements: only the first used
> >
> > The formulation works for two nested effects (e.g. 1|site/transect)
> >
> > I can get it to run in lme
> > modelincrBS<-lme(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bark.
> > thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num,
> > data=rws30.UL, random=(~1| site/transect/plot),na.action=na.omit)
> >
> > but I can't specify a distribution family in that package.
> >
> > Any help much appreciated.
> >
> > Ben Caldwell
> >
> > *
> > *
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Loading...