[{"data":1,"prerenderedAt":678},["ShallowReactive",2],{"content-query-NtYV4pMPAR":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"heading":10,"prompt":11,"tags":15,"files":17,"nav":17,"presets":18,"gallery":35,"body":37,"_type":671,"_id":672,"_source":673,"_file":674,"_stem":675,"_extension":676,"sitemap":677},"/tools/chi-square-test","tools",false,"","Chi-Square Test Calculator for Excel & CSV","Run chi-square tests of independence and goodness-of-fit online from Excel or CSV data. Build contingency tables, p-values, and effect sizes with AI.","Chi-Square Test",{"prefix":12,"label":13,"placeholder":14},"Run a chi-square test","Describe the chi-square test you want to run","e.g. chi-square test of independence between education level and voting behavior",[16],"statistics",true,[19,25,30],{"label":20,"prompt":21,"dataset_url":22,"dataset_title":23,"dataset_citation":24},"Education level vs internet access","chi-square test of independence between education level and internet access; create a contingency table, compute chi-square statistic, degrees of freedom, p-value, and Cramér's V effect size; show standardized residuals heatmap","https://ourworldindata.org/grapher/share-of-individuals-using-the-internet.csv","Share of individuals using the internet","Our World in Data",{"label":26,"prompt":27,"dataset_url":28,"dataset_title":29,"dataset_citation":24},"Income group vs energy access","chi-square test of independence between World Bank income group and access to electricity; build contingency table, compute chi-square, p-value, Cramér's V; plot observed vs expected counts and standardized residuals","https://ourworldindata.org/grapher/share-of-population-with-access-to-electricity.csv","Share of population with access to electricity",{"label":31,"prompt":32,"dataset_url":33,"dataset_title":34,"dataset_citation":24},"Region vs renewable energy adoption","chi-square goodness-of-fit test: does renewable energy share differ significantly across world regions? Group countries by region, compute observed vs expected under uniform distribution, chi-square statistic, and p-value","https://ourworldindata.org/grapher/share-of-electricity-production-by-source.csv","Share of electricity production by source",[36],"/img/tools/chi-square-test.png",{"type":38,"children":39,"toc":661},"root",[40,49,70,97,122,128,185,191,331,337,445,451,505,511,540,546,575,591,615,632],{"type":41,"tag":42,"props":43,"children":45},"element","h2",{"id":44},"what-is-a-chi-square-test",[46],{"type":47,"value":48},"text","What Is a Chi-Square Test?",{"type":41,"tag":50,"props":51,"children":52},"p",{},[53,55,61,63,68],{"type":47,"value":54},"A ",{"type":41,"tag":56,"props":57,"children":58},"strong",{},[59],{"type":47,"value":60},"chi-square test",{"type":47,"value":62}," is a statistical test used to determine whether there is a significant association between two ",{"type":41,"tag":56,"props":64,"children":65},{},[66],{"type":47,"value":67},"categorical variables",{"type":47,"value":69}," (test of independence) or whether an observed frequency distribution matches a theoretically expected distribution (goodness-of-fit test). Unlike t-tests and ANOVA which compare means of numeric variables, chi-square operates entirely on counts — how many observations fall into each combination of categories.",{"type":41,"tag":50,"props":71,"children":72},{},[73,75,80,82,87,89,95],{"type":47,"value":74},"The ",{"type":41,"tag":56,"props":76,"children":77},{},[78],{"type":47,"value":79},"test of independence",{"type":47,"value":81}," is the more common form. It asks: are two categorical variables related, or are they independent? For example, is there a relationship between a person's education level and their voting behavior? To answer this, you build a ",{"type":41,"tag":56,"props":83,"children":84},{},[85],{"type":47,"value":86},"contingency table",{"type":47,"value":88}," (cross-tabulation) of observed counts and compare it to the counts you would ",{"type":41,"tag":90,"props":91,"children":92},"em",{},[93],{"type":47,"value":94},"expect",{"type":47,"value":96}," if the variables were completely independent. The larger the discrepancy between observed and expected counts, the larger the chi-square statistic (χ²), and the smaller the p-value. A p-value below your threshold (usually 0.05) indicates a statistically significant association.",{"type":41,"tag":50,"props":98,"children":99},{},[100,101,106,108,113,115,120],{"type":47,"value":74},{"type":41,"tag":56,"props":102,"children":103},{},[104],{"type":47,"value":105},"goodness-of-fit test",{"type":47,"value":107}," asks whether an observed distribution across categories matches a specified theoretical distribution — for example, whether a die is fair (each face appearing 1/6 of the time), or whether product defects are evenly distributed across production lines. The ",{"type":41,"tag":56,"props":109,"children":110},{},[111],{"type":47,"value":112},"standardized residuals",{"type":47,"value":114}," from either test reveal ",{"type":41,"tag":90,"props":116,"children":117},{},[118],{"type":47,"value":119},"which cells",{"type":47,"value":121}," contribute most to the chi-square statistic — large positive residuals mean a cell has far more observations than expected; large negative residuals mean far fewer. This cell-level diagnosis, often visualized as a heatmap, is as informative as the overall p-value.",{"type":41,"tag":42,"props":123,"children":125},{"id":124},"how-it-works",[126],{"type":47,"value":127},"How It Works",{"type":41,"tag":129,"props":130,"children":131},"ol",{},[132,143,158],{"type":41,"tag":133,"props":134,"children":135},"li",{},[136,141],{"type":41,"tag":56,"props":137,"children":138},{},[139],{"type":47,"value":140},"Upload your data",{"type":47,"value":142}," — provide a CSV or Excel file with at least two categorical columns (for a test of independence) or one column of observed counts with expected proportions specified in the prompt. One row per observation, or a pre-aggregated contingency table.",{"type":41,"tag":133,"props":144,"children":145},{},[146,151,153],{"type":41,"tag":56,"props":147,"children":148},{},[149],{"type":47,"value":150},"Describe the test",{"type":47,"value":152}," — e.g. ",{"type":41,"tag":90,"props":154,"children":155},{},[156],{"type":47,"value":157},"\"chi-square test of independence between income group and healthcare access, show standardized residuals and Cramér's V\"",{"type":41,"tag":133,"props":159,"children":160},{},[161,166,168,175,177,183],{"type":41,"tag":56,"props":162,"children":163},{},[164],{"type":47,"value":165},"Get full results",{"type":47,"value":167}," — the AI writes Python code using ",{"type":41,"tag":169,"props":170,"children":172},"a",{"href":171},"https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chi2_contingency.html",[173],{"type":47,"value":174},"scipy",{"type":47,"value":176}," to compute the test statistic, p-value, and effect size, and ",{"type":41,"tag":169,"props":178,"children":180},{"href":179},"https://plotly.com/python/",[181],{"type":47,"value":182},"Plotly",{"type":47,"value":184}," to visualize the contingency table and residuals",{"type":41,"tag":42,"props":186,"children":188},{"id":187},"interpreting-the-results",[189],{"type":47,"value":190},"Interpreting the Results",{"type":41,"tag":192,"props":193,"children":194},"table",{},[195,214],{"type":41,"tag":196,"props":197,"children":198},"thead",{},[199],{"type":41,"tag":200,"props":201,"children":202},"tr",{},[203,209],{"type":41,"tag":204,"props":205,"children":206},"th",{},[207],{"type":47,"value":208},"Output",{"type":41,"tag":204,"props":210,"children":211},{},[212],{"type":47,"value":213},"What it means",{"type":41,"tag":215,"props":216,"children":217},"tbody",{},[218,235,251,267,283,299,315],{"type":41,"tag":200,"props":219,"children":220},{},[221,230],{"type":41,"tag":222,"props":223,"children":224},"td",{},[225],{"type":41,"tag":56,"props":226,"children":227},{},[228],{"type":47,"value":229},"χ² statistic",{"type":41,"tag":222,"props":231,"children":232},{},[233],{"type":47,"value":234},"Sum of (observed − expected)² / expected across all cells — larger means more deviation",{"type":41,"tag":200,"props":236,"children":237},{},[238,246],{"type":41,"tag":222,"props":239,"children":240},{},[241],{"type":41,"tag":56,"props":242,"children":243},{},[244],{"type":47,"value":245},"Degrees of freedom",{"type":41,"tag":222,"props":247,"children":248},{},[249],{"type":47,"value":250},"(rows − 1) × (columns − 1) for independence test",{"type":41,"tag":200,"props":252,"children":253},{},[254,262],{"type":41,"tag":222,"props":255,"children":256},{},[257],{"type":41,"tag":56,"props":258,"children":259},{},[260],{"type":47,"value":261},"p-value",{"type":41,"tag":222,"props":263,"children":264},{},[265],{"type":47,"value":266},"Probability of observing this χ² or larger if the variables are truly independent",{"type":41,"tag":200,"props":268,"children":269},{},[270,278],{"type":41,"tag":222,"props":271,"children":272},{},[273],{"type":41,"tag":56,"props":274,"children":275},{},[276],{"type":47,"value":277},"Cramér's V",{"type":41,"tag":222,"props":279,"children":280},{},[281],{"type":47,"value":282},"Effect size (0 = no association, 1 = perfect association) — independent of sample size",{"type":41,"tag":200,"props":284,"children":285},{},[286,294],{"type":41,"tag":222,"props":287,"children":288},{},[289],{"type":41,"tag":56,"props":290,"children":291},{},[292],{"type":47,"value":293},"Standardized residual",{"type":41,"tag":222,"props":295,"children":296},{},[297],{"type":47,"value":298},"(observed − expected) / √expected — values beyond ±2 indicate a notable cell",{"type":41,"tag":200,"props":300,"children":301},{},[302,310],{"type":41,"tag":222,"props":303,"children":304},{},[305],{"type":41,"tag":56,"props":306,"children":307},{},[308],{"type":47,"value":309},"Red cell in heatmap",{"type":41,"tag":222,"props":311,"children":312},{},[313],{"type":47,"value":314},"More observations than expected — these categories tend to co-occur",{"type":41,"tag":200,"props":316,"children":317},{},[318,326],{"type":41,"tag":222,"props":319,"children":320},{},[321],{"type":41,"tag":56,"props":322,"children":323},{},[324],{"type":47,"value":325},"Blue cell in heatmap",{"type":41,"tag":222,"props":327,"children":328},{},[329],{"type":47,"value":330},"Fewer observations than expected — these categories tend not to co-occur",{"type":41,"tag":42,"props":332,"children":334},{"id":333},"example-prompts",[335],{"type":47,"value":336},"Example Prompts",{"type":41,"tag":192,"props":338,"children":339},{},[340,356],{"type":41,"tag":196,"props":341,"children":342},{},[343],{"type":41,"tag":200,"props":344,"children":345},{},[346,351],{"type":41,"tag":204,"props":347,"children":348},{},[349],{"type":47,"value":350},"Scenario",{"type":41,"tag":204,"props":352,"children":353},{},[354],{"type":47,"value":355},"What to type",{"type":41,"tag":215,"props":357,"children":358},{},[359,377,394,411,428],{"type":41,"tag":200,"props":360,"children":361},{},[362,367],{"type":41,"tag":222,"props":363,"children":364},{},[365],{"type":47,"value":366},"Association test",{"type":41,"tag":222,"props":368,"children":369},{},[370],{"type":41,"tag":371,"props":372,"children":374},"code",{"className":373},[],[375],{"type":47,"value":376},"chi-square test of independence between gender and product preference, show contingency table",{"type":41,"tag":200,"props":378,"children":379},{},[380,385],{"type":41,"tag":222,"props":381,"children":382},{},[383],{"type":47,"value":384},"Survey analysis",{"type":41,"tag":222,"props":386,"children":387},{},[388],{"type":41,"tag":371,"props":389,"children":391},{"className":390},[],[392],{"type":47,"value":393},"chi-square test: is satisfaction level independent of department? Cramér's V and residuals",{"type":41,"tag":200,"props":395,"children":396},{},[397,402],{"type":41,"tag":222,"props":398,"children":399},{},[400],{"type":47,"value":401},"Goodness of fit",{"type":41,"tag":222,"props":403,"children":404},{},[405],{"type":41,"tag":371,"props":406,"children":408},{"className":407},[],[409],{"type":47,"value":410},"chi-square goodness-of-fit test: are defects equally distributed across 5 production lines?",{"type":41,"tag":200,"props":412,"children":413},{},[414,419],{"type":41,"tag":222,"props":415,"children":416},{},[417],{"type":47,"value":418},"Medical research",{"type":41,"tag":222,"props":420,"children":421},{},[422],{"type":41,"tag":371,"props":423,"children":425},{"className":424},[],[426],{"type":47,"value":427},"chi-square test of independence between treatment group and recovery outcome",{"type":41,"tag":200,"props":429,"children":430},{},[431,436],{"type":41,"tag":222,"props":432,"children":433},{},[434],{"type":47,"value":435},"Marketing",{"type":41,"tag":222,"props":437,"children":438},{},[439],{"type":41,"tag":371,"props":440,"children":442},{"className":441},[],[443],{"type":47,"value":444},"chi-square test: does click-through rate differ by ad category? Show expected vs observed",{"type":41,"tag":42,"props":446,"children":448},{"id":447},"assumptions-to-check",[449],{"type":47,"value":450},"Assumptions to Check",{"type":41,"tag":452,"props":453,"children":454},"ul",{},[455,465,475,485,495],{"type":41,"tag":133,"props":456,"children":457},{},[458,463],{"type":41,"tag":56,"props":459,"children":460},{},[461],{"type":47,"value":462},"Random sampling",{"type":47,"value":464}," — observations should be independently drawn from the population",{"type":41,"tag":133,"props":466,"children":467},{},[468,473],{"type":41,"tag":56,"props":469,"children":470},{},[471],{"type":47,"value":472},"Categorical variables",{"type":47,"value":474}," — both variables must be categorical (nominal or ordinal); chi-square does not apply to numeric variables",{"type":41,"tag":133,"props":476,"children":477},{},[478,483],{"type":41,"tag":56,"props":479,"children":480},{},[481],{"type":47,"value":482},"Expected cell counts ≥ 5",{"type":47,"value":484}," — each cell in the expected table should have at least 5 observations; if not, ask the AI to apply Yates' correction or Fisher's exact test",{"type":41,"tag":133,"props":486,"children":487},{},[488,493],{"type":41,"tag":56,"props":489,"children":490},{},[491],{"type":47,"value":492},"Mutually exclusive categories",{"type":47,"value":494}," — each observation should belong to exactly one category in each variable",{"type":41,"tag":133,"props":496,"children":497},{},[498,503],{"type":41,"tag":56,"props":499,"children":500},{},[501],{"type":47,"value":502},"Sufficient sample size",{"type":47,"value":504}," — at least 20–30 total observations is a practical minimum; very small samples need Fisher's exact test instead",{"type":41,"tag":42,"props":506,"children":508},{"id":507},"related-tools",[509],{"type":47,"value":510},"Related Tools",{"type":41,"tag":50,"props":512,"children":513},{},[514,516,522,524,530,532,538],{"type":47,"value":515},"Use the ",{"type":41,"tag":169,"props":517,"children":519},{"href":518},"/tools/t-test",[520],{"type":47,"value":521},"Online t-test calculator",{"type":47,"value":523}," when your outcome variable is numeric and you are comparing means between two groups. Use the ",{"type":41,"tag":169,"props":525,"children":527},{"href":526},"/tools/one-way-anova",[528],{"type":47,"value":529},"Online ANOVA calculator",{"type":47,"value":531}," when comparing numeric means across three or more groups. Use the ",{"type":41,"tag":169,"props":533,"children":535},{"href":534},"/tools/ai-heatmap",[536],{"type":47,"value":537},"AI Heatmap Generator",{"type":47,"value":539}," to visualize a pre-computed correlation or association matrix without running a statistical test.",{"type":41,"tag":42,"props":541,"children":543},{"id":542},"frequently-asked-questions",[544],{"type":47,"value":545},"Frequently Asked Questions",{"type":41,"tag":50,"props":547,"children":548},{},[549,554,556,560,562,566,568,573],{"type":41,"tag":56,"props":550,"children":551},{},[552],{"type":47,"value":553},"What is the difference between the chi-square test of independence and goodness-of-fit?",{"type":47,"value":555},"\nThe ",{"type":41,"tag":56,"props":557,"children":558},{},[559],{"type":47,"value":79},{"type":47,"value":561}," uses two observed categorical variables from your data to test whether they are associated with each other. The ",{"type":41,"tag":56,"props":563,"children":564},{},[565],{"type":47,"value":105},{"type":47,"value":567}," uses one observed categorical variable and compares it against a ",{"type":41,"tag":90,"props":569,"children":570},{},[571],{"type":47,"value":572},"specified",{"type":47,"value":574}," expected distribution (e.g. equal proportions, or proportions from a prior study). Describe which you want in your prompt and the AI will run the appropriate version.",{"type":41,"tag":50,"props":576,"children":577},{},[578,583,585,589],{"type":41,"tag":56,"props":579,"children":580},{},[581],{"type":47,"value":582},"My p-value is significant — what does Cramér's V tell me?",{"type":47,"value":584},"\nA significant p-value only tells you that an association exists; it says nothing about how strong it is. With a large sample, even a tiny, practically meaningless association can be statistically significant. ",{"type":41,"tag":56,"props":586,"children":587},{},[588],{"type":47,"value":277},{"type":47,"value":590}," measures effect size: V \u003C 0.1 is negligible, 0.1–0.3 is small, 0.3–0.5 is moderate, and > 0.5 is strong. Always report both.",{"type":41,"tag":50,"props":592,"children":593},{},[594,599,601,606,608,613],{"type":41,"tag":56,"props":595,"children":596},{},[597],{"type":47,"value":598},"Some of my expected cell counts are below 5 — what should I do?",{"type":47,"value":600},"\nChi-square is unreliable when expected counts are small (\u003C 5). Options: (1) combine rare categories, (2) use ",{"type":41,"tag":56,"props":602,"children":603},{},[604],{"type":47,"value":605},"Fisher's exact test",{"type":47,"value":607}," (ask the AI to run it instead — it's exact for any cell size), or (3) apply ",{"type":41,"tag":56,"props":609,"children":610},{},[611],{"type":47,"value":612},"Yates' continuity correction",{"type":47,"value":614}," for 2×2 tables.",{"type":41,"tag":50,"props":616,"children":617},{},[618,623,625,630],{"type":41,"tag":56,"props":619,"children":620},{},[621],{"type":47,"value":622},"Can I run chi-square on a pre-aggregated contingency table rather than raw data?",{"type":47,"value":624},"\nYes — if you already have a table with rows and columns of counts, upload it and tell the AI ",{"type":41,"tag":90,"props":626,"children":627},{},[628],{"type":47,"value":629},"\"this is already a contingency table, not raw observations\"",{"type":47,"value":631},". The AI will skip the cross-tabulation step and run chi-square directly on the table.",{"type":41,"tag":50,"props":633,"children":634},{},[635,640,645,647,652,654,659],{"type":41,"tag":56,"props":636,"children":637},{},[638],{"type":47,"value":639},"What's the difference between standardized residuals and adjusted residuals?",{"type":41,"tag":56,"props":641,"children":642},{},[643],{"type":47,"value":644},"Standardized residuals",{"type":47,"value":646}," = (observed − expected) / √expected. ",{"type":41,"tag":56,"props":648,"children":649},{},[650],{"type":47,"value":651},"Adjusted (standardized Pearson) residuals",{"type":47,"value":653}," further account for the marginal totals, making them more interpretable: adjusted residuals > ±2 indicate a cell that is significantly different from expected, similar to a z-score. Ask for ",{"type":41,"tag":90,"props":655,"children":656},{},[657],{"type":47,"value":658},"\"adjusted residuals\"",{"type":47,"value":660}," for more precise cell-level inference.",{"title":7,"searchDepth":662,"depth":662,"links":663},2,[664,665,666,667,668,669,670],{"id":44,"depth":662,"text":48},{"id":124,"depth":662,"text":127},{"id":187,"depth":662,"text":190},{"id":333,"depth":662,"text":336},{"id":447,"depth":662,"text":450},{"id":507,"depth":662,"text":510},{"id":542,"depth":662,"text":545},"markdown","content:tools:028.chi-square-test.md","content","tools/028.chi-square-test.md","tools/028.chi-square-test","md",{"loc":4},1775502468196]