Refer to the discussion of residuals for Poisson models 011 page 288. Demonstrat
ID: 3182653 • Letter: R
Question
Refer to the discussion of residuals for Poisson models 011 page 288. Demonstrate how well the standard normal approximation holds for large residuals from a Poisson model with different means. Specifically, for counts y leftarrow c(0:10), and for mean yhat leftarrow 2: (a) Compute Pearson residuals pear leftarrow (y-yhat)/squareroot (yhat). (b) Compute both the Poisson and the standard normal cumulative probabilities for a larger value than the Pearson residual, pp leftarrow 1-ppois(y, yhat) and pn leftarrow 1-pnorm(pear), respectively. (c) Use cbind(y, pear, pp, pn) to print the results. Compare these probabilities for any Pearson residual above 2, 3, and 4. Are the probabilities similar? Are there any other Pearson residuals below 2 that have probability 0.05? (d) From parts (a)-(c), what can you conclude about interpreting Pearson residuals from models where y^= 2? (e) Repeat these steps for y^= 1, 0.5, 0.25, 0.1. Comment on whether you are comfortable using the above 2, 3, and 4 guidelines to identify large Pearson residuals in these cases.Explanation / Answer
At Yhar =2
a) R-Code:
y=c(0:10)
yhat=2
pear=(y-yhat)/sqrt(yhat)
pear
b) R-Code
pp=1-ppois(y,yhat)
pp
pn=1-pnorm(pear)
pn
c) R-Code
cbind(y,pear,pp,pn)
> cbind(y,pear,pp,pn)
y pear pp pn
[1,] 0 -1.4142136 8.646647e-01 9.213504e-01
[2,] 1 -0.7071068 5.939942e-01 7.602499e-01
[3,] 2 0.0000000 3.233236e-01 5.000000e-01
[4,] 3 0.7071068 1.428765e-01 2.397501e-01
[5,] 4 1.4142136 5.265302e-02 7.864960e-02
[6,] 5 2.1213203 1.656361e-02 1.694743e-02
[7,] 6 2.8284271 4.533806e-03 2.338867e-03
[8,] 7 3.5355339 1.096719e-03 2.034760e-04
[9,] 8 4.2426407 2.374473e-04 1.104525e-05
[10,] 9 4.9497475 4.649808e-05 3.715492e-07
[11,] 10 5.6568542 8.308224e-06 7.708629e-09
d) There are any other pearson residuals below 2 that have probability < 0.05,
At Yhar =1
R-Code:
a)
y=c(0:10)
yhat=1
pear=(y-yhat)/sqrt(yhat)
pear
b) R-Code
pp=1-ppois(y,yhat)
pp
pn=1-pnorm(pear)
pn
c) R-Code
cbind(y,pear,pp,pn)
> cbind(y,pear,pp,pn)
y pear pp pn
[1,] 0 -1 6.321206e-01 8.413447e-01
[2,] 1 0 2.642411e-01 5.000000e-01
[3,] 2 1 8.030140e-02 1.586553e-01
[4,] 3 2 1.898816e-02 2.275013e-02
[5,] 4 3 3.659847e-03 1.349898e-03
[6,] 5 4 5.941848e-04 3.167124e-05
[7,] 6 5 8.324115e-05 2.866516e-07
[8,] 7 6 1.024920e-05 9.865877e-10
[9,] 8 7 1.125203e-06 1.279865e-12
[10,] 9 8 1.114255e-07 6.661338e-16
[11,] 10 9 1.004777e-08 0.000000e+00
d) There are any other pearson residuals below 2 that have probability < 0.05,
At Yhar = 0.5
R-Code:
a)
y=c(0:10)
yhat=0.5
pear=(y-yhat)/sqrt(yhat)
pear
b) R-Code
pp=1-ppois(y,yhat)
pp
pn=1-pnorm(pear)
pn
c) R-Code
cbind(y,pear,pp,pn)
> cbind(y,pear,pp,pn)
y pear pp pn
[1,] 0 -0.7071068 3.934693e-01 7.602499e-01
[2,] 1 0.7071068 9.020401e-02 2.397501e-01
[3,] 2 2.1213203 1.438768e-02 1.694743e-02
[4,] 3 3.5355339 1.751623e-03 2.034760e-04
[5,] 4 4.9497475 1.721156e-04 3.715492e-07
[6,] 5 6.3639610 1.416494e-05 9.830803e-11
[7,] 6 7.7781746 1.002380e-06 3.663736e-15
[8,] 7 9.1923882 6.219691e-08 0.000000e+00
[9,] 8 10.6066017 3.435490e-09 0.000000e+00
[10,] 9 12.0208153 1.709669e-10 0.000000e+00
[11,] 10 13.4350288 7.740697e-12 0.000000e+00
d) There are any other pearson residuals below 2 that have probability < 0.05,
At Yhat = 0.25
R-Code:
a)
y=c(0:10)
yhat=0.25
pear=(y-yhat)/sqrt(yhat)
pear
b) R-Code
pp=1-ppois(y,yhat)
pp
pn=1-pnorm(pear)
pn
c) R-Code
cbind(y,pear,pp,pn)
> cbind(y,pear,pp,pn)
y pear pp pn
[1,] 0 -0.5 2.211992e-01 6.914625e-01
[2,] 1 1.5 2.649902e-02 6.680720e-02
[3,] 2 3.5 2.161497e-03 2.326291e-04
[4,] 3 5.5 1.333697e-04 1.898956e-08
[5,] 4 7.5 6.611711e-06 3.186340e-14
[6,] 5 9.5 2.738136e-07 0.000000e+00
[7,] 6 11.5 9.734522e-09 0.000000e+00
[8,] 7 13.5 3.031274e-10 0.000000e+00
[9,] 8 15.5 8.396284e-12 0.000000e+00
[10,] 9 17.5 2.093881e-13 0.000000e+00
[11,] 10 19.5 4.773959e-15 0.000000e+00
d) There are any other pearson residuals below 2 that have probability < 0.05,
At Yhat = 0.10
R-Code:
a)
y=c(0:10)
yhat=0.10
pear=(y-yhat)/sqrt(yhat)
pear
b) R-Code
pp=1-ppois(y,yhat)
pp
pn=1-pnorm(pear)
pn
c) R-Code
cbind(y,pear,pp,pn)
> cbind(y,pear,pp,pn)
y pear pp pn
[1,] 0 -0.3162278 9.516258e-02 6.240852e-01
[2,] 1 2.8460499 4.678840e-03 2.213263e-03
[3,] 2 6.0083276 1.546531e-04 9.372342e-10
[4,] 3 9.1706052 3.846834e-06 0.000000e+00
[5,] 4 12.3328829 7.667802e-08 0.000000e+00
[6,] 5 15.4951605 1.274899e-09 0.000000e+00
[7,] 6 18.6574382 1.818012e-11 0.000000e+00
[8,] 7 21.8197159 2.269296e-13 0.000000e+00
[9,] 8 24.9819935 2.442491e-15 0.000000e+00
[10,] 9 28.1442712 0.000000e+00 0.000000e+00
[11,] 10 31.3065488 0.000000e+00 0.000000e+00
d) There are any other pearson residuals below 2 that have probability < 0.05,
a) R-Code:
y=c(0:10)
yhat=2
pear=(y-yhat)/sqrt(yhat)
pear
b) R-Code
pp=1-ppois(y,yhat)
pp
pn=1-pnorm(pear)
pn
c) R-Code
cbind(y,pear,pp,pn)
> cbind(y,pear,pp,pn)
y pear pp pn
[1,] 0 -1.4142136 8.646647e-01 9.213504e-01
[2,] 1 -0.7071068 5.939942e-01 7.602499e-01
[3,] 2 0.0000000 3.233236e-01 5.000000e-01
[4,] 3 0.7071068 1.428765e-01 2.397501e-01
[5,] 4 1.4142136 5.265302e-02 7.864960e-02
[6,] 5 2.1213203 1.656361e-02 1.694743e-02
[7,] 6 2.8284271 4.533806e-03 2.338867e-03
[8,] 7 3.5355339 1.096719e-03 2.034760e-04
[9,] 8 4.2426407 2.374473e-04 1.104525e-05
[10,] 9 4.9497475 4.649808e-05 3.715492e-07
[11,] 10 5.6568542 8.308224e-06 7.708629e-09
d) There are any other pearson residuals below 2 that have probability < 0.05,