1
$\begingroup$

I have a set of observations obs.

If I plot the histogram of the observation I see that they could come from a gamma distribution

[counts,x] = hist(obs,[1:max(obs)]);

I would like to prove it using chi square goodness of fit.

So I first estimate the gamma parameters

paramEsts = fitdist(obs,'Gamma');  

and the use chi2gof to see if the hypotesis is true (h=0).

[h,p] = chi2gof(obs,'CDF',paramEsts)

My problem is that I get a p = NaN...how is it possible? Where is my mistake? Thanks

to test it please download the obs.mat file https://drive.google.com/file/d/0B3vXKJ_zYaCJbHU2SHhac29MRms/view?usp=sharing

$\endgroup$

1 Answer 1

1
$\begingroup$

I did not download your data file, but try getting the third output from chi2gof. Is its degrees of freedom (df) field positive?

The degrees of freedom for a pre-specified distribution is equal to the number of bins minus 1. For a distribution that is estimated from the data, the chi2gof function also deducts the number of estimated parameters in an attempt to compensate for the fact that the distribution is "too close" to the data. This can lead to df values that are 0 or negative if the number of bins is small.

$\endgroup$

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.