my2.7 = load.image("2.7.jpg")
rotated2.7 = imrotate(my2.7, 270)
save.image(rotated2.7,"rotated2.7.jpg")
include_graphics("rotated2.7.jpg")
my2.10 = load.image("2.10.jpg")
rotated2.10 = imrotate(my2.10, 270)
save.image(rotated2.10,"rotated2.10.jpg")
include_graphics("rotated2.10.jpg")
include_graphics("2.12.jpg")
include_graphics("2.17.jpg")
include_graphics("2.26.jpg")
The first thing we must do is read in the data from excel.
mydata = read.csv("2.26 Data.csv", header = TRUE)
mydata
## ï..Type.1 Type.2
## 1 65 64
## 2 81 71
## 3 57 83
## 4 66 59
## 5 82 65
## 6 82 56
## 7 67 69
## 8 59 74
## 9 75 82
## 10 70 79
Next we need to get the mean, variance, and sizes of the two samples.
mean1 = mean(mydata$ï..Type.1)
mean2 = mean(mydata$Type.2)
var1 = var(mydata$ï..Type.1)
var2 = var(mydata$Type.2)
n1 = length(mydata$ï..Type.1)
n2 = length(mydata$Type.2)
Using the sample variances, we can calculate our test statistic, F0, using the equation on slide 56 of CH2 slides.
F0 = var1 / var2
F0
## [1] 0.9782168
F0 = .978. Using the F - table on page 8 of the appendix, we compare our test stat to F(.025, 9, 9) = 4.03. Since .978 < 4.03, we do not reject the null.
Null hypothesis is that means are equal. Alternate hypothesis is that means are unequal (two sided). From part A, we know that the variances are assumed to be equal but unknown. I used formulas from slide 37 of CH2.
To calculate our test statistic, we must first calculate our pooled estimator of the common variance.
PE = (((n1 - 1)*var1) + ((n2 - 1)*var2)) / (n1 + n2 - 2)
PE
## [1] 86.77778
Using the pooled estimator we can calculate the standard error
Sp = sqrt(PE)
SE = Sp * sqrt((1/n1) + (1/n2))
SE
## [1] 4.166
Now that we have our standard error, we can calculate our test statistic, t0.
t0 = (mean1 - mean2) / SE
t0
## [1] 0.04800768
Comparing t0 to t(.025, 18): .048 < 2.101 Therefore, we do not reject the null.
To calculate p-value, we will use computer generated t-tes statistics.
t.test(mydata$ï..Type.1, mydata$Type.2, alternative = c("two.sided"), var.equal = TRUE)
##
## Two Sample t-test
##
## data: mydata$ï..Type.1 and mydata$Type.2
## t = 0.048008, df = 18, p-value = 0.9622
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -8.552441 8.952441
## sample estimates:
## mean of x mean of y
## 70.4 70.2
This test shows that the p-value is .9622.
The normality assumption is important in this problem as it allowed us to use the t-test. In the t-test, “we make the assumption that both samples are random samples that are drawn from independent populations that can be described by a normal distribution” (Page 41 of the textbook).
Here is the qqplot for type 1.
qqnorm(mydata$ï..Type.1, main = "Type 1")
qqline(mydata$ï..Type.1)
Since the points generally fall near the line, our normality assumption holds.
Here is the qqplot for type 2.
qqnorm(mydata$Type.2, main = "Type 2")
qqline(mydata$Type.2)
Since the points generally fall near the line, our normality assumption holds.
First step is to import data
mydata31 = read.csv("2.31 Data.csv", header = TRUE)
mydata31
## ï..Uniformity
## 1 5.34
## 2 6.00
## 3 5.97
## 4 5.25
## 5 6.65
## 6 7.55
## 7 7.35
## 8 6.35
## 9 4.76
## 10 5.54
## 11 5.44
## 12 4.61
## 13 5.98
## 14 5.62
## 15 4.39
## 16 6.00
## 17 7.25
## 18 6.21
## 19 4.98
## 20 5.32
For the confidence interval, we needed to calculate the sample variance.
var(mydata31$ï..Uniformity)
## [1] 0.7904484
We need to use a qqplot to test the normality assumption.
qqnorm(mydata31$ï..Uniformity, main = "Problem 2.31")
qqline(mydata31$ï..Uniformity)
include_graphics("2.31.jfif")