Version:

Last Modified: September 4, 2017

Tests whether the row and column categorical variables of a contingency table are independent.

Contingency table of counts or frequencies.

Probability that this node incorrectly rejects a true null hypothesis.

**Default: **0.05

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an **error in** input and an **error out** output so that the node can respond to and communicate errors that occur while code is running. The value of **error in** specifies whether an error occurred before the node runs. Most nodes respond to values of **error in** in a standard, predictable way.

**Default: **No error

A Boolean that indicates whether this node rejects the null hypothesis.

True | p value is less than or equal to significance level. This node rejects the null hypothesis and accepts the alternative hypothesis. |

False | p value is greater than significance level. This node accepts the null hypothesis and rejects the alternative hypothesis. |

Smallest significance level that leads to rejection of the null hypothesis based on the sample sets.

Sample statistics of the contingency table test.

Degree of freedom of the chi-squared distribution that the test statistic follows.

Sample test statistic used in the contingency table test.

Chi-squared value that corresponds to **significance level**.

Algorithm for Calculating **chi-squared critical value**

**chi-squared critical value** satisfies the following equation:

Prob{*X*_{n} > **chi-squared critical value**} = **significance level**

where *X*_{n} represents a chi-squared distributed variate with *n* degrees of freedom.

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

**error in** input and an **error out** output so that the node can respond to and communicate errors that occur while code is running. The value of **error in** specifies whether an error occurred before the node runs. Most nodes respond to values of **error in** in a standard, predictable way.

This node uses the Pearson's chi-squared test of homogeneity and test of independence to test your hypothesis.

For the chi-squared test of homogeneity, you take a random sample of a fixed size from each category in one categorization scheme. For each sample, categorize the objects of experimentation according to the second scheme and tally them. This node tests the hypothesis to determine whether the populations from which each sample is taken are identically distributed with respect to the second categorization scheme.

For the chi-squared test of independence, you take only one sample from the total population, categorize each object, and tally each object in two categorization schemes. This node tests the hypothesis that the categorization schemes are independent.

For both tests, this node tests the hypothesis with the same algorithm. Let *y*_{(p, q)} be the number of occurrences in the (*p**q*)^{th} cell of the contingency table for *p* = 0, 1, ..., (*s* - 1) and *q* = 0, 1, ..., (*k* - 1).

And let

${y}_{p}=\underset{q=0}{\overset{k-1}{\sum}}{y}_{(p,\text{\hspace{0.17em}}q)}\phantom{\rule{0ex}{0ex}}{y}_{q}=\underset{p=0}{\overset{s-1}{\sum}}{y}_{(p,\text{\hspace{0.17em}}q)}\phantom{\rule{0ex}{0ex}}y=\underset{p=0}{\overset{s-1}{\sum}}\underset{q=0}{\overset{k-1}{\sum}}{y}_{(p,\text{\hspace{0.17em}}q)}\phantom{\rule{0ex}{0ex}}{e}_{(p,\text{\hspace{0.17em}}q)}=\frac{{y}_{p}{y}_{q}}{y}\phantom{\rule{0ex}{0ex}}x=\underset{p=0}{\overset{s-1}{\sum}}\underset{q=0}{\overset{k-1}{\sum}}\frac{{({y}_{(p,\text{\hspace{0.17em}}q)}-{e}_{(p,\text{\hspace{0.17em}}q)})}^{2}}{{e}_{(p,\text{\hspace{0.17em}}q)}}$

where

*s*is the number of rows in the contingency table*k*is the number of columns in the contingency table*e*_{(p, q)}is the expected counts or frequencies in the (*p**q*)^{th}cell*x*is**sample chi-squared value**

This node uses **sample chi-squared value** to calculate **p value** according to the following equation:

**p value** = Prob{*X* ≥ *x*}

where *X* is a random variable from the chi-squared distribution. If the hypothesis is true, *x* came from a chi-squared distribution with (*s* - 1) and (*k* - 1) degrees of freedom.

**Where This Node Can Run: **

Desktop OS: Windows

FPGA: This product does not support FPGA devices

Web Server: Not supported in VIs that run in a web application