This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
Problem 1: ACTN3 is a gene that encodes alpha-actinin-3, a protein in fast-twitch muscle fibers, important for activities like sprinting and weightlifting. The gene has two main alleles: R (functional) and X (non-functional). The R allele is linked to better performance in strength, speed, and power sports, while the X allele is associated with endurance due to a greater reliance on slow-twitch fibers. However, athletic performance is influenced by various factors, including training, environment, and other genes, making the ACTN3 genotype just one contributing factor. A study examines the ACTN3 genetic alleles R and X, also associated with fast-twitch muscles. Of the 436 people in this sample, 244 were classified as R, and 192 were classified as X. Does the sample provide evidence that the two options are not equally likely? Conduct the test using a chi-square goodness-of-fit test.
#observed
observed <- c(244, 192)
#null or missing
missing <- rep(1/2, 2)
#expected values
expected <- missing*sum(observed)
expected
## [1] 218 218
#results
chisq.test(observed)
##
## Chi-squared test for given probabilities
##
## data: observed
## X-squared = 6.2018, df = 1, p-value = 0.01276
p-value 0.01276 is small, The sample does provide evidence that the two options are not equally likely.
Problem 2: Who Is More Likely to Take Vitamins: Males or Females? The dataset NutritionStudy contains, among other things, information about vitamin use and the gender of the participants. Is there a significant association between these two variables? Use the variables VitaminUse and Gender to conduct a chi-square analysis and give the results. (Test for Association)
setwd("~/Documents/School/Data 101/HW8")
df <- read.csv("NutritionStudy.csv")
#observed
observed <- table(df$VitaminUse, df$Sex)
observed
##
## Female Male
## No 87 24
## Occasional 77 5
## Regular 109 13
#result
chisq.test(observed)
##
## Pearson's Chi-squared test
##
## data: observed
## X-squared = 11.071, df = 2, p-value = 0.003944
seems liek there is a significant difference between the two variables based off the p-value.
Problem 3: Most fish use gills for respiration in water, and researchers can observe how fast a fish’s gill cover beats to study ventilation, much like we might observe a person’s breathing rate. Professor Brad Baldwin is interested in how water chemistry might affect gill beat rates. In one experiment, he randomly assigned fish to tanks with different calcium levels. One tank was low in calcium (0.71 mg/L), the second tank had a medium amount (5.24 mg/L), and the third tank had water with a high calcium level (18.24 mg/L). His research team counted gill rates (beats per minute) for samples of 30 fish in each tank. The results are stored in FishGills3. Perform ANOVA test to see if the mean gill rate differs depending on the calcium level of the water.
setwd("~/Documents/School/Data 101/HW8/Fish")
Fish <- read.csv("FishGills3.csv")
summary(Fish)
## Calcium GillRate
## Length:90 Min. :33.00
## Class :character 1st Qu.:48.00
## Mode :character Median :62.50
## Mean :61.78
## 3rd Qu.:72.00
## Max. :98.00
#ANOVA
anova_results <- aov(GillRate ~ Calcium, data = Fish)
anova_results
## Call:
## aov(formula = GillRate ~ Calcium, data = Fish)
##
## 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_results)
## 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 is 0.0121 indicating that the against gill rate differs depending on the calcium level of the water.
#Tuckey
TukeyHSD(anova_results)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = GillRate ~ Calcium, data = Fish)
##
## $Calcium
## diff lwr upr p adj
## Low-High 10.333333 1.219540 19.4471264 0.0222533
## Medium-High 0.500000 -8.613793 9.6137931 0.9906108
## Medium-Low -9.833333 -18.947126 -0.7195402 0.0313247