// Numbas version: exam_results_page_options {"name": "Chi-square test: contingency tables", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Chi-square test: contingency tables", "tags": [], "metadata": {"description": "", "licence": "Creative Commons Attribution-NonCommercial 4.0 International"}, "statement": "
A social scientist was interested in the relationship between sporting activity and age.
\nPeople in different age groups were asked to categorise their involvement in sports under three headings:
\nVery Active if they were members of a sports team
\nActive if they played sports on a regular basis but not a member of a sports team.
\nInactive if they rarely or never played sports.
\nThe data collected is presented below:
\n\n | \\(12\\le age<15\\) | \n\\(15\\le age<18\\) | \n\\(18\\le age<21\\) | \n
Very Active | \n{n11} | \n{n12} | \n{n13} | \n
Active | \n{n21} | \n{n22} | \n{n23} | \n
Inactive | \n{n31} | \n{n32} | \n{n33} | \n
Test the hypothesis that Sporting activity and age profile are independent of one another.
\n", "advice": "\\(H_0:\\) Sporting activity and age profile are independent of one another.
\n\\(H_1:\\) Sporting activity and age profile are not independent of one another.
\n\nThe observed values are given below.
\n\n | \\(12\\le age<15\\) | \n\\(15\\le age<18\\) | \n\\(18\\le age<21\\) | \nRow Sum | \n
Very Active | \n{n11} | \n{n12} | \n{n13} | \n\\(\\simplify{{n11}+{n12}+{n13}}\\) | \n
Active | \n{n21} | \n{n22} | \n{n23} | \n\\(\\simplify{{n21}+{n22}+{n23}}\\) | \n
Inactive | \n{n31} | \n{n32} | \n{n33} | \n\\(\\simplify{{n31}+{n32}+{n33}}\\) | \n
Column Sum | \n\\(\\simplify{{n11}+{n21}+{n31}}\\) | \n\\(\\simplify{{n12}+{n22}+{n32}}\\) | \n\\(\\simplify{{n13}+{n23}+{n33}}\\) | \n\n |
The expected values can be calculated using the formula:
\n\\(e_{i,j}=\\frac{(sum\\,of\\,row\\,i)*(sum\\,of\\,column\\,j)}{Overall\\,total\\,sum}\\)
\n\n\n | \\(12\\le age<15\\) | \n\\(15\\le age<18\\) | \n\\(18\\le age<21\\) | \n
Very Active | \n{e11} | \n{e12} | \n{e13} | \n
Active | \n{e21} | \n{e22} | \n{e23} | \n
Inactive | \n{e31} | \n{e32} | \n{e33} | \n
The formula for the t-statistic:
\\(\\chi^2=\\sum{\\frac{(obs-exp)^2}{exp}}\\)
\n\\(\\chi^2=\\frac{(\\var{n11}-\\var{e11})^2}{\\var{e11}}+\\frac{(\\var{n12}-\\var{e12})^2}{\\var{e12}}+\\frac{(\\var{n13}-\\var{e13})^2}{\\var{e13}}+\\frac{(\\var{n21}-\\var{e21})^2}{\\var{e21}}+\\frac{(\\var{n22}-\\var{e22})^2}{\\var{e22}}+\\frac{(\\var{n23}-\\var{e23})^2}{\\var{e23}}+\\frac{(\\var{n31}-\\var{e31})^2}{\\var{e31}}+\\frac{(\\var{n32}-\\var{e32})^2}{\\var{e32}}+\\frac{(\\var{n33}-\\var{e33})^2}{\\var{e33}}\\)
\n\\(\\chi^2=\\var{test_statistic}\\)
\nThe \\(\\chi^2\\) table values will be for a two-tailed test having \\((r-1)*(c-1)=2*2=4\\) degrees of freedom. We only need to consider the upper value.
\n\\(\\begin{array}{r|rrrr}&0.10&0.05&0.02\\\\\\hline3&\\var{Chi_90}&\\var{Chi_95}&\\var{Chi_98}\\end{array}\\)
\nCompare the test statistic with the \\(\\chi^2\\)-table values and choose your conclusion.
", "rulesets": {}, "extensions": ["stats"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"e11": {"name": "e11", "group": "Ungrouped variables", "definition": "precround(250*{r1}/690,1)", "description": "", "templateType": "anything", "can_override": false}, "n31": {"name": "n31", "group": "Ungrouped variables", "definition": "250-{n11}-{n21}", "description": "", "templateType": "anything", "can_override": false}, "r2": {"name": "r2", "group": "Ungrouped variables", "definition": "{n21}+{n22}+{n23}", "description": "", "templateType": "anything", "can_override": false}, "Chi_90": {"name": "Chi_90", "group": "Ungrouped variables", "definition": "9.488", "description": "", "templateType": "number", "can_override": false}, "n13": {"name": "n13", "group": "Ungrouped variables", "definition": "random(75 .. 80#1)", "description": "", "templateType": "randrange", "can_override": false}, "test_statistic": {"name": "test_statistic", "group": "Ungrouped variables", "definition": "precround(({n11}-{e11})^2/{e11}+({n12}-{e12})^2/{e12}+({n13}-{e13})^2/{e13}+({n21}-{e21})^2/{e21}+({n22}-{e22})^2/{e22}+({n23}-{e23})^2/{e23}+({n31}-{e31})^2/{e31}+({n32}-{e32})^2/{e32}+({n33}-{e33})^2/{e33},1)", "description": "", "templateType": "anything", "can_override": false}, "r1": {"name": "r1", "group": "Ungrouped variables", "definition": "{n11}+{n12}+{n13}", "description": "", "templateType": "anything", "can_override": false}, "e13": {"name": "e13", "group": "Ungrouped variables", "definition": "precround(200*{r1}/690,1)", "description": "", "templateType": "anything", "can_override": false}, "e31": {"name": "e31", "group": "Ungrouped variables", "definition": "precround(250*{r3}/690,1)", "description": "", "templateType": "anything", "can_override": false}, "n32": {"name": "n32", "group": "Ungrouped variables", "definition": "240-{n12}-{n22}", "description": "", "templateType": "anything", "can_override": false}, "e21": {"name": "e21", "group": "Ungrouped variables", "definition": "precround(250*{r2}/690,1)", "description": "", "templateType": "anything", "can_override": false}, "r3": {"name": "r3", "group": "Ungrouped variables", "definition": "{n31}+{n32}+{n33}", "description": "", "templateType": "anything", "can_override": false}, "Chi_98": {"name": "Chi_98", "group": "Ungrouped variables", "definition": "13.28", "description": "", "templateType": "number", "can_override": false}, "e22": {"name": "e22", "group": "Ungrouped variables", "definition": "precround(240*{r2}/690,1)", "description": "", "templateType": "anything", "can_override": false}, "n11": {"name": "n11", "group": "Ungrouped variables", "definition": "random(120 .. 130#1)", "description": "", "templateType": "randrange", "can_override": false}, "n22": {"name": "n22", "group": "Ungrouped variables", "definition": "random(112 .. 130#1)", "description": "", "templateType": "randrange", "can_override": false}, "n12": {"name": "n12", "group": "Ungrouped variables", "definition": "random(90 .. 99#1)", "description": "", "templateType": "randrange", "can_override": false}, "Chi_95": {"name": "Chi_95", "group": "Ungrouped variables", "definition": "11.14", "description": "", "templateType": "number", "can_override": false}, "e12": {"name": "e12", "group": "Ungrouped variables", "definition": "precround(240*{r1}/690,1)", "description": "", "templateType": "anything", "can_override": false}, "e23": {"name": "e23", "group": "Ungrouped variables", "definition": "precround(200*{r2}/690,1)", "description": "", "templateType": "anything", "can_override": false}, "e32": {"name": "e32", "group": "Ungrouped variables", "definition": "precround(240*{r3}/690,1)", "description": "", "templateType": "anything", "can_override": false}, "n33": {"name": "n33", "group": "Ungrouped variables", "definition": "200-{n13}-{n23}", "description": "", "templateType": "anything", "can_override": false}, "e33": {"name": "e33", "group": "Ungrouped variables", "definition": "precround(200*{r3}/690,1)", "description": "", "templateType": "anything", "can_override": false}, "n23": {"name": "n23", "group": "Ungrouped variables", "definition": "random(86 .. 95#1)", "description": "", "templateType": "randrange", "can_override": false}, "n21": {"name": "n21", "group": "Ungrouped variables", "definition": "random(95 .. 104#1)", "description": "", "templateType": "randrange", "can_override": false}, "atvalue": {"name": "atvalue", "group": "Ungrouped variables", "definition": "abs(test_statistic)", "description": "", "templateType": "anything", "can_override": false}, "v": {"name": "v", "group": "Ungrouped variables", "definition": "if(atvalue>=Chi_98,[1,0,0,0],if(atvalue>=Chi_95,[0,1,0,0],if(atvalue>=Chi_90,[0,0,1,0],[0,0,0,1])))", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["test_statistic", "Chi_95", "Chi_98", "Chi_90", "n11", "n12", "n13", "n21", "n31", "n23", "n22", "n32", "n33", "r1", "r2", "r3", "e11", "e21", "e31", "e12", "e22", "e32", "e13", "e23", "e33", "atvalue", "v"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Enter the expected frequencies correct to one decimal place:
\n\n\n | \\(12\\le age<15\\) | \n\\(15\\le age<18\\) | \n\\(18\\le age<21\\) | \n
Very Active | \n[[0]] | \n[[1]] | \n[[2]] | \n
Active | \n[[3]] | \n[[4]] | \n[[5]] | \n
Inactive | \n[[6]] | \n[[7]] | \n[[8]] | \n
Enter the value for the appropriate test statistic: \\(\\chi^2\\) = [[9]]
", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{e11}", "maxValue": "{e11}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{e12}", "maxValue": "{e12}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{e13}", "maxValue": "{e13}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{e21}", "maxValue": "{e21}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": "2", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{e22}", "maxValue": "{e22}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{e23}", "maxValue": "{e23}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{e31}", "maxValue": "{e31}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "{e11}You have not given your answer to the correct precision.
", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{e32}", "maxValue": "{e32}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{e33}", "maxValue": "{e33}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "test_statistic", "maxValue": "test_statistic", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": "1", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "1_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [{"variable": "", "part": "p0", "must_go_first": false}], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Having compared your test statistic with the table values for a two-tailed \\(\\chi^2\\)-test, select one of the following answers that best describes your conclusion.
", "minMarks": "3", "maxMarks": "3", "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": "1", "showCellAnswerState": true, "choices": ["Reject the Null hypothesis that sporting activity and age profile are independent of one another.
", "Reject the Null Hypothesis at the 5% significance level but accept the Null Hypothesis at the 2% significance level and conclude that sporting activity and age profile are independent of one another.
", "Reject the Null Hypothesis at the 10% significance level but accept the Null Hypothesis at the 5% significance level and conclude that sporting activity and age profile are independent of one another.
", "Accept the Null Hypothesis at the 10% significance level and conclude that sporting activity and age profile are independent of one another.
"], "matrix": "v"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Frank Doheny", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/789/"}]}]}], "contributors": [{"name": "Frank Doheny", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/789/"}]}