-
Notifications
You must be signed in to change notification settings - Fork 0
/
ch5.R
71 lines (52 loc) · 1.45 KB
/
ch5.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
library(ISwR)
daily.intake <- c(5260, 5470, 5640, 6180, 6390, 6515, 6805, 7515, 7515, 8230, 8770)
print(mean(daily.intake))
print(sd(daily.intake))
print(quantile(daily.intake))
print(t.test(daily.intake, mu=7725))
#print(wilcox.test(daily.intake, mu=7725))
#print(t.test(expend ~ stature, var.equal=T))
#print(var.test(expend ~ stature))
#print(wilcox.test(expend ~ stature))
#attach(intake)
#print(intake)
#print(t.test(pre, post, paired=T))
#print(wilcox.test(pre, post, paired=T))
#5.1
qqnorm(react)
print(mean(react))
print(sd(react))
print(quantile(react))
print(t.test(react))#
#normally distributed, not centered on 0, but -0.8 ~-1
#significantly different from 0
#5.2
print(t.test(vital.capacity ~ group, conf=0.99, data=vitcap))
#5.3
print(wilcox.test(react))
print(wilcox.test(vital.capacity ~ group, data=vitcap))
#5.4
attach(intake)
opar <- par(mfrow=c(2,2))
plot(post~pre)
abline(0,1)
plot((post+pre)/2, post-pre, ylim=range(0, post-pre))
abline(h=0)
hist(post-pre)
qqnorm(post-pre)
detach(intake)
par(opar)
#5.5
print(shapiro.test(react[-c(1,334)]))
qqnorm(react[-c(1,334)])
#5.6
print(ashina)
attach(ashina)
print(t.test(vas.active, vas.plac, paired=T))
print(t.test((vas.active-vas.plac)[grp==1],(vas.plac-vas.active)[grp==2]))
#5.7
print(t.test(rnorm(25))$p.value)
print(t.test(rt(25, df=2))$p.value)
print(t.test(rexp(25), mu=1)$p.value)
x <- replicate(5000, t.test(rexp(25), mu=1)$p.value)
qqplot(sort(x), ppoints(5000), type='l', log='xy')