# Für die Durchführung eines Anovas wird immer folgendes benötigt
library(ez)
source(file.path(pfadu, "phoc.txt"))

# S. 9
b = read.table(file.path(pfadu,"bet.txt"))
# das gleiche in Lang-Format
blang  = read.table(file.path(pfadu, "blang.txt"))
b
head(blang)

# S. 10
d = b$betont - b$unbetont
boxplot(d)
abline(h=0)

t.test(d)

# S. 11
ezANOVA(blang, .(F2), .(Vpn), .(Betonung))

# S. 12
v.df = read.table(file.path(pfadu,"vokal.txt"))
head(v.df)

# S. 13
boxplot(F2 ~ Sprache, data = v.df)
t.test(F2 ~ Sprache, data = v.df)

ezANOVA(v.df, .(F2), .(Vpn), between = .(Sprache))

# S. 15
leveneTest(F2 ~ Sprache, data = v.df)
t.test(F2 ~ Sprache, data = v.df, var.equal=T)

# S. 16
dg = read.table(file.path(pfadu, "dg.txt"))
head(dg)
names(dg)
table(dg$Gen, dg$Region)


# S. 18
par(mfrow = c(1,2))
boxplot(F2 ~ Gen * Region, data = dg)
with(dg, interaction.plot(Region, Gen, F2))

# S. 19
ezANOVA(dg, .(F2), .(Vpn), between=.(Region, Gen))

# S. 21
vok.ph = phoc(dg, .(F2), .(Vpn), .(Region, Gen))

# S. 24
vok.ph = phoc(vok, .(F2), .(Vpn), .(Vokal, Gen))
phsel(vok.ph$res)
phsel(vok.ph$res, 2)

# S. 25
p1 = phsel(vok.ph$res)
round(p1, 3)

p2 = phsel(vok.ph$res, 2)
round(p2, 3)

