library(tidyverse)
nutrition <- read_csv("NutritionStudy.csv")
fishgills <- read_csv("FishGills3.csv")
observed <- c(244,192)
theoritical_prop <- rep(1/2,2) ##Null values
\(H_0\):\(p_R\) = \(p_X\) = 1/2 \(H_a\): R and X alleles are not equally likely.
expected_values <- theoritical_prop * sum(observed)
expected_values
## [1] 218 218
All values are more than 5 so, we are doing the chi-square test
chisq.test(observed)
##
## Chi-squared test for given probabilities
##
## data: observed
## X-squared = 6.2018, df = 1, p-value = 0.01276
Therefore, based on the p-value (0.01276) obtained, we reject the idea that the outcomes are equally likely and conclude that there are differences in R and X alleles.
observed_dataset <- table(nutrition$VitaminUse, nutrition$Sex)
observed_dataset
##
## Female Male
## No 87 24
## Occasional 77 5
## Regular 109 13
\(H_0\) : Vitamin use is not associated with gender \(H_a\) : Vitamin use is associated with gender
chisq.test(observed_dataset)
##
## Pearson's Chi-squared test
##
## data: observed_dataset
## X-squared = 11.071, df = 2, p-value = 0.003944
with a p-value of 0.003944, which is less than the typical significance level of 0.05, there is sufficient evidence to reject the null hypothesis.
Therefore, we conclude that there is a significant association between vitamin use and the gender.
\(H_0\): All calcium level groups have the same mean gill rate
\(H_a\): At least one calcium group has a different mean gill rate
anova_result <- aov(GillRate ~ Calcium, data = fishgills)
anova_result
## Call:
## aov(formula = GillRate ~ Calcium, data = fishgills)
##
## Terms:
## Calcium Residuals
## Sum of Squares 2037.222 19064.333
## Deg. of Freedom 2 87
##
## Residual standard error: 14.80305
## Estimated effects may be unbalanced
summary(anova_result)
## 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
The p-value is small (0.0121): indicating strong evidence against the null hypothesis. Overall, this test suggests that at least one calcium group has a different mean gill rate.