- Study the lecture notes and screen cast for Statistical Tests and
Confidence Intervals, Part 1: One Mean or the Difference of Two Means
(10:16). Consider testing H0:μ=7 against H1:μ>7, given this random
sample from a normal population: 7, 12.2, 7.1, 10.1, 11, 14.7, 8.8, 6,
11.4, 13.8, 13.4, 9.2, 17.4, 13.1, 6.5, 9.8, 5.4, 11.4, 11, 10.8, 1.5,
22. Find the value of the test statistic, t.
x = c(7, 12.2, 7.1, 10.1, 11, 14.7, 8.8, 6, 11.4, 13.8, 13.4, 9.2, 17.4, 13.1, 6.5, 9.8, 5.4, 11.4, 11, 10.8, 1.5, 22)
t.test(x, alternative="greater", mu =7)
# The t value is 3.8853
Consider testing H0:μ=5 against H1:μ>5, given this random sample
from a normal population: 4.3, 2.6, 12.2, 7.3, 6.8, 4.8, 1, 5.2, 12.5,
5.6, 3.5, 11.9, 6.4, 4.4, 6.3, 11.3, 7.3, 7.4, 0.9, 11, 9. Find the
value of the test statistic, t.
x = c(4.3, 2.6, 12.2, 7.3, 6.8, 4.8, 1, 5.2, 12.5, 5.6, 3.5, 11.9, 6.4, 4.4, 6.3, 11.3, 7.3, 7.4, 0.9, 11, 9)
t.test(x, alternative = "greater", mu=5)
# t = 2.2716
- Assuming H0 is true, find the probability of seeing a test statistic
as extreme as the one you found. (That is, find the P-value.)
x = c(7, 12.2, 7.1, 10.1, 11, 14.7, 8.8, 6, 11.4, 13.8, 13.4, 9.2, 17.4, 13.1, 6.5, 9.8, 5.4, 11.4, 11, 10.8, 1.5, 22)
t.test(x, alternative="greater", mu =7)
# The P value is 0.0004272
- Assuming H0 is true, find the probability of seeing a test statistic
as extreme as the one you found. (That is, find the P-value.)
x = c(4.3, 2.6, 12.2, 7.3, 6.8, 4.8, 1, 5.2, 12.5, 5.6, 3.5, 11.9, 6.4, 4.4, 6.3, 11.3, 7.3, 7.4, 0.9, 11, 9)
t.test(x, alternative = "greater", mu=5)
# p = 0.01715
- Find left endpoint of a 90% (two-sided) confidence interval for the
unknown population mean, μ, given the previous random sample.
x = c(4.3, 2.6, 12.2, 7.3, 6.8, 4.8, 1, 5.2, 12.5, 5.6, 3.5, 11.9, 6.4, 4.4, 6.3, 11.3, 7.3, 7.4, 0.9, 11, 9)
t.test(x, alternative = "two.sided", conf.level = .90)
# left is 5.420721
- Find the right endpoint of the previous confidence interval.
x = c(4.3, 2.6, 12.2, 7.3, 6.8, 4.8, 1, 5.2, 12.5, 5.6, 3.5, 11.9, 6.4, 4.4, 6.3, 11.3, 7.3, 7.4, 0.9, 11, 9)
t.test(x, alternative = "two.sided", conf.level = .90)
# right is 8.074517
- Study Part 2: F Test for Equality of Variances (3:52). Consider
testing H0:σ2X=σ2Y against H1:σ2X≠σ2Y from two independent samples from
normal populations with unknown means μX and μY and standard deviations
σX and σY. The X’s are 7.9, 19.4, 15, 13.5, 6.5, 5.1. The Y’s are 8.4,
5.3, 1.5, 3.8, 6.1, 7.4, 3.5. Find the value of the test statistic.
X = c(7.9, 19.4, 15, 13.5, 6.5, 5.1)
Y = c(8.4, 5.3, 1.5, 3.8, 6.1, 7.4, 3.5)
ftestout = var.test(X, Y, ratio = 1); ftestout
# F = 5.4794
- Find the P-value.
X = c(7.9, 19.4, 15, 13.5, 6.5, 5.1)
Y = c(8.4, 5.3, 1.5, 3.8, 6.1, 7.4, 3.5)
ftestout = var.test(X, Y, ratio = 1); ftestout
# p-value = 0.06129
- Study Part 3: Chi-Squared Tests (7:45). Consider testing whether the
row and column variables are independent, given the following two-way
table of observed counts: 11 16 13 10 14 19 19 13 15 Find the value of
the chi-square test statistic.
m = matrix(data = c(11, 16, 13, 10, 14, 19, 19, 13, 15), nrow = 3, ncol = 3, byrow = TRUE);m
[,1] [,2] [,3]
[1,] 11 16 13
[2,] 10 14 19
[3,] 19 13 15
c = chisq.test(m); c$statistic
X-squared
4.500904
- Find the P-value.
m = matrix(data = c(11, 16, 13, 10, 14, 19, 19, 13, 15), nrow = 3, ncol = 3, byrow = TRUE);m
[,1] [,2] [,3]
[1,] 11 16 13
[2,] 10 14 19
[3,] 19 13 15
c = chisq.test(m); c$p.value
[1] 0.3424403
- Study Part 4: One Proportion or the Difference of Two Proportions
(8:46). Consider testing H0:p=0.5 against H1:p≠0.5, given that there
were 35 successes in a sample of size 52. Find the value of the
(chi-squared) test statistic. (Do not use the continuity
correction.)
x = 35
n = 52
p = 0.5
prtest = prop.test(x, n, p, correct = FALSE); prtest$statistic
X-squared
6.230769
prtest
1-sample proportions test without continuity correction
data: x out of n, null probability p
X-squared = 6.2308, df = 1, p-value = 0.01255
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.5375619 0.7847793
sample estimates:
p
0.6730769
# X-squared = 5.557692
- Find the P-value.
x = 35
n = 52
p = 0.5
prtest = prop.test(x, n, p); prtest$p.value
[1] 0.01839965
LS0tDQp0aXRsZTogIlF1aXogNiBTY3JpcHRzIg0Kb3V0cHV0OiBodG1sX25vdGVib29rDQotLS0NCjEuIFN0dWR5IHRoZSBsZWN0dXJlIG5vdGVzIGFuZCBzY3JlZW4gY2FzdCBmb3IgU3RhdGlzdGljYWwgVGVzdHMgYW5kIENvbmZpZGVuY2UgSW50ZXJ2YWxzLCBQYXJ0IDE6IE9uZSBNZWFuIG9yIHRoZSBEaWZmZXJlbmNlIG9mIFR3byBNZWFucyAoMTA6MTYpLg0KQ29uc2lkZXIgdGVzdGluZyBIMDrOvD03IGFnYWluc3QgSDE6zrw+NywgZ2l2ZW4gdGhpcyByYW5kb20gc2FtcGxlIGZyb20gYSBub3JtYWwgcG9wdWxhdGlvbjogNywgMTIuMiwgNy4xLCAxMC4xLCAxMSwgMTQuNywgOC44LCA2LCAxMS40LCAxMy44LCAxMy40LCA5LjIsIDE3LjQsIDEzLjEsIDYuNSwgOS44LCA1LjQsIDExLjQsIDExLCAxMC44LCAxLjUsIDIyLiBGaW5kIHRoZSB2YWx1ZSBvZiB0aGUgdGVzdCBzdGF0aXN0aWMsIHQuDQpgYGB7cn0NCnggPSBjKDcsIDEyLjIsIDcuMSwgMTAuMSwg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