Dear r-help members. I would like to compare species numbers of moths between eight different forests (each sampled for six nights). I would like to do a nested anova to compare species numbers between forests and nights. For more site specific details I wanted to do a Tukey test (TukeyHSD). Unfortunately this test is not working (message: "nicht anwendbare Methode f?r 'TukeyHSD' auf Objekt der Klasse "c('anova', 'data.frame" ) /(message: "method not appropriate for TukeyHSD for objects of the class "anova", "data.frame"). I tried it also with the "aov" instead of the "anova" function but neither the "aov" nor the "anova" approach is working. Could anyone help me with this problem? Attached you can find the txt.file and the r-script. I'm working with a MAC OSX snow leopard, with R-Studio 0.96 316. Thank you very much. Michael
Hi, Check this link. http://stackoverflow.com/questions/5904513/tukeyhsd-after-within-factors-anova A.K. ----- Original Message ----- From: Michael Eisenring <eimichae at ethz.ch> To: r-help at r-project.org Cc: Sent: Friday, July 20, 2012 6:15 AM Subject: [R] TukeyHSD not working Dear r-help members. I would like to compare species numbers of moths between eight different forests (each sampled for six nights). I would like to do a nested anova to compare species numbers between forests and nights. For more site specific details I wanted to do a Tukey test (TukeyHSD). Unfortunately this test is not working (message:? "nicht anwendbare Methode f?r 'TukeyHSD' auf Objekt der Klasse "c('anova', 'data.frame" ) /(message: "method not appropriate for TukeyHSD for objects of the class "anova", "data.frame"). I tried it also with the "aov" instead of the "anova" function but neither the "aov" nor the "anova" approach is working. Could anyone help me with this? problem? Attached you can find the txt.file and the r-script. I'm working with a MAC OSX snow leopard, with R-Studio 0.96 316. Thank you very much. Michael ______________________________________________ R-help at 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.
HI, I don't have much experience with laercio package.? If it works for you, it is good. A.K. ----- Original Message ----- From: Michael Eisenring <eimichae at ethz.ch> To: arun <smartpink111 at yahoo.com> Cc: Sent: Friday, July 20, 2012 8:38 AM Subject: Re: [R] TukeyHSD not working Hi Thanks for the quick response. I installed the laercio package. Now I have a slightly different output of the Tukey Test but better than nothing. Thank? you! Michi Am 20.07.2012 um 13:58 schrieb arun:> Hi, > > Check this link. > http://stackoverflow.com/questions/5904513/tukeyhsd-after-within-factors-anova > A.K. > > > > ----- Original Message ----- > From: Michael Eisenring <eimichae at ethz.ch> > To: r-help at r-project.org > Cc: > Sent: Friday, July 20, 2012 6:15 AM > Subject: [R] TukeyHSD not working > > Dear r-help members. > I would like to compare species numbers of moths between eight different forests (each sampled for six nights). I would like to do a nested anova to compare species numbers between forests and nights. > For more site specific details I wanted to do a Tukey test (TukeyHSD). Unfortunately this test is not working (message:? "nicht anwendbare Methode f?r 'TukeyHSD' auf Objekt der Klasse "c('anova', 'data.frame" ) /(message: "method not appropriate for TukeyHSD for objects of the class "anova", "data.frame"). > I tried it also with the "aov" instead of the "anova" function but neither the "aov" nor the "anova" approach is working. > Could anyone help me with this? problem? > Attached you can find the txt.file and the r-script. > I'm working with a MAC OSX snow leopard, with R-Studio 0.96 316. > > Thank you very much. > Michael > ______________________________________________ > R-help at 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. >
Michael, Use dput() to output your data (or perhaps a small subset). Then paste the result of that call and your R code (just those lines of code that are needed to reproduce the problem) right in your message to R-help. That makes it easier for the R-help list readers to help you troubleshoot. Jean Michael Eisenring <eimichae@ethz.ch> wrote on 07/20/2012 05:15:32 AM:> Dear r-help members. > I would like to compare species numbers of moths between eight > different forests (each sampled for six nights). I would like to do > a nested anova to compare species numbers between forests and nights. > For more site specific details I wanted to do a Tukey test > (TukeyHSD). Unfortunately this test is not working (message: "nicht > anwendbare Methode für 'TukeyHSD' auf Objekt der Klasse "c('anova', > 'data.frame" ) /(message: "method not appropriate for TukeyHSD for > objects of the class "anova", "data.frame"). > I tried it also with the "aov" instead of the "anova" function but > neither the "aov" nor the "anova" approach is working. > Could anyone help me with this problem? > Attached you can find the txt.file and the r-script. > I'm working with a MAC OSX snow leopard, with R-Studio 0.96 316. > > Thank you very much. > Michael[[alternative HTML version deleted]]
Michael Eisenring <eimichae@ethz.ch> wrote on 07/20/2012 09:35:03 AM:> Dear Jean, > thanks for this email. I'm grateful for this instruction Just to > make sure that I understood you properly: something like this?:Michael, Yes, this is perfect. Very helpful.> My data: > > dput(geo_anova_nested_input): > > structure(list(Site = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, > 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, > 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, > 8L, 8L, 8L, 8L, 8L, 8L), Night = 1:48, Species = c(21L, 22L, > 13L, 12L, 26L, 12L, 28L, 22L, 25L, 27L, 27L, 10L, 21L, 31L, 33L, > 36L, 32L, 17L, 31L, 26L, 27L, 38L, 32L, 14L, 27L, 36L, 37L, 40L, > 38L, 5L, 20L, 31L, 29L, 36L, 30L, 30L, 18L, 19L, 16L, 43L, 31L, > 27L, 24L, 27L, 28L, 49L, 34L, 30L)), .Names = c("Site", "Night", > "Species"), class = "data.frame", row.names = c(NA, -48L)) > > RCode > > attach(geo_anova_nested_input) > geo_anova_nested_input > data<-anova(lm(Species~Site/Night)) > TukeyHSD(data,"Site", conf.level=0.90)There are a number of issues with the line of code data<-anova... First of all, look at the output from lm(Species~Site/Night) You are fitting a linear regression model with Site and Site x Night interaction as the two independent continuous variables. You have no categorical variables. I assume that you want Site to be a categorical variable (it represents forests, right?). I'm not sure how you want to deal with Night. You may want to talk over your design with a statistician to be sure the model you are using is appropriate for the way your data were collected. Second, look at the output from anova(lm(Species~Site/Night)) This is simply an ANOVA table for the regression model you just fit. But TukeyHSD(), in your next line of code, wants a "... fitted model object, usually an aov fit." This is clearly stated in the help page for TukeyHSD(). ?TukeyHSD So, here's an example of some code that "works" (gives output without warning/error messages) using your data. I have ignored Night, since I'm not sure how it should be dealt with (again, talk to a statistician). But, hopefully this will help you to understand how to make things work in R. # create a new variable for Site, as a categorical variable (aka factor) geo_anova_nested_input$Sitef <- as.factor(geo_anova_nested_input$Site) # fit an ANOVA model to the data fit <- aov(Species ~ Sitef, data=geo_anova_nested_input) # compute Tukey honest significant differences for the Site factor TukeyHSD(fit, "Sitef", conf.level=0.90) Jean> Michael, > > Use dput() to output your data (or perhaps a small subset). Then > paste the result of that call and your R code (just those lines of > code that are needed to reproduce the problem) right in your message > to R-help. That makes it easier for the R-help list readers to help > you troubleshoot. > > Jean > > > Michael Eisenring <eimichae@ethz.ch> wrote on 07/20/2012 05:15:32 AM: > > > Dear r-help members. > > I would like to compare species numbers of moths between eight > > different forests (each sampled for six nights). I would like to do > > a nested anova to compare species numbers between forests and nights. > > For more site specific details I wanted to do a Tukey test > > (TukeyHSD). Unfortunately this test is not working (message: "nicht > > anwendbare Methode für 'TukeyHSD' auf Objekt der Klasse "c('anova', > > 'data.frame" ) /(message: "method not appropriate for TukeyHSD for > > objects of the class "anova", "data.frame"). > > I tried it also with the "aov" instead of the "anova" function but > > neither the "aov" nor the "anova" approach is working. > > Could anyone help me with this problem? > > Attached you can find the txt.file and the r-script. > > I'm working with a MAC OSX snow leopard, with R-Studio 0.96 316. > > > > Thank you very much. > > Michael[[alternative HTML version deleted]]