0
$\begingroup$

I am trying to determine how well a Poisson model fits my data using Residual Null and Saturated Deviances. The Y col is the # of pennies that landed in a cup and the cup column represents the size. This is the R-code I have so far.

Y=c(4,7,2,5,4,5,10,6,8,2,9,9,9,7,10)
Cup=c(0,2,0,0,0,1,1,1,2,1,2,0,2,1,2)

sum(Y)
M1=glm(Y~Cup,family="poisson")
M1$deviance

SaturatedProbs=dpois(Y,Y)
SaturatedProbs
Ls=prod(SaturatedProbs)
Ds=-2*log(Ls)
Ds

#NullProbs
ln=sum(Y)/length(Y)
probsn=dpois(Y,ln)
Ln=prod(probsn)
Ln
Dn=-2*log(Ln)
Dn

Dn-Ds

Ultimately, I want to compare my model to a chi_square distribution. I am having some trouble determining the appropriate inputs. Is what I have so far enough to determine the goodness-of-fit?

$\endgroup$

1 Answer 1

1
$\begingroup$

You would need the deviances and the degrees of freedom to perform a deviance test. If the model fits the data well then $D_1 \sim \chi^2(n-p)$ and $D_2 \sim \chi^2(n-q)$. $D_1$ and $D_2$ are deviances for model 1 and model 2. $n$ is the number of parameters for saturated model. $p$ and $q$ are the number of parameters for given models ($q < p < n$)

Deviance test:

$$D_1 - D_2 \sim \chi^2(p-q)$$

If value is greater than expected from chi squared, reject model 1.

$\endgroup$
1
  • $\begingroup$ Okay so, please correct me if I am wrong but I am comparing my null model, which only contains 1 parameter, with my fitted model, which contains 2 parameters? The deviance for my null model is Dn=72, the deviance for the saturated model is Ds=54, and the residual deviance for the fitted model is Dr=12. I am looking at the drop in deviance of my null model to my fitted model. I have Dn-((Dn-Ds)-Dr) or 72-(17-12) = 66. Is this mathematically sound so far? How again does this look on the chi_sq distribution with 13 degrees of freedom? Do I simply compare this to my cut off at 0.05? $\endgroup$
    – hwhorf
    Jun 4, 2018 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.