Ask LibreOffice - RSS feedhttps://ask.libreoffice.org/en/questions/Questions and answers for LibreOfficeenSun, 24 Nov 2019 19:10:04 +0100CHITEST gives unexpected valuehttps://ask.libreoffice.org/en/question/218592/chitest-gives-unexpected-value/I have two columns denoting respectively **observed and expected frequency**, I then calculate **X²** (chi-square) for each row with `((OBSERVED-EXPECTED)^2)/EXPECTED)` and proceed to `SUM` all rows to get the actual **X²** value. The resulting value is different from the value given by `CHITEST` and I can't seem to understand why (in fact, I can't really find much documentation about this function at all).
Also, the values in my table are rounded for display.
Observed Expected X²
3 4.0 0.26
15 18.5 0.66
47 42.5 0.47
76 65.2 1.78
68 75.0 0.66
74 69.0 0.36
46 52.9 0.90
39 34.8 0.52
15 20.0 1.25
9 10.2 0.15
5 4.7 0.02
2 2.0 0.00
0 0.8 0.75
1 0.3 2.02
SUM: 9.782 CHITEST: 0.712
Here's my table (in case it's useful): [Exemplo_Qui-Quadrado.ods](/upfiles/1574535392204544.ods)
Could someone explain to me how is the value of `CHITEST` calculated?Sat, 23 Nov 2019 20:11:03 +0100https://ask.libreoffice.org/en/question/218592/chitest-gives-unexpected-value/Answer by Mike Kaganski for <p>I have two columns denoting respectively <strong>observed and expected frequency</strong>, I then calculate <strong>X²</strong> (chi-square) for each row with <code>((OBSERVED-EXPECTED)^2)/EXPECTED)</code> and proceed to <code>SUM</code> all rows to get the actual <strong>X²</strong> value. The resulting value is different from the value given by <code>CHITEST</code> and I can't seem to understand why (in fact, I can't really find much documentation about this function at all).
Also, the values in my table are rounded for display.</p>
<pre><code>Observed Expected X²
3 4.0 0.26
15 18.5 0.66
47 42.5 0.47
76 65.2 1.78
68 75.0 0.66
74 69.0 0.36
46 52.9 0.90
39 34.8 0.52
15 20.0 1.25
9 10.2 0.15
5 4.7 0.02
2 2.0 0.00
0 0.8 0.75
1 0.3 2.02
SUM: 9.782 CHITEST: 0.712
</code></pre>
<p>Here's my table (in case it's useful): <a href="/upfiles/1574535392204544.ods">Exemplo_Qui-Quadrado.ods</a></p>
<p>Could someone explain to me how is the value of <code>CHITEST</code> calculated?</p>
https://ask.libreoffice.org/en/question/218592/chitest-gives-unexpected-value/?answer=218653#post-id-218653The function [CHITEST](https://help.libreoffice.org/latest/en-US/text/scalc/01/04060181.html?DbPAR=CALC#bm_id3154260) is implemented in [ScInterpreter::ScChiTest](https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/interpr3.cxx?r=f853ec31#2797). In your spreadsheet, given the `χ²` (result of ![image description](/upfiles/1574581251771364.png)) in E17, the function is equal to
=CHIDIST(E17;13)
where 13 is degrees of freedom: number of rows of a test series (14) decremented by 1 and multiplied by number of columns (1).Sun, 24 Nov 2019 08:44:08 +0100https://ask.libreoffice.org/en/question/218592/chitest-gives-unexpected-value/?answer=218653#post-id-218653Comment by telmo_trooper for <p>The function <a href="https://help.libreoffice.org/latest/en-US/text/scalc/01/04060181.html?DbPAR=CALC#bm_id3154260">CHITEST</a> is implemented in <a href="https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/interpr3.cxx?r=f853ec31#2797">ScInterpreter::ScChiTest</a>. In your spreadsheet, given the <code>χ²</code> (result of <img src="/upfiles/1574581251771364.png" alt="image description">) in E17, the function is equal to</p>
<pre><code>=CHIDIST(E17;13)
</code></pre>
<p>where 13 is degrees of freedom: number of rows of a test series (14) decremented by 1 and multiplied by number of columns (1).</p>
https://ask.libreoffice.org/en/question/218592/chitest-gives-unexpected-value/?comment=218713#post-id-218713Thank you!Sun, 24 Nov 2019 19:10:04 +0100https://ask.libreoffice.org/en/question/218592/chitest-gives-unexpected-value/?comment=218713#post-id-218713