[R] goodfit() in vcd package: computation of chi-squared

Boris.Vasiliev at forces.gc.ca Boris.Vasiliev at forces.gc.ca
Thu Jul 23 16:26:31 CEST 2009


I have troubles understanding how goodfit() function in the vcd package
computes  the Pearson coefficient.  Can anybody provide more information
on the computation?

In particular, for HorseKicks data in vcd package, goodfit() yields

> oo <- goodfit(HorseKicks,type="poisson",method="MinChisq")
> summary(oo)

         Goodness-of-fit test for poisson distribution

             X^2 df  P(> X^2)
Pearson 0.594649  3 0.8976563
Warning message:
In summary.goodfit(oo) : Chi-squared approximation may be incorrect

However, if I compute the Pearson coefficient by hand, I get a different
value for chi-squared

> with(oo, sum( (observed-fitted)^2/fitted ))
[1] 0.694577

I am not sure where I am making a mistake.  Any suggestions?

Regards,
Boris.




More information about the R-help mailing list