$25
This homework is optional. You do NOT need to turn it in. However, if you turn it in, the score can be used to replace the lowest value of those contributing homework scores if it is lower than the score of HW #9. Precisely, including HW#0 and the two optional HWs, the highest 7 scores will be used to calculate your final homework score.
1. Consider Problem #6 on page 233 of Chap. 15 and the description of the dataset ’butterfat’: ’Average butterfat content (percentages) of milk for random samples of twenty cows (ten twoyear old and ten mature (greater than four years old)) from each of five breeds.’ Use the butterfat data with ‘Butterfat’ as the response, ’Breed’ as the predictor, and only consider the ’Mature’ (see ’Age’) subset. Answer 6 (b), 6 (c) and 6 (d). Note: for 6 (d), after saving the results from “TukeyHSD”, you can plot these intervals as shown on pages 229-230 in the textbook.
2. Use the pima data and the codes below to answer the questions.
library(faraway) data(pima) pima$diastolic[pima$diastolic == 0] <- NA pima$glucose[pima$glucose == 0] <- NA pima$triceps[pima$triceps == 0] <- NA pima$insulin[pima$insulin == 0] <- NA pima$bmi[pima$bmi == 0] <- NA pima.dat <- pima pregn <- rep("common", length(pima$pregnant)) pregn[pima.dat$pregnant>=10] <- "high" pima.dat$pregn <- pregn test.out <- glm(test~pregnant+ glucose+bmi+diabetes+pregnant:glucose,family=binomial,pima.dat) test2.out<-glm(test~pregn+ glucose+bmi+diabetes+pregn:glucose,family=binomial,pima.dat)
summary(test.out) summary(test2.out)
(a) Provide the model that corresponds to “test.out” in the R-codes above.
(b) Suppose you are interested to learn whether a higher level of bmi would lead to a higher chance of showing signs of diabetes using the model in the problem above. What would be the H0 and Ha? Describe your test result and conclusion.
(c) In “test2.out”, we are interested at learning whether the association between glucose level and the chance of showing signs of diabetes changes with two levels of times being pregnant: common/regular and high. Comment on what you find.