Hi Nicholas,
Thanks for the support.
The expected result is something like:
pval_mu = something aprox to 0, but no 0.0
chisq_mu = a positive value
df_mu = 21 (not a value of interest);
running the same data, I get the following:
pval_mu = NaN
chisq_mu = NaN
df_mu = 21
looking at the function (you can type 'edit chisquare_test_homogeneity' to open m-file functions and step through the code)
df is just the length of c, so df = 21
chisq gives NaN because the values used for d1 and c, and also d2 and c, produce a divide by zero error. See the operations performed on lines 55, 58, and then 59.
I don't know the chisquare test operation well enough to identify any errors in the code, but essectially the values of c are very small relative to the d1 and d2 values, producing zeros for the internal variables n_x and n_y. divide by (n_x+n_y) appears in the chisq calculation, so this obviously is a divide by zero error, or NaN.
I have access to a copy of matlab and it appears they do not have this function. Can you point to some other implementation of the test that we can compare results?