-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab 4-B.R
68 lines (54 loc) · 1.53 KB
/
Lab 4-B.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
## settig up the dat frame
Chemical <- read.csv(file.choose(), header = TRUE)
Chemical
Day <- factor(Day)
Batch <- factor(Batch)
means <- tapply(Time, Day, mean)
means
Vars <- tapply(Time, Day, var)
Vars
Sdv <- tapply(Time, Day, sd)
Sdv
mean <- tapply(Time, Batch, mean)
## Building Linear Model
ingre.aov <- aov(Time ~ Day+Batch)
summary.aov(ingre.aov)
## the ingredients affect reaction time
model.tables(ingre.aov, type="effects")
## Day1 against Batch1 has a significant different of -0.68 and batch 0.72
model.tables(ingre.aov, type = "means")
tukey <- TukeyHSD(ingre.aov)
plot(tukey)
## check for interaction
interaction.plot(Day, Batch, Time)
res <- residuals(ingre.aov)
qqnorm(res)
qqline(res)
## No. 2 Engineering
Engineering <- read.csv(file.choose(), header = TRUE)
Engineering
Operator <- factor(Operator)
Assembly <- factor(Assembly)
tapply(time, Operator, mean)
tapply(time, Operator, var)
tapply(time, Operator, sd)
## linear model, using aov()
engineering.aov <- aov(time ~ Operator+Assembly)
summary(engineering.aov)
## the effects taken for the operator, assembly time
model.tables(engineering.aov, type = "effects")
model.tables(engineering.aov,, type = "means")
## check for interaction
interaction.plot(Operator, Assembly, time)
tuk <- TukeyHSD(engineering.aov)
plot(tuk)
## Residual check:
residu <- residuals(engineering.aov)
residu
qqnorm(residu)
qqline(residu)
plot(residu,time)
plot(residu, Operator)
plot(residu,time)
plot(time~Assembly)
plot(time~ Operator)