TU Wien:Statistik und Wahrscheinlichkeitstheorie UE (Levajkovic)/Übungen 2023W/HW11.5

Aus VoWi
Zur Navigation springen Zur Suche springen
-test for independence (with R)
(a) Solve the previous exercise using R.
(b) Can you also reject for a significance level of ?
(c) Double observed frequencies in each cell and perform the test on the 0.1% level. Did the decision change comparing to the one from (b)?
Dieses Beispiel ist als solved markiert. Ist dies falsch oder ungenau? Aktualisiere den Lösungsstatus (Details: Vorlage:Beispiel)


Lösungsvorschlag von Lessi[Bearbeiten | Quelltext bearbeiten]

--Lessi 2024-02-07T13:04:11Z

# a)

data <- matrix(c(15, 10, 5, 10, 20, 15, 20, 10, 15), nrow=3, ncol=3, byrow=TRUE, dimnames=list(c("calc", "alg", "prob"), c("A", "B", "C")))
alpha <- 0.05

sum(data)

test <- chisq.test(data)
test

p <- test$p.value

p > alpha

# b) for 0.1% significance we would not reject the null 

p > 0.001

# c)

data2 <- data * 2
alpha2 <- 0.001

test2 <- chisq.test(data2)
test2

p2 <- test2$p.value

p2 > alpha2

# the decision changed we now reject the null. seems correct as with larger samples we can make more accurate decisions