#Problem 1
observed <- c(R = 244, X = 192)
expected <- c(218, 218)
chisq.test(x = observed, p = c(0.5, 0.5))
##
## Chi-squared test for given probabilities
##
## data: observed
## X-squared = 6.2018, df = 1, p-value = 0.01276
Because the chi-square test produced a p-value of 0.01276, which is less than 0.05, we reject the null hypothesis. The R and X alleles are not equally likely in the population, and the observed distribution differs significantly from a 50/50 ratio.
df <- read.csv("NutritionStudy (1).csv")
tab <- table(df$VitaminUse, df$Sex)
chisq_res <- chisq.test(tab)
chisq_res$expected
##
## Female Male
## No 96.20000 14.80000
## Occasional 71.06667 10.93333
## Regular 105.73333 16.26667
min(chisq_res$expected)
## [1] 10.93333
chisq_res
##
## Pearson's Chi-squared test
##
## data: tab
## X-squared = 11.071, df = 2, p-value = 0.003944
Since the p-value (0.00394) is less than the significance level (α = 0.05), we reject the null hypothesis. There is statistically significant evidence of an association between vitamin use and sex. In this sample, vitamin-taking behavior appears to differ between males and females. Based on the contingency table, females were more likely to take vitamins than males.
df1 <- read.csv("FishGills3 (1).csv")
df1$Calcium <- as.factor(df1$Calcium)
model <- aov(GillRate ~ Calcium, data = df1)
summary(model)
## 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
Since the ANOVA test produced a p-value of 0.0121, which is less than 0.05, we reject the null hypothesis. This indicates that mean gill beat rate differs significantly among the three calcium levels.