Null H0: The two groups of actors have the same height
Alternative Ha: The two groups of actors have different heights
legolas = rnorm(50, 195, 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 = 4.5041, df = 94.139, p-value = 1.911e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 6.719479 17.313748
## sample estimates:
## mean of x mean of y
## 194.1439 182.1273
t.test(legolas, gimli, alternative="two.sided")
##
## Welch Two Sample t-test
##
## data: legolas and gimli
## t = 20.398, df = 97.775, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 55.21154 67.11275
## sample estimates:
## mean of x mean of y
## 194.1439 132.9818
In both of these tests, p=0, which shows a significant difference between groups and means that we can reject our null hypothesis with high confidence.
var.test(gimli,legolas)
##
## F test to compare two variances
##
## data: gimli and legolas
## F = 1.1009, num df = 49, denom df = 49, p-value = 0.7379
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.6247186 1.9399438
## sample estimates:
## ratio of variances
## 1.100872
In this test, the value of p is above 0.05, (=0.9131), suggesting that there is no significant difference in variance.
deer <- read.csv("deer.csv")
table(deer$Month)
##
## 1 2 3 4 5 6 7 8 9 10 11 12
## 256 165 27 3 2 35 11 19 58 168 189 188
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
The p-value is zero, meaning that this relationship is significant.
table(deer$Tb, deer$Farm)
##
## AL AU BA BE CB CRC HB LCV LN MAN MB MO NC NV PA PN QM RF RN
## 0 10 23 67 7 88 4 22 0 28 27 16 186 24 18 11 39 67 23 21
## 1 3 0 5 0 3 0 1 1 6 24 5 31 4 1 0 0 7 1 0
##
## RO SAL SAU SE TI TN VISO VY
## 0 31 0 3 16 9 16 13 15
## 1 0 1 0 10 0 2 1 4
chisq.test(table(deer$Tb, deer$Farm))
## Warning in chisq.test(table(deer$Tb, deer$Farm)): Chi-squared approximation may
## be incorrect
##
## Pearson's Chi-squared test
##
## data: table(deer$Tb, deer$Farm)
## X-squared = 129.09, df = 26, p-value = 1.243e-15
The p-value is zero, meaning that this relationship is significant.