Statistical Inference Tests

Chi-Square Test for Independence on Lattice

The chi-square test helps you decide if there is a real relationship between two categorical variables. Use it when you have two groups or categories and want to check if the frequency of outcomes is different across them, such as comparing conversion rates or preferences between different user segments.

Understanding categorical relationships

The chi-square test examines how counts of categorical items are distributed. By organizing data into a contingency table—which counts the occurrences of every combination of your two variables—Lattice calculates the difference between what you observed and what you would expect if there were no relationship at all.

When the observed counts differ significantly from the expected ones, it indicates that the variables are likely related. This method is the standard approach for binary outcomes like pass/fail, purchased/not purchased, or categorical survey responses.

Statistical evidence with p-values

The test returns a p-value to help you determine if the observed patterns are statistically significant. If the p-value is below your chosen threshold (usually 0.05), you can conclude that the relationship between your groups is likely not due to random chance.

Lattice always provides the specific p-value alongside the chi-square statistic, allowing you to see exactly how much evidence there is against the idea that the two variables are independent.

Measuring the size of the effect

Beyond just confirming significance, it is important to understand if a relationship is meaningful in practice. The chi-square test on Lattice reports Cramér's V, an effect size metric that scales from 0 to 1.

This value tells you the strength of the association. A significant p-value confirms the relationship exists, while Cramér's V helps you judge if that relationship is practically important for your decision-making.

Safety and accuracy

For 2x2 tables, Lattice applies Yates's continuity correction by default to prevent overestimating the significance of small datasets. We also perform a check on your expected frequencies; if any cell has a count less than 5, the platform will suggest an alternative method to ensure your results remain valid.

Our approach ensures you are notified if the underlying assumptions of the test are not met, keeping your analysis grounded in solid data practices.

1 · Intent → method

An LLM picks svt_run_chi2 from a fixed catalog.

2 · Method → numbers

Deterministic Python engine runs the math. Same input → same output.

3 · Numbers → plain language

A second LLM translates the result into your domain’s vocabulary.

  • When should I use this instead of a t-test?

    Use this chi-square test when your data is categorical (like 'Yes'/'No', or 'Red'/'Blue'). A t-test is designed for numerical values like averages and measurements.

  • What happens if my sample size is too small?

    If your data has very small counts in some groups, Lattice will issue a warning recommending the Fisher exact test, which is more reliable when expected frequencies fall below 5.

  • How do I interpret the Cramér's V value?

    Cramér's V measures the strength of the association. Values under 0.1 are negligible, 0.3 is moderate, and 0.5 or higher indicates a strong relationship between the categories.

Tool input schema

Schema for svt_run_chi2 not exported yet (run pnpm export:registry).