Run a t-test to compare the Legolas actors to the set of Aragorns and then the set of Gimlis. Do you find evidence for significant differences?

Legolas = rnorm(50, mean=195, sd=15)
Aragorn = rnorm(50, mean=180, sd=10)
Gimli= rnorm(50, mean = 132, sd = 15)
t.test(Legolas, Aragorn, alternative="two.sided")
## 
##  Welch Two Sample t-test
## 
## data:  Legolas and Aragorn
## t = 3.1958, df = 86.285, p-value = 0.001949
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##   2.42520 10.40713
## sample estimates:
## mean of x mean of y 
##  190.0832  183.6671
t.test(Legolas, Gimli, alternative="two.sided")
## 
##  Welch Two Sample t-test
## 
## data:  Legolas and Gimli
## t = 22.396, df = 90.215, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  57.03827 68.14233
## sample estimates:
## mean of x mean of y 
##  190.0832  127.4929

Re-run the variance test (F-test) to compare the group of Gimli and Legolas actors. Do these groups have different variance?

var.test(Legolas, Gimli)
## 
##  F test to compare two variances
## 
## data:  Legolas and Gimli
## F = 0.54588, num df = 49, denom df = 49, p-value = 0.03641
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.3097729 0.9619405
## sample estimates:
## ratio of variances 
##          0.5458783

Redo the correlation for the Sepal Length and Sepal Width for the Iris dataset, but for the three individual species. Are these correlated?

iris = read.csv("iris.csv")
iris$Species = factor(iris$Species)

setosa = iris$Species 
irisset = iris[setosa,]
cor.test(irisset$Sepal.Length, irisset$Sepal.Width)
## 
##  Pearson's product-moment correlation
## 
## data:  irisset$Sepal.Length and irisset$Sepal.Width
## t = 9.0306, df = 148, p-value = 8.511e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.4818007 0.6903567
## sample estimates:
##       cor 
## 0.5960396
versicolor = iris$Species == "versicolor"
irisvers = iris[versicolor,]
cor.test(irisvers$Sepal.Length, irisvers$Sepal.Width)
## 
##  Pearson's product-moment correlation
## 
## data:  irisvers$Sepal.Length and irisvers$Sepal.Width
## t = 4.2839, df = 48, p-value = 8.772e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2900175 0.7015599
## sample estimates:
##       cor 
## 0.5259107
virginica = iris$Species == "virginica"
irisvir = iris[virginica,]
cor.test(irisvir$Sepal.Length, irisvir$Sepal.Width)
## 
##  Pearson's product-moment correlation
## 
## data:  irisvir$Sepal.Length and irisvir$Sepal.Width
## t = 3.5619, df = 48, p-value = 0.0008435
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2049657 0.6525292
## sample estimates:
##       cor 
## 0.4572278

Using the deer dataset and the chisq.test() function, test:

If there are significant differences in the number of deer caught per month

deer = read.csv("deer.csv")
chisq.test(table(deer$Month))
## 
##  Chi-squared test for given probabilities
## 
## data:  table(deer$Month)
## X-squared = 997.07, df = 11, p-value < 2.2e-16

If the cases of tuberculosis are uniformly distributed across all farms

chisq.test(table(deer$Tb))
## 
##  Chi-squared test for given probabilities
## 
## data:  table(deer$Tb)
## X-squared = 508.14, df = 1, p-value < 2.2e-16