[R] Crossed random effects in lme

2010-10-18 Thread anord

Dear all, 

I am trying to fit a model with crossed random effects using lme. In this
experiment, I have been measuring oxygen consumption (mlmin) in bird
nestlings, originating from three different treatments (treat), in a
respirometer with 7 different channels (ch). I have also measured body mass
(mass) for these birds. 

id  nesttreat   yearmlmin   massch  
hack
1EP5171117  H   20081.401719138 10.74   2008:17
1EP5170917  H   20081.257163112 9.7 5   2008:17
1EP5171617  H   20081.050170714 10.26   2008:17
1EP5171217  H   20081.330495314 9.6 7   2008:17
1EP51791687 M   20081.07625708  9.7 3   
2008:687
1EP51772823 H   20081.336820232 10.24   2008:823
1EP51778613 L   20081.300814516 10.75   2008:613
1EP52336207 M   20081.071775936 10.73   2008:207
1EP52403808 H   20081.142389688 10.35   2008:808
1ER17603838 M   20090.984225217 9.6 3   2009:838
1ER17607838 M   20091.045058894 9.3 4   2009:838
1ER17600247 L   20091.047603048 9.2 5   2009:247
1ER17299247 L   20090.974569658 9.2 6   2009:247
1ER17292617 H   20091.271260094 10.57   2009:617
1ER172067009M   20091.074791644 10.72   
2009:7009
1ER17221730 H   20091.423266177 10.24   2009:730
1ER17275863 L   20091.433076022 10.74   2009:863
1ER17277863 L   20091.165236024 9.7 5   2009:863
1ER17283863 L   20091.139311895 10.46   2009:863
1ER17280863 L   20091.056161196 10.47   2009:863
CK59991 690 H   20100.994878996 9.5 2   2010:690
CK59806 161 M   20101.070052025 9.7 6   2010:161
CK59859 545 M   20101.456680579 9.9 4   2010:545
CK59862 545 M   20101.350698793 9.9 5   2010:545
CK59871 223 L   20100.830582186 8.3 6   2010:223
CK59868 223 L   20100.776241825 8   7   2010:223
CL77343 365 M   20101.352454484 10.34   2010:365
CL77338 365 M   20101.327691628 9.6 5   2010:365
CL77356 191 H   20101.212796979 11.31   2010:191
CL77361 191 H   20100.882307732 11.42   2010:191
CL77355 191 H   20101.137097586 10.93   2010:191

I want to include both nesting attempt (hack) and respirometer channel (ch)
as random factors in a model trying to explain variation in oxygen
consumption. From Pinheiro  Bates (2000), I've gathered that this model
could be fit making use of pdBlocked and pdIdent, so I've tried fitting the
below model:

m1.bmr-with(bmred.df,lme(mlmin~treat*year+massout,random=pdBlocked(list(pdIdent(~hack-1),pdIdent(~ch-1)))
))

However, my model fails with the following error message:
Error in getGroups.data.frame(dataMix, groups) : 
  Invalid formula for groups

I would much appreciate any input on this! 

Kind regards, 
Andreas Nord
Sweden





-- 
View this message in context: 
http://r.789695.n4.nabble.com/Crossed-random-effects-in-lme-tp3000101p3000101.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] Crossed random effects in lme

2010-10-18 Thread Kevin Wright
See this email:
http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg10849.html

http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg10849.htmlKevin


On Mon, Oct 18, 2010 at 7:06 AM, anord andreas.n...@zooekol.lu.se wrote:


 Dear all,

 I am trying to fit a model with crossed random effects using lme. In this
 experiment, I have been measuring oxygen consumption (mlmin) in bird
 nestlings, originating from three different treatments (treat), in a
 respirometer with 7 different channels (ch). I have also measured body mass
 (mass) for these birds.

 id  nesttreat   yearmlmin   massch
  hack
 1EP5171117  H   20081.401719138 10.74
 2008:17
 1EP5170917  H   20081.257163112 9.7 5
 2008:17
 1EP5171617  H   20081.050170714 10.26
 2008:17
 1EP5171217  H   20081.330495314 9.6 7
 2008:17
 1EP51791687 M   20081.07625708  9.7 3
 2008:687
 1EP51772823 H   20081.336820232 10.24
 2008:823
 1EP51778613 L   20081.300814516 10.75
 2008:613
 1EP52336207 M   20081.071775936 10.73
 2008:207
 1EP52403808 H   20081.142389688 10.35
 2008:808
 1ER17603838 M   20090.984225217 9.6 3
 2009:838
 1ER17607838 M   20091.045058894 9.3 4
 2009:838
 1ER17600247 L   20091.047603048 9.2 5
 2009:247
 1ER17299247 L   20090.974569658 9.2 6
 2009:247
 1ER17292617 H   20091.271260094 10.57
 2009:617
 1ER172067009M   20091.074791644 10.72
 2009:7009
 1ER17221730 H   20091.423266177 10.24
 2009:730
 1ER17275863 L   20091.433076022 10.74
 2009:863
 1ER17277863 L   20091.165236024 9.7 5
 2009:863
 1ER17283863 L   20091.139311895 10.46
 2009:863
 1ER17280863 L   20091.056161196 10.47
 2009:863
 CK59991 690 H   20100.994878996 9.5 2   2010:690
 CK59806 161 M   20101.070052025 9.7 6   2010:161
 CK59859 545 M   20101.456680579 9.9 4   2010:545
 CK59862 545 M   20101.350698793 9.9 5   2010:545
 CK59871 223 L   20100.830582186 8.3 6   2010:223
 CK59868 223 L   20100.776241825 8   7   2010:223
 CL77343 365 M   20101.352454484 10.34   2010:365
 CL77338 365 M   20101.327691628 9.6 5   2010:365
 CL77356 191 H   20101.212796979 11.31   2010:191
 CL77361 191 H   20100.882307732 11.42   2010:191
 CL77355 191 H   20101.137097586 10.93   2010:191

 I want to include both nesting attempt (hack) and respirometer channel (ch)
 as random factors in a model trying to explain variation in oxygen
 consumption. From Pinheiro  Bates (2000), I've gathered that this model
 could be fit making use of pdBlocked and pdIdent, so I've tried fitting the
 below model:


 m1.bmr-with(bmred.df,lme(mlmin~treat*year+massout,random=pdBlocked(list(pdIdent(~hack-1),pdIdent(~ch-1)))
 ))

 However, my model fails with the following error message:
 Error in getGroups.data.frame(dataMix, groups) :
  Invalid formula for groups

 I would much appreciate any input on this!

 Kind regards,
 Andreas Nord
 Sweden





 --
 View this message in context:
 http://r.789695.n4.nabble.com/Crossed-random-effects-in-lme-tp3000101p3000101.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org 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.




-- 
Kevin Wright

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.