A sample of 436 people was classified according to weather they had the R or X allele. The were 244 people with the R allele and 192 with the X allele. I am going to determine whether the two alleles are equally likely.
Hypotheses:
Null hypothesis: The R and X alleles are equally likely.
Alternative hypothesis: The R and X alleles are not equally likely.
ACTN3 <- c(R = 244, X = 192)
ACTN3
## R X
## 244 192
ACTN3_test <- chisq.test( ACTN3, p = c(0.50, 0.50) )
ACTN3_test
##
## Chi-squared test for given probabilities
##
## data: ACTN3
## X-squared = 6.2018, df = 1, p-value = 0.01276
Conclusion:
P-value = 0.01276
I am using a significance level of alpha = 0.05 this is grader than the p-value so we reject the null hypothesis. There is sufficient evidence that the R and A alleles are not equally likely. The sample contained more R alleles than X alleles.
The Nutrition Study dataset contains information about vitamin use and the sex of the participants. OI will perform a chi-square test of association to determine whether vitamin use is associated with sex.
NutritionStudy <- read.csv("NutritionStudy.csv")
head(NutritionStudy)
## ID Age Smoke Quetelet Vitamin Calories Fat Fiber Alcohol Cholesterol
## 1 1 64 No 21.4838 1 1298.8 57.0 6.3 0.0 170.3
## 2 2 76 No 23.8763 1 1032.5 50.1 15.8 0.0 75.8
## 3 3 38 No 20.0108 2 2372.3 83.6 19.1 14.1 257.9
## 4 4 40 No 25.1406 3 2449.5 97.5 26.5 0.5 332.6
## 5 5 72 No 20.9850 1 1952.1 82.6 16.2 0.0 170.8
## 6 6 40 No 27.5214 3 1366.9 56.0 9.6 1.3 154.6
## BetaDiet RetinolDiet BetaPlasma RetinolPlasma Sex VitaminUse PriorSmoke
## 1 1945 890 200 915 Female Regular 2
## 2 2653 451 124 727 Female Regular 1
## 3 6321 660 328 721 Female Occasional 2
## 4 1061 864 153 615 Female No 2
## 5 2863 1209 92 799 Female Regular 1
## 6 1729 1439 148 654 Female No 2
Hypothesis:
Null Hypothesis: There is no association between sex and vitamin use. The two variables are independent.
Alternative Hypothesis: There is an association between sex and vitamin use. The two variables are not independent.
vitamin_table <- table( NutritionStudy$Sex, NutritionStudy$VitaminUse )
vitamin_table
##
## No Occasional Regular
## Female 87 77 109
## Male 24 5 13
vitamin_test <- chisq.test(vitamin_table)
vitamin_test
##
## Pearson's Chi-squared test
##
## data: vitamin_table
## X-squared = 11.071, df = 2, p-value = 0.003944
Conclusion:
The P-value = 0.003944
I am using a significance level of 0.05; in this case, 0.05 is greater than the p-value we go so we will reject the null hypothesis. There is sufficient evidence that there is a significant association between sex and vitamin use. This sample showed that females use vitamins more regularly than men. Vitamin use and sex are not independent in the sample.
I will use a one-way ANOVA test to determine whether the mean gill rate differs depending on the calcium level of the water.
FishGills3 <- read.csv("FishGills3.csv")
head(FishGills3)
## Calcium GillRate
## 1 Low 55
## 2 Low 63
## 3 Low 78
## 4 Low 85
## 5 Low 65
## 6 Low 98
Hypothesis:
Null Hypothesis: The mean gill rate is the same for all three calcium levels.
Alternative Hypothesis: At least one mean gill rate is different.
gill_anova <- aov(GillRate ~ Calcium, data = FishGills3)
summary(gill_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
Conclusion:
P-vales = 0.0121
Since the p-value of 0.0121 is less than 0.05, we reject the null hypothesis. There is sufficient evidence to conclude that the mean gill rate differs depending on the calcium level of the water.