Do the properties of Pearson's chi-squared test for independence hold true for continuous PDFs?

In probabilist statistics, the properties of a discrete Pearson's chi-squared test hold that:

\begin{aligned} \chi^2 = \sum_{i=1}^{r} \sum_{j=1}^{c} {(O_{i,j} - E_{i,j})^2 \over E_{i,j}} \end{aligned}

Where $\chi^2$ is our (Pearson's) cumulative test statistic, $O_{i,j}$ is an observed frequency in a given contingency table, $E_{i,j}$ is the an expected (theoretical) frequency for the same, and $r$ and $c$ are the number of rows and columns in the table, respectively.

Assuming this is true, a Pearson's chi-squared test for independence states:

\begin{aligned} E_{i,j}=\frac{\sum_{k=1}^c O_{i,k}\ \sum_{k=1}^r O_{k,j}}{N} \end{aligned}

... which is a mathematically terse way of saying that, for all observations in $O_{i,j}$, we expect a frequency derived from the row and column values.

I'm currently looking at generalizing this test for continuous variables estimable by PDF. Phrased differently: given the joint probability distribution of an intersecting function, I would like to be able to perform a chi-squared test for independence.

My intuition states that, for the continuous case, the first formula can be generalized as:

\begin{aligned} \chi^2 = \int_I \int_J {(\hat{O_{i,j}} - \hat{E_{i,j}})^2 \over \hat{E_{i,j}}}\ di\ dj \end{aligned}

Where $\chi^2$ remains our cumulative test statistic, $\hat{O_{i,j}}$ is an observed frequency off the joint probability distribution, given $i \in I$ and $j \in J$, $\hat{E_{i,j}}$ remains the expected frequency, and $r$ and $c$ briefly disappear. We then define $\hat{E_{i,j}}$ to a comparable function that looks something like:

\begin{aligned} \hat{E_{i,j}}=\frac{\int_c \hat{O_{i,c}}\ dc\ \int_r \hat{O_{r,j}}\ dr}{2} \end{aligned}

... where $r$ and $c$ are the partitions selected during integration by, for example, an adaptive quadrature. Note further that this relationship breaks down for infinite bounds, as $r$ or $c$ approach infinity (or conversely, as the value of any evaluation of $\hat{E_{i,j}}$ approaches zero).

This is intuitive only in the sense that these calculations are made practical by tools like SciPy, and I'm leaving out a lot of detail so as not to bore or confuse the reader.

But, I am curious: is method, as tersely presented, correct? I can find no guidance contradicting it. The goal of such a thing is to make terms expressible as continuous PDFs smoothed by a Gaussian kernel possible, for unorganized ordinal and nominal data.

Thank you in advance.

• The integral itself is always $1$ for a continuous distribution, because the numerator equals $E_{i,j}$ almost everywhere (and presumably $E_{i,j}$ is the pdf of the joint distribution). Or perhaps it is intended in some special sense? – whuber Dec 15 '11 at 2:31
• @whuber Did you means 'the numerator equals $E_{i,j}^2$ ...'? – onestop Dec 15 '11 at 12:26
• @Onestop Sorry; I meant the integrand equals $E_{i,j}$. Thanks for catching that. – whuber Dec 15 '11 at 16:05
• @whuber I updated the question to be more specific and to define certain qualities that need to hold true. Among them, the evaluation of $\int_I$ and $\int_J$ must not have infinite bounds, because as $E_{i,j}$ approaches 0, each infinitesimal evaluation approaches a singularity. It's a bit weird to think of integrals in this way, but then, this is how packages like QUADPACK evaluate them. -- As a bonus, I believe the properties of the gamma function bounding the error of the chi-squared test also hold true: mathworld.wolfram.com/Chi-SquaredTest.html – MrGomez Dec 15 '11 at 22:53
• Thank you. I think you'll get a glimpse of what goes wrong if you consider a case where the kernel halfwidth is small. Your expression appears to reduce to a chi-square-like formula where every observation has been placed into its own bin. That will not have a chi-square distribution. It raises the additional question of what half-width to use for the kernel estimates, because your statistic (and its sampling distribution) will depend heavily on the choice of half-width. – whuber Dec 16 '11 at 14:45