Homework 14: Conduct a simulation study in R to confirm the null distribution of the chi-square test of homogeneity by doing the following: 1. Draw two multinomials of size n1=873 and n2=624 from p=((.302,.566,.091,.041)) 2. Compute chi-square test statistic for homogeneity 3. Repeat 10000 times 4. Compare histogram with the pdf of chi-square with 3 df Below is portion of R session to start you out. ***************************************************************** > p<-c(.302,.566,.091,.041) > p [1] 0.302 0.566 0.091 0.041 > x<-rmultinom(10,873,p) #### 10 reps of x-sample > x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 253 267 259 242 241 249 255 277 259 261 [2,] 508 503 493 516 505 492 501 483 511 487 [3,] 86 77 84 80 89 92 79 72 78 88 [4,] 26 26 37 35 38 40 38 41 25 37 > y<-rmultinom(10,624,p) #### 10 reps of y-sample > y [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 178 175 194 180 174 207 182 187 175 210 [2,] 374 366 337 355 377 349 363 350 346 327 [3,] 51 60 64 65 49 45 57 63 68 69 [4,] 21 23 29 24 24 23 22 24 35 18 > xy<-cbind(x[,1],y[,1]) #### Calculate chi-square test-statistic for first columns > chisq.test(xy)$statistic X-squared 1.507721