Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Generalized Linear Models MATH 523

Winter Term 2022

Assignment 2

Q1 Lecture 5a

Consider a Poisson GLM with the log link and linear predictor of the form

ηi  = β1 + β2 ai ,    i e {1, . . . n},

where ai   is the value of a factor predictor with two levels,  such that  ai   =  1 for i e {1, . . . n1 } and ai  = 0 for i e {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 2 , log y¯1 - log y¯2 ),


where y¯1  =


1 yi , and y¯2  =


i=n1 +1 yi .


(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 + β2 xi ,

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 German General 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):


library(catdata)


##  Loading  required package:    MASS

data(children)

attach(children)

head(children)


##       child  age  dur nation  god univ

##  6           2    33     9           0     6       0

##  10         2    80     7           0      1       0

##  11          1    63     8           0      1       0

##  12         2    82     7           0      1       0

##  13         2   49     8           0      1       0

##  14          1    54     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(  ,  )).