ST758 -- Fall 2011 Homework #5 -- due Tuesday, 25 October 2011 (revised 15,17,20 October) Exercises in Textbook: (*just turn in these) 9.13*, but use matrices a) matrix(c(4,3,3,4),2,2) and b) matrix(c(2,-1,-1,1),2,2). Compare by taking a few starting points away from the origin and look at the distance of the iterates from the origin (solution). 9.15 R Exercises: In the files 'gardner1.dat' and 'gardner2.dat' are data from a study of gallery construction by pine beetles. Rows (observations) are galleries (dug by beetles); columns are X1i = temperature (1 or 2) X2i = treatment (1 or 2) ai = length of galllery Yi = number of egg niches stuff = something to be ignored for now Theory says that the number of egg niches should be Poisson with a rate proportional to the length; researchers are interested on whether the temperature or treatment has an effect. *1) Fit a Poisson regression model with rate lambdai = ai * exp(beta0 + beta1*X1i + beta2*X2i) so si = ai = intensity, X1i and X2i are the covariates. Perform a likelihood ratio test of H: beta1=beta2=0 against the alternative that either or both are not zero at level 0.05. (Write a function to compute the (un-)log-likelihood, and minimize it using nlm. You can use 'glm' only to check.) *2) Fit a nonlinear regression model with mean lambdai as above, but with variances also lambdai. So the goal is to minimize a nonlinear generalized least squares, or minimize the sum of squares of Yi/sqrt(lambdai) - sqrt(lambdai) Again test the same hypothesis that the covariates have no effect, using a LRT (F test with SSE(Reduce) and SSE(Full)) at level 0.05. (Use 'nls' here.) *3) Compute sandwich standard errors using the C4 expression on p.246. (You can drop the T(betahat) terms to simplify.) Which file to use? If you were born on an odd day of the month, use 'garder1.dat' and use 'gardner2.dat' for even. Files are in rfiles directory.