-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSR_Lab_9.R
More file actions
33 lines (24 loc) · 771 Bytes
/
Copy pathMSR_Lab_9.R
File metadata and controls
33 lines (24 loc) · 771 Bytes
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
### MSR - LAB 9
rm(list=ls())
# Przyk³ad 9.1
pigs <- ToothGrowth
pigs$dose <- as.factor(pigs$dose)
table(pigs$supp, pigs$dose)
library(ggplot2)
theme_set(theme_bw())
g <- ggplot(pigs)
g + geom_boxplot(aes(x=dose, y=len, color=supp)) + labs(x="dose [mg/day]", y="length of cells", color="Suppl. type")
# ANOVA z interakcjami, obie komendy poni¿ej s¹ równowa¿ne
pigs.aov <- aov(len ~ supp+dose+supp:dose, data=pigs)
pigs.aov <- aov(len ~ supp*dose, data=pigs)
print(summary(pigs.aov))
HSDpig <- TukeyHSD(pigs.aov, which = "dose")
print(HSDpig)
library(car)
AnovaPig <- Anova(pigs.aov, type="III")
print(AnovaPig)
# Przyk³ad 9.2
irysy <- iris
cor(irysy[,-5])
irysy.maov <- manova(cbind(Sepal.Length, Petal.Length) ~ Species, data = irysy)
print(summary(irysy.maov))