In: Math
Part (1)
Consider the data in the above table for number of pets in 100 households. Do the following:
1
Number of Pets |
0 |
1 |
2 |
3 |
4+ |
Count |
19 |
26 |
29 |
13 |
13 |
– Use the R command chisq.test to test whether the data can be fitted by a Poisson model with α = 0.05. Report the p-value and the number of degrees of freedom from your test.
– Are there any corrections necessary and if so why?
– How would you update the code to include these corrections and what is
the new p-value obtained?
Use the R-builtin function dpois to calculate the Poisson probabilities.
Part (2)
Run install.packages(”MASS”) to install the MASS library. Do the follow- ing:
– For the data frame survey in this package first remove any NA values with the command survey = na.omit(survey). Following that consider the 2 categorical variables Sex and Exer in survey. How many different types of values does Exer take?
– Use the R command chisq.test to test whether there is an association between these variables with α = 0.05. Report the p-value obtained.
– Remove the level Freq for the variable Exer and report the p-value ob- tained by running chisq.test between Sex and Exer.