fish <- read.csv("FishGills3.csv")
nutrition <- read.csv("NutritionStudy.csv")
#Problem 1

alleles <- c(244, 192)

chisq.test(alleles, p = c(0.5, 0.5))
## 
##  Chi-squared test for given probabilities
## 
## data:  alleles
## X-squared = 6.2018, df = 1, p-value = 0.01276

###Hypothesis

H₀: The R and X alleles are equally likely in the population.

pR​= pX​= 0.50

Hₐ: The R and X alleles are not equally likely in the population.

p-value : p = 0.0128

#Conclusion: Because the p-value of 0.0128 is less than 0.05, we reject the null hypothesis. There is statistically significant evidence that the R and X alleles are not equally likely in the population represented by this sample. The R allele occurred more often, with 244 individuals classified as R compared with 192 classified as X.



``` r
#Problem 2
vitamin_table <- table(nutrition$Sex, nutrition$VitaminUse)

vitamin_table
##         
##           No Occasional Regular
##   Female  87         77     109
##   Male    24          5      13
chisq.test(vitamin_table)
## 
##  Pearson's Chi-squared test
## 
## data:  vitamin_table
## X-squared = 11.071, df = 2, p-value = 0.003944

Hypothesis

H₀: Sex and vitamin use are independent. There is no association between a person’s sex and their vitamin use.

Hₐ: Sex and vitamin use are associated. There is a relationship between a person’s sex and their vitamin use.

p-value : p = 0.00394

#Conclusion: Since the p-value of 0.00394 is less than 0.05, we reject the null hypothesis. There is statistically significant evidence of an association between sex and vitamin use. The sample suggests that vitamin use patterns differ between males and females. For example, females had proportionally more occasional and regular vitamin users than males.

#Problem 3
anova <- aov(GillRate ~ Calcium, data = fish)

summary(anova)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## Calcium      2   2037  1018.6   4.648 0.0121 *
## Residuals   87  19064   219.1                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
aggregate(GillRate ~ Calcium, data = fish, mean)
##   Calcium GillRate
## 1    High 58.16667
## 2     Low 68.50000
## 3  Medium 58.66667

Hypothesis

H₀: The mean gill rates are equal for all three calcium levels.

μLow =μMedium =μHigh

Hₐ: At least one calcium level has a different mean gill rate.

#p-value : p = 0.0121

#Conclusion: the p-value of 0.0121 is less than 0.05, so we reject the null hypothesis. There is statistically significant evidence that mean fish gill rate differs depending on the calcium level of the water. The low-calcium group had the highest average gill rate at approximately 68.5 beats per minute, compared with approximately 58.7 beats per minute for the medium-calcium group and 58.2 beats per minute for the high-calcium group. ```