DATA # install.packages(\"Sleuth3\") library(Sleuth3) data(\"case0501\") mouse.d
ID: 3221008 • Letter: D
Question
DATA
# install.packages("Sleuth3")
library(Sleuth3)
data("case0501")
mouse.data <- case0501
names(mouse.data)
## [1] "Lifetime" "Diet"
attach(mouse.data)
## The following objects are masked from mouse.data (pos = 3):
##
## Diet, Lifetime
boxplot(Lifetime ~ Diet, main="Lifespans")
ANALYSIS
Perform One-Way ANOVA
Do the treatment groups show differing lifetimes?
my.model <- aov(Lifetime ~ Diet)
summary(my.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## Diet 5 12734 2546.8 57.1 <2e-16 ***
## Residuals 343 15297 44.6
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Check ANOVA Assumptions (Normality and Heterogeneity)
Are the residuals normal? Do the treatment groups have approximately equal variances?
Confirm Model with Non-Parametric Test
Use the kruskal.test() to find out.*
kruskal.test(Lifetime ~ Diet)
##
## Kruskal-Wallis rank sum test
##
## data: Lifetime by Diet
## Kruskal-Wallis chi-squared = 159.01, df = 5, p-value < 2.2e-16
Find Significantly Differing Diets
Which treament groups have differing means? Use the TukeyHSD() to find out.
TukeyHSD(my.model)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Lifetime ~ Diet)
##
## $Diet
## diff lwr upr p adj
## N/R40-N/N85 12.4254386 8.885436 15.9654413 0.0000000
## N/R50-N/N85 9.6059550 6.202170 13.0097399 0.0000000
## NP-N/N85 -5.2891873 -9.017748 -1.5606269 0.0008380
## R/R50-N/N85 10.1944862 6.593417 13.7955556 0.0000000
## lopro-N/N85 6.9944862 3.393417 10.5955556 0.0000008
## N/R50-N/R40 -2.8194836 -6.175736 0.5367684 0.1564608
## NP-N/R40 -17.7146259 -21.399845 -14.0294069 0.0000000
## R/R50-N/R40 -2.2309524 -5.787127 1.3252222 0.4684413
## lopro-N/R40 -5.4309524 -8.987127 -1.8747778 0.0002306
## NP-N/R50 -14.8951423 -18.449713 -11.3405719 0.0000000
## R/R50-N/R50 0.5885312 -2.832070 4.0091319 0.9963976
## lopro-N/R50 -2.6114688 -6.032070 0.8091319 0.2460200
## R/R50-NP 15.4836735 11.739756 19.2275913 0.0000000
## lopro-NP 12.2836735 8.539756 16.0275913 0.0000000
## lopro-R/R50 -3.2000000 -6.816968 0.4169683 0.1167873
detach(mouse.data)
FINDINGS
Do the diets contribute to differning lifespans? Which (if any) result it the highest mean lifespan? Which diets DO NOT DIffer
Can someone please help me with this? I can't seem to understand how to answer the questions.
Explanation / Answer
Our question is whether diet has effect on lifespan. According to the given data lifespan is the continuous data and diet is categorical data where diet has 6 categories. Usually we want to check for every diet lifespan means are same or not. So we set our hypothesis as, H0: all diet has same mean
Vs
H1: not H0
This can be reflected in ANOVA table
Df Sum Sq Mean Sq F value Pr(>F)
## Diet 5 12734 2546.8 57.1 <2e-16 ***
## Residuals 343 15297 44.6
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Here we can note that the p-value corresponding to diet is very close to zero ( 2e-16)
Since p-value is < significance level =0.05 we reject our null hypothesis. And can comment that the diet has significant effect on lifespan.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.