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]:
III
1159
22518
33229
41728
51116

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]:
J
2
nj.I
100
nj.II
100
n
200
k
5

In [4]:
pi <- 1/n * rowSums(data)
pi


Out[4]:
  1. 0.12
  2. 0.215
  3. 0.305
  4. 0.225
  5. 0.135

In [5]:
QI <- sum((data$I - nj[1]*pi)^2/(nj[1]*pi))
QI


Out[5]:
3.20094534107115

In [6]:
QII <- sum((data$II - nj[2]*pi)^2/(nj[2]*pi))
QII


Out[6]:
3.20094534107115

In [7]:
Q <- QI + QII
Q


Out[7]:
6.4018906821423

In [8]:
qchisq(1-alpha, (J-1)*(k-1))


Out[8]:
9.48772903678115

$Q \ngtr \chi^2 \implies$ H0 wird nicht verworfen