Load data

setwd("C:/Users/wesle/Downloads/Data 101")
ns <- readr::read_csv("NutritionStudy.csv")
fg3 <- readr::read_csv("FishGills3.csv")

1.

\(p_1\) = Proportion of those in the study classified as R \(p_2\) = Proportion of those in the study classified as X

\(H_0\):\(p_1\) = \(p_2\) = 1/2 \(H_a\): at least on \(p_i\) \(\neq\) 1/2

scounts <- c(244, 192)

sprop <- rep(1/2, 2)
expval <- sprop*sum(scounts)
expval
## [1] 218 218

All expected counts are above 5

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

p-value = 0.01276

The p-value is 0.01276 which is less than the default α which is 0.05. This means that we reject the null that the two options, R and X, are equally likely.

2.

\(H_0\): Gender is not assosiated with vitamin use \(H_a\): Gender is assosiated with vitamin use

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

p-value = 0.003944

The p-value is 0.003944 which is signifcantly lower than the default α of 0.05, which means that there is an assosiation between gender and vitamin use.

3.

\(\mu_A\) = Mean gill beat rate of fish in high calcium tank \(\mu_A\) = Mean gill beat rate of fish in medium calcium tank \(\mu_A\) = Mean gill beat rate of fish in low calcium tank

\(H_0\): \(\mu_A\) = \(\mu_B\) = \(\mu_C\)

\(H_a\): not all \(\mu_i\) are equal

anovar <- aov(GillRate ~ Calcium, data = fg3)
anovar
## Call:
##    aov(formula = GillRate ~ Calcium, data = fg3)
## 
## 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(anovar)
##             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

p-value = 0.0121

The p-value is 0.0121 which is less than the default α of 0.05, this means that we reject the null and that atleast one of the mean gill beat rates of the 3 different calcium level tanks is different.