Universit´e Joseph Fourier L2/STA230
Lab 11: Chi-squared tests
Objectives: Compute chi-squared goodness-of-fit test and chi-squared test for independence.
1 Chi-squared goodness-of-fit test
Exercise 1We want to realize a goodness-of-fit test to establish whether or not the empirical distribution of the weights differs from the binomial distribution.
1. Upload the datasetHER, assign toAthe arm circumference column.
2. Create a discrete vectorDAwith values 0 if the circumference is less than 29, 1 if the circumference is between 29 and 34, 2 if the circumference is between 34 and 38, 3 if between 38 and 42, and 4 otherwise.
3. Is the distribution of the arm conference compatible with theB(4,0.2) ?
(a) Give the assumptionsH0andH1of the goodness-of-fit test. Give the statistic and the decision rule of this test.
(b) Compute the theoretical distribution table of the binomial distributionB(4,0.2).
(c) Apply the test withchisq.test.
4. Is the distribution of the arm conference compatible with theB(4,0.3) ?
5. Is the distribution of the arm conference compatible with the distribution (0.2,0.4,0.3,0.07,0.03) ?
2 Chi-squared test for independence
Exercise 1
1. Upload the datasetHER.
2. We want to test if there is independence between girls and boys BMI.
(a) Compute the proportion of patients with a BMI lower (or equal) than 24. Same question for only girls, and for only boys.
(b) We want to test if the proportion of patients with a low BMI is significantly larger among girls than among boys.
i. Give the assumptions H0 andH1of the independence test.
ii. Give the statistic and the decision rule of this test.
iii. Apply the test with the functionchisq.test.
iv. Compare with the Fisher test fisher.test.
v. Conclude and comment.
3. We want to test if the proportion of patients with a low BMI is significantly larger among treated patients than among non treated patients.