Chi-square test with 2 bins, why do I get P = nan ?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I would like to use chi-square statistical test with just two bins. Everything seems fine in the table, but the p value is nana and degree of freedom is 0. p value is different from nan when the number of bins is hgher than 3. For bins=4 degree of freedom is 1. Why is it so?
e.g. [h,p,stats] = chi2gof(rand(1,1000),'nbins',2)
chi2stat: 0.0130
df: 0
edges: [0.0012 0.5003 0.9995]
O: [489 511]
E: [490.8038 509.1962]
thanks
0 Commenti
Risposte (1)
Tom Lane
il 28 Nov 2012
The default for chi2gof is to test against the normal distribution, estimate the parameters, and deduct the number of estimated parameters from the degrees of freedom.
Compare these:
x = randn(100,1);
[h,p,stats] = chi2gof(x,'nbins',2)
[h,p,stats] = chi2gof(x,'nbins',2,'cdf',@normcdf)
The first is what you tried. The second tests against the standard normal distribution (parameters fixed at mu=0 and sigma=1), so it doesn't lose any degrees of freedom by estimating the parameters. You will probably see that the chi-square statistic is higher for the latter, because the estimation process tends to reduce the statistic compared with pre-specified values.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!