88 lines
2.9 KiB
R
88 lines
2.9 KiB
R
|
|
# ZAD1
|
|
dane <- read.table("http://ls.home.amu.edu.pl/data_sets/kontekst.txt")
|
|
colnames(dane) <- c("number", "context")
|
|
|
|
# Transform from text type to categorical type
|
|
dane$context <- as.factor(dane$context)
|
|
aggregate(dane$number, list(CONTEXT = dane$context), FUN = mean)
|
|
boxplot(number ~ context, data = dane, xlab = "Kontekst", ylab = "Words number")
|
|
|
|
summary(aov(number ~ context, data = dane))
|
|
|
|
rests <- lm(number ~ context, data = dane)$residuals
|
|
shapiro.test(rests)$p.value
|
|
qqnorm(rests)
|
|
qqline(rests)
|
|
bartlett.test(number ~ context, data = dane)$p.value
|
|
fligner.test(number ~ context, data = dane)$p.value
|
|
# library(car)
|
|
leveneTest(number ~ context, data = dane)[[3]][1]
|
|
leveneTest(number ~ context, data = dane, center = "mean")[[3]][1]
|
|
|
|
attach(dane)
|
|
pairwise.t.test(number, context, data = dane)
|
|
model_aov <- aov(number ~ context, data = dane)
|
|
TukeyHSD(model_aov)$context
|
|
plot(TukeyHSD(model_aov))
|
|
# install.packages("agricolae")
|
|
# library(agricolae)
|
|
HSD.test(model_aov, "context", console = TRUE)
|
|
SNK.test(model_aov, "context", console = TRUE)
|
|
LSD.test(model_aov, "context", p.adj = "holm", console = TRUE)
|
|
scheffe.test(model_aov, "context", console = TRUE)
|
|
|
|
C1 <- c(-3, 2, 2, -3, 2)
|
|
C2 <- c(0, -1, -1, 0, 2)
|
|
C3 <- c(0, 1, -1, 0, 0)
|
|
C4 <- c(1, 0, 0, -1, 0)
|
|
con <- cbind(C1, C2, C3, C4)
|
|
contrasts(dane$context) <- con
|
|
model_aov_2 <- aov(number ~ context, data = dane)
|
|
summary(model_aov_2, split = list(context = list('C1' = 1, 'C2' = 2, 'C3' = 3, 'C4' = 4)))
|
|
|
|
# ZAD2
|
|
dane <- read.table("http://ls.home.amu.edu.pl/data_sets/Eysenck.txt", header = TRUE)
|
|
dane$Nr <- NULL
|
|
|
|
dane$Instrukcja <- as.factor(dane$Instrukcja)
|
|
aggregate(dane$Wynik, list(CONTEXT = dane$Instrukcja), FUN = mean)
|
|
boxplot(Wynik ~ Instrukcja, data = dane, xlab = "Instrukcja", ylab = "Wynik")
|
|
|
|
summary(aov(Wynik ~ Instrukcja, data = dane))
|
|
|
|
rests <- lm(Wynik ~ Instrukcja, data = dane)$residuals
|
|
shapiro.test(rests)$p.value
|
|
qqnorm(rests)
|
|
qqline(rests)
|
|
bartlett.test(Wynik ~ Instrukcja, data = dane)$p.value
|
|
fligner.test(Wynik ~ Instrukcja, data = dane)$p.value
|
|
# library(car)
|
|
leveneTest(Wynik ~ Instrukcja, data = dane)[[3]][1]
|
|
leveneTest(Wynik ~ Instrukcja, data = dane, center = "mean")[[3]][1]
|
|
|
|
attach(dane)
|
|
pairwise.t.test(Wynik, Instrukcja, data = dane)
|
|
model_aov <- aov(Wynik ~ Instrukcja, data = dane)
|
|
TukeyHSD(model_aov)$Instrukcja
|
|
plot(TukeyHSD(model_aov))
|
|
# library(agricolae)
|
|
HSD.test(model_aov, "Instrukcja", console = TRUE)
|
|
SNK.test(model_aov, "Instrukcja", console = TRUE)
|
|
LSD.test(model_aov, "Instrukcja", p.adj = "holm", console = TRUE)
|
|
scheffe.test(model_aov, "Instrukcja", console = TRUE)
|
|
|
|
C1 <- c(0, 1, -1, 1, -1)
|
|
C2 <- c(4, -1, -1, -1, -1)
|
|
C3 <- c(0, 1, 0, -1, 0)
|
|
C4 <- c(0, 0, -1, 0, 1)
|
|
con <- cbind(C1, C2, C3, C4)
|
|
contrasts(dane$Instrukcja) <- con
|
|
contrasts(dane$Instrukcja)
|
|
model_aov_2 <- aov(Wynik ~ Instrukcja, data = dane)
|
|
summary(model_aov_2, split = list(Instrukcja = list('C1' = 1, 'C2' = 2, 'C3' = 3, 'C4' = 4)))
|
|
|
|
|
|
|
|
|