Contact

CHITEST Function (LibreOffice Calc)

Statistical Intermediate LibreOffice Calc

LibreOffice Calc CHITEST examples turn observed and expected counts into a right-tail p-value, with table-shape degrees of freedom and model cautions.

Verification status: Official release source and independently calculated examples for CHITEST were reviewed. No new LibreOffice Calc application execution is claimed for this guide; the stated version and example limits still apply. How formula examples are checked

Quick answer: For observed counts 18, 22, 20, 20 and expected counts 20, 20, 20, 20, CHITEST gives approximately 0.940242494839. The result is a right-tail p-value under the specified chi-square model.

Availability and version history

  • Introduced: First release not established. The LibreOffice 3.3 function appendix documents this name; that establishes historical presence, not its introduction.
  • Supported in: LibreOffice 26.8.1.1; no final supported release established.
  • Scope: Desktop Calc. Examples use English function names and semicolon argument separators; the numeric contract is release-specific.
  • Checked: October 14, 2026. Retained official sources and independent mathematics checked. No new LibreOffice Calc execution is claimed here.

What CHITEST calculates

CHITEST first forms the statistic Σ(observed−expected)²/expected, then evaluates its chi-square right tail. Expected counts must come from the model you intend to test. A large p-value does not establish that the model is true, and a small one does not identify the cause of a difference. Release implementation.

The usual reference approximation assumes suitable independent count observations and sufficiently large expected counts. Repeated measurements of the same individual, percentages entered as though they were counts, or sparse categories can invalidate that interpretation even when Calc returns a number.

Syntax and input shape

=CHITEST(Observed; Expected)

Both arguments are required and must have identical row and column dimensions. For a single row or column of k entries, Calc uses k−1 degrees of freedom. For a genuine r-by-c rectangle, it uses (r−1)(c−1). Consequently, rearranging four categories from one column into a 2-by-2 block changes the reference distribution.

Use complete numeric counts with strictly positive expected values. The implementation skips pairs containing empty cells but still derives degrees of freedom from the full rectangular shape. This is a reason to prepare a complete table rather than rely on blank skipping. A zero expected value has an explicit division-by-zero guard. A one-cell input has zero degrees of freedom and is rejected.

Reproducible worksheet

Enter these four columns beginning in row 2. B holds the expected counts; each complete observed column has the same total, 80.

Row A B C D
2 18 20 10 19
3 22 20 10 21
4 20 20 20 20
5 20 20 40 20

The following values were calculated independently and rounded to twelve decimal places.

Formula Expected result, approximately
=CHITEST(A2:A5;B2:B5) 0.940242494839
=CHITEST(C2:C5;B2:B5) 0.000001380057
=CHITEST(D2:D5;B2:B5) 0.991837423732
=CHITEST(B2:B5;B2:B5) 1
=CHITEST(A2:A3;B2:B3) 0.527089256866
=CHITEST(A2:A4;B2:B4) 0.818730753078
=CHITEST(A4:A5;B4:B5) 1
=CHITEST(D2:D3;B2:B3) 0.751829634046

For A against B, the chi-square statistic is 0.4 and df=3. Check it with =SUMPRODUCT((A2:A5-B2:B5)^2/B2:B5) and evaluate =CHIDIST(0.4;3) separately. This cross-check exposes a wrong expected range or tail choice.

Advanced example: a 2-by-2 independence table

Suppose the observed rows are 30, 20 and 10, 40. Both row totals are 50; column totals are 40 and 60; the grand total is 100. Under independence, expected counts are row total × column total ÷ grand total, giving rows 20, 30 and 20, 30.

Place the observed table in A10:B11 and the expected table in D10:E11. =CHITEST(A10:B11;D10:E11) uses df=1 and gives approximately 0.000044557091. The statistic is 16.666666666667. Do not include marginal totals as extra observations.

When the built-in degrees of freedom do not fit

If expected counts were fitted using parameters estimated from these same observations, the appropriate goodness-of-fit degrees of freedom can be smaller than k−1. CHITEST does not discover that model adjustment. Compute the statistic and evaluate CHIDIST with the justified df instead.

Also avoid changing categories after inspecting the result solely to obtain a smaller p-value. Record the grouping and model before testing, retain the original counts and interpret the result with the study design and effect sizes.

Official evidence and calculation scope

The numerical references were recomputed independently against the retained release contract. Native application execution, import paths and locale behavior are not newly verified by these reference calculations.