Skip to content

Anova and tukey-grouping

7 messages · Landi, arun

#
Hello,

I am really new to R and it's still a challenge to me.
Currently I'm working on my Master's Thesis. My supervisor works with SAS
and is not familiar with R at all.

I want to run an Anova, a tukey-test and as a result I want to have the
tukey-grouping ( something like A - AB - B)

I came across the HSD.test in the agricolae-package, but... unfortunately I
do not get an output (like here in the answer
http://stats.stackexchange.com/questions/31547/how-to-obtain-the-results-of-a-tukey-hsd-post-hoc-test-in-a-table-showing-groupe
)

I did it like this:

######   ANOVA
anova.typabunmit<-aov(ds.typabunmit$abun ~ ds.typabunmit$typ)
summary(anova.typabunmit)
summary.lm(anova.typabunmit)

###### post HOC
tukey.typabunmit<-TukeyHSD(anova.typabunmit)
tukey.typabunmit

###### HSD
HSD.test(anova.typabunmit, "abun", group=TRUE)



and the ONLY output is this:
Name:  abun 
 ds.typabunmit$typ 


I would be very pleased about some ides..:!





--
View this message in context: http://r.789695.n4.nabble.com/Anova-and-tukey-grouping-tp4644485.html
Sent from the R help mailing list archive at Nabble.com.
#
HI,

I guess there is a mistake in your code.? You should have used "typ" instead of "abun" as "abun" is the dependent variable.
summary(fm1 <- aov(breaks ~ wool + tension, data = warpbreaks))
myresults??? <-? TukeyHSD(fm1, "tension", ordered = TRUE)
library(agricolae)

HSD.test(fm1,"wool",group=TRUE)
#Study:
#HSD Test for breaks 
#Mean Square Error:? 134.9578 
#wool,? means
#??? breaks? std.err replication
#A 31.03704 3.050609????????? 27
#B 25.25926 1.789963????????? 27
#alpha: 0.05 ; Df Error: 50 
#Critical Value of Studentized Range: 2.840532 
#Honestly Significant Difference: 6.350628 
#Means with the same letter are not significantly different.
#Groups, Treatments and means
#a ??? ?A ??? ?31.037037037037 
#a ??? ?B ??? ?25.2592592592593 

?

A.K.



----- Original Message -----
From: Landi <ent-artet at gmx.de>
To: r-help at r-project.org
Cc: 
Sent: Friday, September 28, 2012 5:41 AM
Subject: [R] Anova and tukey-grouping

Hello,

I am really new to R and it's still a challenge to me.
Currently I'm working on my Master's Thesis. My supervisor works with SAS
and is not familiar with R at all.

I want to run an Anova, a tukey-test and as a result I want to have the
tukey-grouping ( something like A - AB - B)

I came across the HSD.test in the agricolae-package, but... unfortunately I
do not get an output (like here in the answer
http://stats.stackexchange.com/questions/31547/how-to-obtain-the-results-of-a-tukey-hsd-post-hoc-test-in-a-table-showing-groupe
)

I did it like this:

######?  ANOVA
anova.typabunmit<-aov(ds.typabunmit$abun ~ ds.typabunmit$typ)
summary(anova.typabunmit)
summary.lm(anova.typabunmit)

###### post HOC
tukey.typabunmit<-TukeyHSD(anova.typabunmit)
tukey.typabunmit

###### HSD
HSD.test(anova.typabunmit, "abun", group=TRUE)



and the ONLY output is this:
Name:? abun 
ds.typabunmit$typ 


I would be very pleased about some ides..:!





--
View this message in context: http://r.789695.n4.nabble.com/Anova-and-tukey-grouping-tp4644485.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
#
Hello !

Thanks for your advice. I tried it, but the output is the same:
Name:  typ 
 ds.typabunmit$typ 

I don't get the values...!?!?



--
View this message in context: http://r.789695.n4.nabble.com/Anova-and-tukey-grouping-tp4644485p4644513.html
Sent from the R help mailing list archive at Nabble.com.
#
Hi,

As I mentioned earlier, these are just guess work until you provide a subset of your data with dput().? Also, please check the structure of the data with str().

A.K.? 






----- Original Message -----
From: Landi <ent-artet at gmx.de>
To: r-help at r-project.org
Cc: 
Sent: Friday, September 28, 2012 10:35 AM
Subject: Re: [R] Anova and tukey-grouping

Hello !

Thanks for your advice. I tried it, but the output is the same:
Name:? typ 
ds.typabunmit$typ 

I don't get the values...!?!?



