Advanced Statistics - Biology 6030

Bowling Green State University, Fall 2017

Lab Exercise 5 for R: Comparing 2 Independent Samples

Exercise 1: Compare two samples

If two independent samples are obtained, then we can ask whether they may have been drawn from two different underlying distributions.


Download and read the content from file "TroutDiet.txt" for 2000 individual trout ready to go to market. One half was fed a special diet [Diet=1], the other half received the usual grub [Diet=0]. Your goal is to test whether the new diet has been effective in promoting growth. You might consider making sure that 'Diet' is treated as a factor, rather than a number.

> Trout <- read.table("http://caspar.bgsu.edu/~courses/stats/Labs/Datasets/TroutDiet.txt", header=TRUE)
> Trout$Diet <- as.factor(Trout$Diet)

> summary(Trout)
> library(psych)
> describeBy(Trout$stLength, group = Trout$Diet)

ANOVA is mathematically identical to a t-Test. Here we run the analysis as an ANOVA

> anovaFit <- aov(Trout$stLength ~ Trout$Diet)
> summary(anovaFit)

To run a posthoc analysis of the results

> TukeyHSD(anovaFit)

Test for significant Heteroscedasticity/Normality

> bartlett.test(Trout$stLength ~ Trout$Diet)

> library(car)
> leveneTest(Trout$stLength ~ Trout$Diet)

> fligner.test(Trout$stLength ~ Trout$Diet)

> var.test(Trout$stLength ~ Trout$Diet)

Get a plot of the results

> boxplot(Trout$stLength ~ Trout$Diet)
> plot(anovaFit)



last modified: 2/2/15
This material is copyrighted and MAY NOT be used for commercial purposes, 2001-2017 lobsterman.
[ Advanced Statistics Course page | About BIO 6030 | Announcements ]
[ Course syllabus | Exams & Grading | Glossary | Evaluations | Links ]