# Null hypothesis and $\chi^2$ test

Which null hypothesis can be tested by a $\chi^2$ test?

could you please write the description of the relevant null hypothesis or at least give an example.

Thank you.

-
From the help of the chisq.test() function in R : Then Pearson's chi-squared test is performed of the null hypothesis that the joint distribution of the cell counts in a 2-dimensional contingency table is the product of the row and column marginals. –  Stéphane Laurent Jan 10 '13 at 12:22
Which chi-square test? For association in contingency tables? For goodness of fit? To test distributional hypotheses? To compare variance estimates? To assess significance of added variables in nested models using Maximum Likelihood? Others? –  whuber Jan 10 '13 at 13:47

There are lots of things to test with chi-square. Perhaps the most common, in my experience anyway, is whether two categorical variables are associated. But also whether one variable fits a certain distribution. It can also come up in testing of various models.

-
The question is about the mathematical statement of $H_0$, I think (the mathematical definition of "association" here) –  Stéphane Laurent Jan 10 '13 at 12:23

It is used to check if a given sample is of a certain law (goodness-of-fit test), and it's also used to check whether to samples are independent. Here's an example using R

x=rnorm(100)
y=rnorm(100)
chisq.test(x,y) # test for goodness of fit


HTH

-
As it is stated in charlesdennishale.com/books/eets_ap/… Chi-square can be used to test whether a. Observed nominal data conforms to some theoretical or expected distribution b. Two variables within a sample are related c. Two or more samples, drawn from different populations, are homogenous on some characteristic of interest –  O_Devinyak Jan 10 '13 at 10:28
David: and so, what is $H_0$ ? –  Stéphane Laurent Jan 10 '13 at 12:24
$H_0$ is : $x$ and $y$ come from the same $mother$ distribution , you do not even have to specify the distribution is normal or anything. You can view it as a distance between the empirical cumulative density functions of the two input samples. Is it clear? –  DKK Jan 10 '13 at 12:38
This is a mis-application of chisq.test and its output is nonsensical. According to its manual page, "Otherwise, x and y must be vectors or factors of the same length; cases with missing values are removed, the objects are coerced to factors, and the contingency table is computed from these." In short, these data are supposed to represent a small contingency table. In the application given here, it's virtually certain that all $(x,y)$ pairs will be distinct, leading to a $100$ by $100$ table with $99$ zeros in each row and each column! –  whuber Mar 6 '13 at 18:54