## Do not delete this! ## It loads the s20x library for you. If you delete it ## your document may not compile it. require(s20x) knitr::opts_chunk$set( dev = "png", fig.ext = "png", dpi = 96 )
In this study, we look at how the male fruit-flies longevity is related to reproductive activity. (Data is described in more detail here)
How does one define "interest" in fruit-flies? Here is this study's definition:
Newly inseminated females will not usually mate again for at least two days.
So the males in the uninterested groups were always living with newly inseminated females!
The hypothesis was that the males living alone and with the uninterested females would live longer than the males living with the interested females. Since there are more than two group means, a one-way ANOVA is used to determine if there is a significant difference between the group means.
The design of the study placed male fruit-flies in the following groups:
1) Males living alone, 2) Males living with one interested female, 3) Males living with eight interested females, 4) Males living with one uninterested female, and 5) Males living with eight uninterested females.
The variables of interest were:
days: A male fruitfly's longevity in days.group: A five-level factor with the levels which corresponds to the group a male fruitfly is in:How does sexual activity affect male fruitfly longevity?
load(system.file("extdata", "Fruitfly.df.rda", package = "s20x"))
Fruitfly.df = read.csv("Fruitfly.csv", stringsAsFactors=TRUE) plot(days ~ group, data = Fruitfly.df) summaryStats(days ~ group, Fruitfly.df)
plot(days ~ group, data = Fruitfly.df) summaryStats(days ~ group, Fruitfly.df)
Our hypothesis that the males living alone and with the uninterested females would live longer than the males living with the interested females does not seem plausible with our data.
ff.fit = lm(days ~ group, data = Fruitfly.df) modelcheck(ff.fit) anova(ff.fit) summary(ff.fit)
library(emmeans) Fruitfly.emm = emmeans(ff.fit, ~group) # View all pairwise comparisons: pairs(Fruitfly.emm, infer=TRUE) # View only the comparisons that are significant at the 5% level: Fruitfly.pairs = data.frame(pairs(Fruitfly.emm, infer=T)) subset(Fruitfly.pairs, p.value<0.05)
conf1=as.data.frame(subset(Fruitfly.pairs, p.value<0.05)) resultStr1 = paste0(sprintf("%.0f", conf1$lower.CL), " to ", sprintf("%.0f", conf1$upper.CL))
\pagebreak{}
The boxplot of days by group indicated that males living with 8 uninterested females have shorter lives compared to their counterparts in other groups. So, we fitted a One-way ANOVA model to these data.
The model assumptions seem satisfied.
Our final model is $$\text{days}_i = \beta_0 + \beta_1 \times Group2_i + \beta_2 \times Group3_i + \beta_3 \times Group4_i + \beta_4 \times Group5_i + \epsilon_i,$$ where $GroupX_i$ is 1 if the $i$th male fruitfly is in group $X$ and 0 otherwise, and $\epsilon_i \sim iid N(0,\sigma^2)$.
Alternatively, our final model could be written as $$\text{days}{ij} = \mu + \alpha_i + \epsilon{ij},$$ where $\mu$ is the overall mean survival time and $\alpha_i$ is the effect of being in the $i$th group and $\epsilon_{ij} \sim iid~N(0,\sigma^2)$.
Our model explained 31% of variability in male fruitfly longevity.
Researchers were interested in how sexual activity affects male fruitfly longevity.
We see that the effect of Group 5, males with 8 uninterested females, seems markedly different from all the others.
In particular group 5 males, on average, lived fewer days than:
r resultStr1[2] fewer days.r resultStr1[1] fewer days.r resultStr1[4] fewer days.On a lighter note these male fruit flies are fine if no females are about or if they are there they need to be 'interested' in them --- otherwise they die earlier (they 'drop like flies'). It's tempting to make similar inference about the human species but that may be going too far!
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.