In [1]:
alpha <- 0.05
In [2]:
data <- data.frame(B1=c(10, 11, 6), B2=c(21, 27, 19), B3=c(15, 21, 27), B4=c(6, 13, 24),
row.names=c("A1", "A2", "A3"))
data
Out[2]:
In [3]:
a <- nrow(data)
b <- ncol(data)
n <- sum(data)
c(a, b, n)
Out[3]:
In [4]:
p_i <- 1/n * rowSums(data)
p_i
Out[4]:
In [5]:
p_j <- 1/n * colSums(data)
p_j
Out[5]:
In [6]:
p_i <- 1/n * rowSums(data)
p_i
Out[6]:
In [7]:
p_ij <- p_i %*% t(p_j)
p_ij
Out[7]:
In [8]:
Q_ij <- (data - n*p_ij)^2/(n * p_ij)
Q_ij
Out[8]:
In [9]:
sum(Q_ij)
Out[9]:
In [10]:
qchisq(1-alpha, (a-1)*(b-1))
Out[10]:
$Q > \chi^2 \implies$ H0 wird verworfen