--
View this message in context: http://r.789695.n4.nabble.com/Anova-and-tukey-grouping-tp4644485p4644513.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
1 day later
#
typohne.csv <http://r.789695.n4.nabble.com/file/n4644635/typohne.csv>  

Hello arun kirshna,

I checked str() but I do not see any mistake.
Find attached a subset of my data (did you mean this with "dput()" ?)
Typ= treatment
abun= abundance
div= diversity, number of species

best wishes.



--
View this message in context: http://r.789695.n4.nabble.com/Anova-and-tukey-grouping-tp4644485p4644635.html
Sent from the R help mailing list archive at Nabble.com.
#
Hi,

I got your data from Nabble.? I meant to do it by dput() because the .csv files may not get through the R-help mailing list.

This is what I got:
dat1<-read.delim("typohne.csv")
?str(dat1)
#'data.frame':??? 60 obs. of? 3 variables:
# $ typ : Factor w/ 5 levels "A","B","C","D",..: 1 2 3 4 5 1 2 3 4 5 ...
# $ abun: int? 7 3 14 8 15 5 21 19 9 21 ...
# $ div : int? 7 3 11 6 14 5 12 15 8 12 ...

summary(fm1<-aov(abun~typ,data=dat1))
#??????????? Df Sum Sq Mean Sq F value Pr(>F)? 
#typ????????? 4??? 847? 211.69?? 3.654 0.0104 *
#Residuals?? 55?? 3186?? 57.93???????????????? 
#---
#Signif. codes:? 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 
?myresults<-TukeyHSD(fm1,"typ",ordered=TRUE)
?myresults
#? Tukey multiple comparisons of means
#??? 95% family-wise confidence level
#??? factor levels have been ordered

#Fit: aov(formula = abun ~ typ, data = dat1)
#
#$typ
#???????? diff??????? lwr????? upr???? p adj
#B-A? 6.500000 -2.2633699 15.26337 0.2382355
#D-A? 6.750000 -2.0133699 15.51337 0.2055350
#E-A? 9.083333? 0.3199635 17.84670 0.0386441
#C-A 11.166667? 2.4032968 19.93004 0.0060292
#D-B? 0.250000 -8.5133699? 9.01337 0.9999902
#E-B? 2.583333 -6.1800365 11.34670 0.9197106
#C-B? 4.666667 -4.0967032 13.43004 0.5657010
#E-D? 2.333333 -6.4300365 11.09670 0.9432637
#C-D? 4.416667 -4.3467032 13.18004 0.6167517
#C-E? 2.083333 -6.6800365 10.84670 0.9619249
library(agricolae)
?HSD.test(fm1,"typ",group=TRUE)
#Study:
#HSD Test for abun 
#Mean Square Error:? 57.92879 
#typ,? means
#????? abun?? std.err replication
#A? 6.25000 0.6976693????????? 12
#B 12.75000 2.4061947????????? 12
#C 17.41667 2.9062585????????? 12
#D 13.00000 2.6198543????????? 12
#E 15.33333 1.5970301????????? 12
#alpha: 0.05 ; Df Error: 55 
#Critical Value of Studentized Range: 3.988545 
#Honestly Significant Difference: 8.76337 
#Means with the same letter are not significantly different.
#Groups, Treatments and means
#a ??? ?C ??? ?17.4166666666667 
#a ??? ?E ??? ?15.3333333333333 
#ab ??? ?D ??? ?13 
#ab ??? ?B ??? ?12.75 
# b ??? ?A ??? ?6.25 


I am not sure why you didn't get the results as above.? Check str() to see whether the str() I got matches with yours.

Have a great day!
A.K.

??? 











----- Original Message -----
From: Landi <ent-artet at gmx.de>
To: r-help at r-project.org
Cc: 
Sent: Friday, September 28, 2012 10:35 AM
Subject: Re: [R] Anova and tukey-grouping

Hello !

Thanks for your advice. I tried it, but the output is the same:
Name:? typ 
ds.typabunmit$typ 

I don't get the values...!?!?



--
View this message in context: http://r.789695.n4.nabble.com/Anova-and-tukey-grouping-tp4644485p4644513.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
#
Hello again !

It worked exactly the same way as yours!
I'm kind of astonished, because in "my" opinion our skripts are the same
(obviously not...).
Whatever! It works :-D

Tomorrow (as where I live it's already evening...sunday) will be a great
day, indeed, and I can go on with analysis !
I really appreciate the conversation with you and your support!



--
View this message in context: http://r.789695.n4.nabble.com/Anova-and-tukey-grouping-tp4644485p4644642.html
Sent from the R help mailing list archive at Nabble.com.