# CHITEST gives different P value

I’ve got 2 columns of numbers (showing here in rows):

20 20 30 40 60 30

30 14 34 45 57 20

Running the CHITEST function from menu ( Data / Statistics / Chi-square Test… ) it gives a P value of 0.33.

Running the function manually ( CHITEST(A1:A6, B1:B6) ) gives a P value of 0.03. I can reproduce the difference with other data as well.

I can see that the menu version has more functions in the CHITEST arguments like transpose and others.

Why? What value does CHITEST give this way then?

Thank you.

I don’t know much about statistical analysis; just mentioning the observable difference.

Given the values in A1:B6:

``````20	30
20	14
30	34
40	45
60	57
30	20
``````

The P-value returned by `Data``Statistics``Chi-Square Test` uses this formula:

``````=CHITEST(\$Sheet1.\$A\$1:\$B\$6; MMULT(MMULT(\$Sheet1.\$A\$1:\$B\$6;TRANSPOSE(IF(COLUMN(\$Sheet1.\$A\$1:\$B\$6))));MMULT(TRANSPOSE(IF(ROW(\$Sheet1.\$A\$1:\$B\$6)));\$Sheet1.\$A\$1:\$B\$6)) / SUM(\$Sheet1.\$A\$1:\$B\$6))
``````

which is equivalent to

``````=CHITEST({20;30|20;14|30;34|40;45|60;57|30;20};{25;25|17;17|32;32|42.5;42.5|58.5;58.5|25;25})
``````

(given the array column separator is `;`, and array row separator is `|`).

So in this case, unlike in manually written formula, the whole your data is the observed data array, and the expected data array is calculated.

However the problem is that it gives different result for the P value. My question still persists: Why and how is it different? Thanks.

BTW I’ve tested the later function you gave and it doesn’t give the same value for the numbers above as CHITEST(A1:A6,B1:B6) does. Yours gives 0.89 and mine gives 0.03.

BTW I’ve tested the later function you gave and it doesn’t give the same value for the numbers above as CHITEST(A1:A6,B1:B6) does.

You seem to not understood what I wrote above: that formula is not the same as “CHITEST(A1:A6,B1:B6)”, but the same as “Data / Statistics / Chi-square Test”.

``````=CHITEST(/20	30\; 	/25  	25  \)
|20	14|  	|17  	17  |
|30	34|  	|32  	32  |
|40	45|  	|42.5	42.5|
|60	57|  	|58.5	58.5|
\30	20/  	\25  	25  /
``````

Yours gives 0.89 and mine gives 0.03

… which also means that you haven’t read the "given the array column separator is `;`, and array row separator is `|`". It should give 0.33… (but of course, not 0.03).

Could you also give me details on how I can provide the observed and the expected values as well for the menu version of chitest? Thank you.

I rephrase my question: How am I supposed to use the menu version of CHITEST compared to the function description below? What am I supposed to select with the mouse and how before applying the function from the menu? Thanks.

https://help.libreoffice.org/Calc/Statistical_Functions_Part_One#CHITEST

Hey, I started my comment with:

I don’t know much about statistical analysis; just mentioning the observable difference.

That was meant to help you see what is actually different in the two formulas (in case you could see that from the numbers, as opposed to convoluted formulas); or to help others who understands the matter. Please don’t assume I owe you an explanation just because I tried to represent the formula in less complex way.

I have realized the solution:

The menu version of Chi-squared Test expects the data to be in rows instead of columns and to be more than 1 row as well. This way it works with P values as expected.