I have a frequency table of claims made by policyholders:
Claims 0, 1, 2, 3, 4 Frequency 2962, 382, 47, 25, 4
And I am going to carry out a chi-squared goodness of fit test to see if it conforms to a Poisson distribution (there are probably far better methods - but I'm teaching basic stats - so go with the flow please).
I converted the frequency table into a vector as follows:
n<-c(0,1,2,3,4) x<-c(2962,382,47,25,4) data <- rep(n,x)
I then fitted a Poisson(mu) as follows:
library(MASS) fitted <-fitdistr(data,"Poisson") mu<-fitted$estimate
I obtained the expected probabilities under this model using:
round(sum(x)*exptd,3) I noticed that the expected frequency of the last two groups were both <5 and so I combined the last three groups together:
I now carried out my chi-squared goodness of fit test:
I have two issues:
- The chi-square test has the wrong degrees of freedom as I estimated a parameter on the data.
- This seems dreadfully long-winded - there must be a quicker way of doing this test.
Unfortunately despite searching I can't find examples of this online (which makes me think that this method isn't used despite what our textbooks say) so I need your help.
Many thanks in advance for the help.