Mukta Chakraborty <chakraborty.mukta <at> gmail.com> writes: > > Hello, > I am trying to run a mixed effects nested ANOVA but none of my codes > are giving me any meaningful results and I am not sure what I am doing > wrong. I am a new user on R and would appreciate some help. > The experimental design is that I have some frogs that have been > exposed to three acoustic Treatments and I am measuring neural > activity (egr), in 12 brain regions. Some frogs also called different > calls than others so I am testing for effect of Call as a fixed > effect. > I have Treatment (Trt), Brain Region (Region), and Call (Call) as > fixed effects and I am modeling Subject (Subj) as a random effect with > brain region nested within subject. I am using lme4 package and I am > not sure if that is the correct one to use. > I also have some missing values as NA as part of the dataset. I have > also set Subj, Region, and Call as factors using as.factor. > I have run the model which I am sure is wrong: > model1<-anova(lme(egr ~ Trt* Region, random=~1|Subj/Region,na.action=na.omit)) > > The output I am getting is: > numDF denDF F-value p-value > Min. : 1.00 Min. : 32 Min. : 2.891 Min. :0.000e+00 > 1st Qu.: 1.75 1st Qu.:197 1st Qu.: 12.120 1st Qu.:0.000e+00 > Median : 6.50 Median :252 Median : 20.275 Median :1.146e-05 > Mean : 9.00 Mean :197 Mean : 87.353 Mean :1.383e-05 > 3rd Qu.:13.75 3rd Qu.:252 3rd Qu.: 95.508 3rd Qu.:2.530e-05 > Max. :22.00 Max. :252 Max. :305.972 Max. :3.240e-05 > > Any help on what I am doing wrong on the coding would be very helpful. > Thanks a lot. > Mukta
1. it would probably be a good idea to ask further questions on this topic on r-sig-mixed-models instead. 2. you probably want to look just at the lme() result, and not immediately wrap it an anova() frame. I'm a little surprised by your results -- but since you haven't given a reproducible example I don't know exactly what's wrong. When I run the lme example in the nlme package and then do > anova(fm1) I get numDF denDF F-value p-value (Intercept) 1 80 3096.4889 <.0001 age 1 80 85.8464 <.0001 which doesn't look like your answer. 3. I don't think you want to use Region as both a random factor and a fixed factor. I would have guessed either lme(egr ~ Trt*Call, random=~1|Subj/Region,na.action=na.omit)) OR lme(egr ~ Trt*Call*Region, random=~1|Subj,na.action=na.omit)) I can also imagine that you might be interested in a crossed design in this case, in which case you should probably use lme4: library(lme4) lmer(egr~Trt*Call+(1|Subj)+(1|Region) ...) [I'm not sure how na.action works for lmer] good luck Ben Bolker ______________________________________________ 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.