Thy Nguyen Thn553
This homework is due on September 6th at 11:59pm. Please submit as a pdf file on Canvas.
This homework uses the crabs dataset available in R. This data set contains various morphological measures of male and female crabs of two different species (blue or orange). We will focus on the measurement FL which is the frontal lobe size measured in mm.
library(MASS)
data(crabs)
head(crabs)
## sp sex index FL RW CL CW BD
## 1 B M 1 8.1 6.7 16.1 19.0 7.0
## 2 B M 2 8.8 7.7 18.1 20.8 7.4
## 3 B M 3 9.2 7.8 19.0 22.4 7.7
## 4 B M 4 9.6 7.9 20.1 23.1 8.2
## 5 B M 5 9.8 8.0 20.3 23.0 8.2
## 6 B M 6 10.8 9.0 23.0 26.5 9.8
More information on the dataset can be obtained by running help(crabs).
Question 1: We are interested in determining which species of crab has larger frontal lobe size, accounting for possible dependence on sex. First, let’s visualize the data. Usingggplot, make a boxplot which compares FL across species for males, and another boxplot which compares FL across species for females. Then, comment on whether it appears that there is a difference across species, across sex, and whether any differences across species are dependent on sex.
# your R code goes here
Your answer goes here. 1-2 sentences only.
Question 2: Use a two-way ANOVA (analysis of variance) to determine if there is evidence of a difference in frontal lobe size by sex, species, and if the effect of species is dependent on sex. Hint: You will first need to fit a linear model using the lm() function to regress FL on sex, sp, and sex * sp (the interaction) and then use the anova() function to perform the analysis of variance.
# your R code goes here.
Your answer goes here. 1-2 sentences only.
Question 3 Use a \(t\)-test to determine if the mean “rear width” (RW) of blue males is different from the rear width of blue females. Interpret and explain your results in 1-2 sentences.
# your R code goes here
Your answer goes here. 1-2 sentences only.
Question 4 Make and interpret a new figure of your choice using one of the geom’s discussed in Lecture 3: (hist, point, line, density, violin, col), using at least two of the fill, color, and size aesthetics. Write 1-2 sentences about what relationship is revealed by the figure you made.
Your answer goes here. 1-2 sentences only.