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

MTH 303

Linear Statistical Models

2023-2024 S1

Task 2(50 marks)

A statistician wants to model the total number of customers at one Caffe Nero situated on Oxford Road in Manchester between 8 am and 8:15 am.They can think of three explanatory variables:if it is rainy or not,if it is during the  semester or not,and the temperature(temp)  in degrees Celsius.The statistician has data for 28 days,given in the file named nero.RData, and believes that the response variable(Customer)follows a Poisson distribution.

1.Loading  the  data  into  R.                                                                                              (2 marks)

2.State    the    linear    predictor    corresponding    to    models    specified    with    the    following    R    code,

explaining    all    relevant    terms:

(a)temp+semester

(b)temp*semester

(c)temp*semester +rainy (8 marks)

3.Fit a Poisson Generalized Linear Model (GLM)with log link to the data set for the model in part 2(c).Label this model  as Model1.Comment  on the  significance  of the  parameters  based on the summary of the fitted model.         (9  marks)

4.Fit an improved model by substracting non-significant variable(s)based on your analysis

in  3.Label this  improved model  as  Model2.                                                             (3  marks)

5.Justify why Model2  improves Modell by referring to the R output.                     (4 marks)

6.You  are  given  a  new  Poisson  GLM(Model3)with  log  link  function,specified  by  the following R code:

temp+temp*semester

(a)Justify why Model3 outperforms Modell and Model2 by referring to the R output. (4 marks)

(b)Use  plot  function  to  draw“Residuals  vs.Fits”plot,for  the  residuals  of  Model3,and comment on the validity of Model3.       (8 marks)

(c)Quantile  residuals  are  the  useful  residuals  of  choice  for  generalized  linear  models.  Make  Q-Q  plot  with  quartile  residuals  and  comment  on  it.(Hint:you  may  need  to install  statmod package first.)                             (8 marks)

(d)Use R to calculate the predicted total number of customers during the semester at rainy day with a temperature of 0 degree Celsius,using Model3.          (4 marks)