Page 1 of 1

Clarification Needed on Chi-Square Residuals Terminology in Jamovi

Posted: Fri Mar 21, 2025 7:00 am
by GmA
Dear Jamovi Community and Developers,

I am writing to seek clarification regarding the terminology used for residuals in the chi-square analysis post-hoc tests in Jamovi. I believe there may be some inconsistency between the labels used in Jamovi and the standard statistical terminology, which is causing confusion among students.

The Issue

After reviewing the output with students, I have noticed the following terminology issues:

1. What Jamovi labels as "Pearson residuals" appears to match what is typically called "Standardised residuals" in the statistical literature - these are calculated as (O - E)/√E.

2. What Jamovi labels as "Standardised residuals" appears to correspond to what are commonly called "Adjusted standardised residuals" - these are standardised residuals further adjusted to account for row and column proportions, following approximately a standard normal distribution when the null hypothesis is true.

3. I cannot quite determine what Jamovi's "Adjusted residuals" represent mathematically. I have not found a clear counterpart to these in the standard statistical literature on contingency table analysis.

Statistical Context

Based on established statistical literature, particularly Haberman's (1973) foundational paper "The Analysis of Residuals in Cross-Classified Tables" published in Biometrics, the commonly known types of residuals in contingency tables are:

- Raw residuals: The difference between observed and expected frequencies (O - E)

- Standardised residuals (sometimes called Pearson residuals): Raw residuals divided by the square root of the expected frequency (O - E)/√E

- Adjusted standardised residuals: Standardised residuals further adjusted to account for the sampling variation. For two-way tables, this adjustment involves dividing standardised residuals by the square root of:
vi = (1 - ni+/n++)(1 - n+j/n++), 1 ≤ i ≤ r, 1 ≤ j ≤ c

Where ni+ and n+j are the row and column totals respectively, and n++ is the grand total.

Request

I would greatly appreciate if someone could:

1. Confirm whether my assessment of the terminology for the first two residual types is correct
2. Clarify what Jamovi's "Adjusted residuals" actually represent mathematically, as I cannot find a corresponding formulation in the statistical literature
3. Consider updating the labels or documentation to align with standard statistical terminology, if appropriate

This clarification would be immensely helpful for teaching purposes, as the current labelling is creating confusion when students compare Jamovi output with textbooks or other statistical resources.

Kind regards,
GmA

Re: Clarification Needed on Chi-Square Residuals Terminology in Jamovi

Posted: Fri Mar 21, 2025 1:20 pm
by MAgojam
Clarification on Residuals Terminology in Jamovi

Hi @GmA,
Thanks for your detailed question! After analyzing the function responsible for computing residuals in Jamovi's post-hoc table, I can confirm that some of the terminology used in the software differs from what is commonly found in statistical literature.

Terminology Used in Jamovi vs. Standard Statistical Terms
Below is the correspondence between the residual types in Jamovi and the more conventional statistical definitions:

1. "Pearson residuals" in Jamovi
  • Formula: (O - E) / sqrt(E)
  • This formula corresponds to what is commonly referred to as Standardized residuals in many statistics textbooks.
  • Therefore, the label "Pearson residuals" in Jamovi might be misleading.


2. "Standardized residuals" in Jamovi
  • Formula: (O - E) / sqrt(E * (1 - p_row) * (1 - p_col))
  • In statistical literature, this is better known as the Adjusted standardized residual.
  • Again, the term "Standardized residuals" in Jamovi does not match the conventional definition.


3. "Adjusted residuals" in Jamovi: Deviance Residuals from a Poisson Model
https://github.com/jamovi/jmv/blob/mast ... #L782-L816
  • Jamovi’s "Adjusted residuals" are, in fact, deviance residuals from a log-linear Poisson model.
    • Jamovi fits a log-linear Poisson model to the contingency table, using the observed counts as the dependent variable and row/column categories as predictors.
    • These "Adjusted residuals" are the deviance residuals from this Poisson model, which measure how well the model fits each cell.
    • Unlike Pearson or standardized residuals, deviance residuals take into account the multiplicative nature of count data, making them a more robust measure of deviation from expected values.
    • Behind the scenes, Jamovi performs the following steps:
      • Creates a dataframe from the contingency table.
      • Fits a generalized linear model (GLM) with a Poisson family:

        Code: Select all

        model <- glm(Count ~ Row + Col, data=df, family=poisson())
      • Extracts the adjusted residuals using:

        Code: Select all

        residuals(model, type="deviance")


Why Does This Discrepancy Exist?
  • The issue arises because "Adjusted Standardized Residuals" (as defined by Haberman) and "Adjusted Residuals" (from a Poisson model) are different concepts, even though both aim to refine residual measures.
  • Jamovi uses deviance residuals from a Poisson regression model instead of classical adjusted standardized residuals in contingency table analysis.
  • This choice is valid, but it can lead to confusion when comparing Jamovi’s output with standard statistical textbooks.


Possible Documentation Improvements
  • To improve clarity (in a future release), I may update the residual labels to align with conventional statistical terminology:
    • "Pearson residuals" → "Standardized residuals"
    • "Standardized residuals" → "Adjusted standardized residuals"
    • "Adjusted residuals" → "Poisson deviance residuals"
  • For a better understanding of "Adjusted Residuals", a small one in the footer of the table might also help, such as:
    "Adjusted residuals derive from a Poisson GLM, modeling counts as a function of row and column categories".


I hope this clarifies your concerns!

Best regards,
Maurizio
https://www.jamovi.org/about.html

Re: Clarification Needed on Chi-Square Residuals Terminology in Jamovi

Posted: Thu Mar 27, 2025 7:02 pm
by GmA
Dear Maurizio,
thanks for your prompt reply and for clarifying things.

Those adjustments to the terminology would be really appreciated and would help my students not to get confused.
Also, thanks for pointing out the Poisson's model residuals, which I had overlooked.

Best

Re: Clarification Needed on Chi-Square Residuals Terminology in Jamovi

Posted: Sun Mar 30, 2025 6:34 pm
by MAgojam
GmA wrote: Thu Mar 27, 2025 7:02 pm Those adjustments to the terminology would be really appreciated and would help my students not to get confused
Hi @GmA,
if you take a look look here:
https://github.com/jamovi/jmv/pull/429

you will see that the changes have been made and the PR is available for evaluation by a Core Team Referee and if merged with the master it will be available in a future version of jamovi.

Thanks for your input.

Best

Maurizio
https://www.jamovi.org/about.html