In [1]:
alpha <- 0.05
In [2]:
data <- data.frame(I=c(15, 25, 32, 17, 11), II=c(9, 18, 29, 28, 16))
data
Out[2]:
In [3]:
J <- length(data)
nj <- colSums(data)
n <- sum(nj)
k <- nrow(data)
c(J=J, nj=nj, n=n, k=k)
Out[3]:
In [4]:
pi <- 1/n * rowSums(data)
pi
Out[4]:
In [5]:
QI <- sum((data$I - nj[1]*pi)^2/(nj[1]*pi))
QI
Out[5]:
In [6]:
QII <- sum((data$II - nj[2]*pi)^2/(nj[2]*pi))
QII
Out[6]:
In [7]:
Q <- QI + QII
Q
Out[7]:
In [8]:
qchisq(1-alpha, (J-1)*(k-1))
Out[8]:
$Q \ngtr \chi^2 \implies$ H0 wird nicht verworfen