Remember to have the necessary R packages installed and read into RStudio

library(ggplot2)

STAGE ONE: Hypothesis (TOTAL = 4 points) NULL Hypothesis: (2 points) ALTERNATIVE Hypothesis (2 points)

STAGE TWO: Load Data (TOTAL = 1 point) ## Use the empty code chunk below to read the mander.csv dataset into RStudio and create a new object ##

Registered S3 methods overwritten by 'htmltools':
  method               from         
  print.html           tools:rstudio
  print.shiny.tag      tools:rstudio
  print.shiny.tag.list tools:rstudio
Registered S3 method overwritten by 'rmarkdown':
  method         from
  print.paged_df     
manders <- read.csv("mander.csv")

STAGE THREE Descriptive statistics: (TOTAL = 20 points)

Use the empty code chunk below to describe measures of central tendancy for each sex group ## (9 points)

manders_f <- manders[manders$Sex == "female",]
manders_m <- manders[manders$Sex == "male",]
Length_manders_mf <- manders[manders$Total_length == "male"]
median(manders_f$Total_length)
[1] 81
mean(manders_f$Total_length)
[1] 80.01613
sd(manders_f$Total_length)
[1] 9.782038
median(manders_m$Total_length)
[1] 77
mean(manders_m$Total_length)
[1] 76.72289
sd(manders_m$Total_length)
[1] 7.477304

Use the code chunk below to produce a simple boxplot (2 points) and frequency histogram (2 points) of salamander total length by the different sex groups

hist(manders$Total_length, probability=TRUE)

boxplot(manders$Total_length~manders$Sex)

Use the code chunk below to test for normality for salamander body length (2 points)

Null hypothesis: The salamander body length data follows the normal distribution. (1 point) Alternative Hypothesis: The salamander body length data doesn’t follow the normal distribution. (1 point)

shapiro.test(manders_f$Total_length)

    Shapiro-Wilk normality test

data:  manders_f$Total_length
W = 0.88958, p-value = 4.3e-05
shapiro.test(manders_m$Total_length)

    Shapiro-Wilk normality test

data:  manders_m$Total_length
W = 0.96394, p-value = 0.01988

Statistical test output: Are your data normally distributed? (1 point). How do you know this - relate your answer to your normality hypotheses? (2 point) The data is not normally distributed because both have a p-value less than 0.05. The null hypothesis is rejected because the p-value is less then 0.05.

STAGE FOUR Plotting Data: (TOTAL = 5 points)

Use ggplot in the empty code chunk below to produce a boxplot of total length for each salamander sex group(5 points)

library(ggplot2)
ggplot (manders, aes(x = Sex, y = Total_length)) + 
  geom_boxplot(fill = "lightblue")

STAGE FIVE: Statistical tests (TOTAL = 4 points)

In the code chunk below, there is a new function - the aov () function This is used to test whether the total length means are significantly different between sexes You should be able to recognize that we first create a new output object called oneway.test The we use the summary () function to reveal the ANOVA output table

oneway.test <- aov(Total_length ~ Sex, data = manders)
summary(oneway.test)
             Df Sum Sq Mean Sq F value Pr(>F)    
Sex           2  22046   11023   90.33 <2e-16 ***
Residuals   270  32949     122                   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

What does the P-value tell you about significant differences between the different groups? (4 points)

It shows that there is a very big significant difference between the groups.

Use the following code chunk to run a post-hoc test to identify where the significant differences are. Note: this code chunk creates a new post hoc test output object using the TukeyHSD () function which contains your anova object from the previous code chunk The print () function is used to show the output of the post-hoc test

tukeytest <- TukeyHSD(oneway.test)
print(tukeytest)
  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = Total_length ~ Sex, data = manders)

$Sex
                     diff        lwr        upr     p adj
male-female     -3.293237  -7.663406   1.076931 0.1796283
unknown-female -19.734879 -23.763209 -15.706549 0.0000000
unknown-male   -16.441642 -20.110629 -12.772654 0.0000000

Annotate here your own notes on the R-chitecture and interpretation of the output from the lecture

STAGE SIX: Reporting the results (TOTAL = 6 points)

What does the one-way ANOVA output tell you about the total length of salamanders and the different sexes? (2 points)

We would fail to reject the null hypothesis becausd the p- value is greater than .05.

What does this mean for your overall (STAGE ONE) hypotheses? (2 points)

You would accept the null hypothesis.

What do the results of the post-hoc test tell you about ‘where’ any significant differences occur? (2 points)

Significant differences occur when the p-value<0.05. In both the unknown-female and unknown-male section, the p-value is 0.00, less than .05, and therefore significant. You can also see that the upper and lower quartiles do not cross 0, also showing a lack of statistical significance.

LS0tCnRpdGxlOiAiR1JPVVAgQVNTU0lHTk1FTlQgIyA1IFJlZC1iYWNrZWQgU2FsYW1hbmRl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