File: Ch_Intro.R

package info (click to toggle)
multcomp 1.4-29-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,444 kB
  • sloc: sh: 28; makefile: 2
file content (77 lines) | stat: -rw-r--r-- 2,504 bytes parent folder | download | duplicates (2)
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
72
73
74
75
76
77

###################################################
### chunk number 2: setup
###################################################
set.seed(290875)


###################################################
### chunk number 3: packages-1
###################################################
library("ISwR")
library("multcomp")


###################################################
### chunk number 4: TypeIerror
###################################################
typeI <- function(alpha) 1 - (1-alpha)^(1:100)
results <- cbind(typeI(alpha = 0.10), typeI(alpha = 0.05), typeI(alpha = 0.01))
plot(results[,1], type = "l", xlab = "m", ylab = "P(at least one Type I error)", 
     lty = 1, ylim = c(0, 1))
lines(results[,2], lty = 2)
lines(results[,3], lty = 3)
legend(70, 0.2, c(expression(alpha == 0.10), 
       expression(alpha == 0.05), expression(alpha == 0.01)), 
       lty = 1:3, bty = "n")


###################################################
### chunk number 5: thuesen
###################################################
data("thuesen", package = "ISwR")
plot(short.velocity ~ blood.glucose, data = thuesen, xlab = "Blood glucose", 
     ylab = "Velocity")
abline(lm(short.velocity ~ blood.glucose, data = thuesen))


###################################################
### chunk number 6: thuesen:lm
###################################################
thuesen.lm <- lm(short.velocity ~ blood.glucose, 
                  data = thuesen)
summary(thuesen.lm)


###################################################
### chunk number 7: thuesen:mc
###################################################
library("multcomp")
thuesen.mc <- glht(thuesen.lm, linfct = diag(2))
summary(thuesen.mc, test = adjusted(type = "bonferroni"))


###################################################
### chunk number 8: thuesen:mc2
###################################################
summary(thuesen.mc)


###################################################
### chunk number 9: Bias
###################################################
n <- 1
curve(n*dnorm(x)*(pnorm(x))^(n-1), -5, 5, ylim = c(0,1), ylab = "y")
n <- 2
curve(n*dnorm(x)*(pnorm(x))^(n-1), -5, 5, add = T, lty = 2)
n <- 5
curve(n*dnorm(x)*(pnorm(x))^(n-1), -5, 5, add = T, lty = 3)
n <- 10
curve(n*dnorm(x)*(pnorm(x))^(n-1), -5, 5, add = T, lty = 4)
n <- 100
curve(n*dnorm(x)*(pnorm(x))^(n-1), -5, 5, add = T, lty = 5)
legend(-4, 1, c("m = 1", "m = 2", "m = 5", "m = 10", "m = 100"), 
       lty = 1:5, bty = "n")
abline(v = 0, col = "lightgray")

sessionInfo()