Johanna G. Nešlehová Mc , Winter Term 2022
Generalized Linear Models MATH 523 Assignment 2 due on February 16 at noon.
Q1 Lecture 5a
Consider a Poisson GLM with the log link and linear predictor of the form
Copyright By PowCoder代写 加微信 powcoder
ηi=β1+β2ai, i∈{1,…n},
where ai is the value of a factor predictor with two levels, such that ai = 1 for
i∈{1,…n1}andai =0fori∈{n1+1,…,n}.
Suppose that at the beginning of the t-th iteration of the Fisher Scoring algorithm
(formulated as iterative reweighted least squares), we get
β(t+1) = (β(t+1), β(t+1)) = (log y ̄ , log y ̄ − log y ̄ ), 12212
wherey ̄1=1n1 yi,andy ̄2=1n yi. n1 i=1 n2 i=n1 +1
(1) Calculate the remaining part of the iteration step of the algorithm: η(t+1), μ(t+1), z(t+1), W(t+1), D(t+1), and u(t+1).
(2) Does the algorithm terminate after this iteration? Justify your answer.
(3) Did the algorithm find the exact solution after this iteration? Justify your answer.
Q2 Lecture 6a
Consider the Gamma GLM (viz. page 2 of Lecture 3a) with a linear predictor of the form
ηi = β1 + β2xi,
where xi is the value of a continuous predictor corresponding to the ith response.
(1) Calculate the standard error of βˆ1 using (a) the reciprocal link (g(μ) = 1/μ) and (b) the identity link (g(μ) = μ).
(2) Calculate the deviance. Does it depend on the link function? Explain.
Q3 R excercise
Consider the data from the Social Survey on the number of children. This data set contains 3548 observations on the following 6 variables: child (num- ber of children), age (age of the woman in years), dur (years of education), nation (nationality of the woman; 0 = German, 1 = otherwise), god (Belief of the woman in God: 1 = Strong agreement, 2 = Agreement 3 = No definite opinion, 4 = Rather no agreement, 5= No agreement at all 6= Never thougt about it), and univ (whether the woman visited university: 0 = no, 1 = yes).
The dataset is available in the catdata library in R and can be loaded as follows (after having installed the catdata library):
Johanna G. Nešlehová Mc , Winter Term 2022
Generalized Linear Models MATH 523 Assignment 2 due on February 16 at noon.
library(catdata)
## Loading required package: MASS
data(children)
attach(children)
head(children)
## child age dur nation god univ ##6 2339 060 ##10 280 7 0 1 0 ##11 163 8 0 1 0 ##12 282 7 0 1 0 ##13 249 8 0 1 0 ##14 154 9 0 5 0
The data can be used to investigate the effect of age, dur, nation, god and univ on the number of children. Therefore, we will treat child as a response in the analysis below.
(1) Fit a Poisson GLM with the canonical link to the data with child as a response, and age, dur, nation, god and univ as main effects but no interactions and display the summary of the fit.
(2) List the predictors of the model in part (1). For each age, dur, nation, god and univ, decide whether it is a factor or a continuous predictor and determine whether it is significant at the 5% level using appropriate Wald tests.
(3) Using the model fitted in part (1), estimate the expected number of children of a German woman aged 44 with 12 years of education, who did not attend university and is in agreement with the statement that she beliefs in God, along with a two-sided 95% approximate (large-sample) confidence interval.
(4) Fit a Poisson GLM to these data using only the intercept and dur predictors, and the identity link. Why do you think the glm function produced an error mes- sage? Try to fix the problem by supplying starting values to glm using glm(…. start=c( , )).
Due on February 16 at noon.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com