// 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": [{"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

\n

The observed values are given below.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\\(12\\le age<15\\)\\(15\\le age<18\\)\\(18\\le age<21\\)Row Sum
Very Active{n11}{n12}{n13}\\(\\simplify{{n11}+{n12}+{n13}}\\)
Active{n21}{n22}{n23}\\(\\simplify{{n21}+{n22}+{n23}}\\)
Inactive{n31}{n32}{n33}\\(\\simplify{{n31}+{n32}+{n33}}\\)
Column Sum\\(\\simplify{{n11}+{n21}+{n31}}\\)\\(\\simplify{{n12}+{n22}+{n32}}\\)\\(\\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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\\(12\\le age<15\\)\\(15\\le age<18\\)\\(18\\le age<21\\)
Very Active{e11}{e12}{e13}
Active{e21}{e22}{e23}
Inactive{e31}{e32}{e33}
\n


The formula for the t-statistic:  

\n

\\(\\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}\\)

\n

The \\(\\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}\\)

\n

Compare the test statistic with the \\(\\chi^2\\)-table values and choose your conclusion.

", "variable_groups": [], "ungrouped_variables": ["test_statistic", "Chi_95", "scenario", "decision_matrix", "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"], "functions": {}, "extensions": ["stats"], "variablesTest": {"condition": "", "maxRuns": 100}, "type": "question", "statement": "

A social scientist was interested in the relationship between sporting activity and age. 

\n

People in different age groups were asked to categorise their involvement in sports under three headings:

\n

Very Active if they were members of a sports team

\n

Active if they played sports on a regular basis but not a member of a sports team.

\n

Inactive if they rarely or never played sports.

\n

The data collected is presented below:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\\(12\\le age<15\\)\\(15\\le age<18\\)\\(18\\le age<21\\)
Very Active{n11}{n12}{n13}
Active{n21}{n22}{n23}
Inactive{n31}{n32}{n33}
\n

\n

Test the hypothesis that Sporting activity and age profile are independent of one another.

\n

", "preamble": {"js": "", "css": ""}, "tags": [], "parts": [{"showFeedbackIcon": true, "marks": 0, "scripts": {}, "prompt": "

Enter the expected frequencies correct to one decimal place:

\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\\(12\\le age<15\\)\\(15\\le age<18\\)\\(18\\le age<21\\)
Very Active[[0]][[1]][[2]]
Active[[3]][[4]][[5]]
Inactive[[6]][[7]][[8]]
\n

Enter the value for the appropriate test statistic: \\(\\chi^2\\) = [[9]]

", "type": "gapfill", "gaps": [{"precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerStyle": "plain", "scripts": {}, "strictPrecision": false, "maxValue": "{e11}", "precisionType": "dp", "showPrecisionHint": false, "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": 1, "precision": "1", "allowFractions": false, "minValue": "{e11}", "precisionPartialCredit": 0, "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerStyle": "plain", "scripts": {}, "strictPrecision": false, "maxValue": "{e12}", "precisionType": "dp", "showPrecisionHint": false, "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": 1, "precision": "1", "allowFractions": false, "minValue": "{e12}", "precisionPartialCredit": 0, "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerStyle": "plain", "scripts": {}, "strictPrecision": false, "maxValue": "{e13}", "precisionType": "dp", "showPrecisionHint": false, "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": 1, "precision": "1", "allowFractions": false, "minValue": "{e13}", "precisionPartialCredit": 0, "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerStyle": "plain", "scripts": {}, "strictPrecision": false, "maxValue": "{e21}", "precisionType": "dp", "showPrecisionHint": false, "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": 1, "precision": "1", "allowFractions": false, "minValue": "{e21}", "precisionPartialCredit": 0, "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerStyle": "plain", "scripts": {}, "strictPrecision": false, "maxValue": "{e22}", "precisionType": "dp", "showPrecisionHint": false, "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": "2", "precision": "1", "allowFractions": false, "minValue": "{e22}", "precisionPartialCredit": 0, "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerStyle": "plain", "scripts": {}, "strictPrecision": false, "maxValue": "{e23}", "precisionType": "dp", "showPrecisionHint": false, "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": 1, "precision": "1", "allowFractions": false, "minValue": "{e23}", "precisionPartialCredit": 0, "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"precisionMessage": "

{e11}You have not given your answer to the correct precision.

", "correctAnswerStyle": "plain", "scripts": {}, "strictPrecision": false, "maxValue": "{e31}", "precisionType": "dp", "showPrecisionHint": false, "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": 1, "precision": "1", "allowFractions": false, "minValue": "{e31}", "precisionPartialCredit": 0, "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerStyle": "plain", "scripts": {}, "strictPrecision": false, "maxValue": "{e32}", "precisionType": "dp", "showPrecisionHint": false, "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": 1, "precision": "1", "allowFractions": false, "minValue": "{e32}", "precisionPartialCredit": 0, "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerStyle": "plain", "scripts": {}, "strictPrecision": false, "maxValue": "{e33}", "precisionType": "dp", "showPrecisionHint": false, "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": 1, "precision": "1", "allowFractions": false, "minValue": "{e33}", "precisionPartialCredit": 0, "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}, {"precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerStyle": "plain", "scripts": {}, "strictPrecision": false, "maxValue": "test_statistic", "precisionType": "dp", "showPrecisionHint": false, "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "numberentry", "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "marks": 1, "precision": "1", "allowFractions": false, "minValue": "test_statistic", "precisionPartialCredit": 0, "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false}], "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": 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.

"], "maxMarks": "3", "scripts": {}, "minMarks": "3", "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.

", "displayType": "radiogroup", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "type": "1_n_2", "shuffleChoices": false, "showFeedbackIcon": true, "marks": 0, "displayColumns": "1", "matrix": "decision_matrix", "variableReplacements": [{"part": "p0", "must_go_first": false, "variable": ""}]}], "rulesets": {}, "variables": {"n11": {"templateType": "randrange", "definition": "random(120..130#1)", "description": "", "group": "Ungrouped variables", "name": "n11"}, "Chi_95": {"templateType": "number", "definition": "11.14", "description": "", "group": "Ungrouped variables", "name": "Chi_95"}, "e11": {"templateType": "anything", "definition": "precround(250*{r1}/690,1)", "description": "", "group": "Ungrouped variables", "name": "e11"}, "n32": {"templateType": "anything", "definition": "240-{n12}-{n22}", "description": "", "group": "Ungrouped variables", "name": "n32"}, "n23": {"templateType": "randrange", "definition": "random(86..95#1)", "description": "", "group": "Ungrouped variables", "name": "n23"}, "test_statistic": {"templateType": "anything", "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": "", "group": "Ungrouped variables", "name": "test_statistic"}, "e23": {"templateType": "anything", "definition": "precround(200*{r2}/690,1)", "description": "", "group": "Ungrouped variables", "name": "e23"}, "e31": {"templateType": "anything", "definition": "precround(250*{r3}/690,1)", "description": "", "group": "Ungrouped variables", "name": "e31"}, "Chi_90": {"templateType": "number", "definition": "9.488", "description": "", "group": "Ungrouped variables", "name": "Chi_90"}, "e22": {"templateType": "anything", "definition": "precround(240*{r2}/690,1)", "description": "", "group": "Ungrouped variables", "name": "e22"}, "r2": {"templateType": "anything", "definition": "{n21}+{n22}+{n23}", "description": "", "group": "Ungrouped variables", "name": "r2"}, "r3": {"templateType": "anything", "definition": "{n31}+{n32}+{n33}", "description": "", "group": "Ungrouped variables", "name": "r3"}, "Chi_98": {"templateType": "number", "definition": "13.28", "description": "", "group": "Ungrouped variables", "name": "Chi_98"}, "n31": {"templateType": "anything", "definition": "250-{n11}-{n21}", "description": "", "group": "Ungrouped variables", "name": "n31"}, "e13": {"templateType": "anything", "definition": "precround(200*{r1}/690,1)", "description": "", "group": "Ungrouped variables", "name": "e13"}, "decision_matrix": {"templateType": "anything", "definition": "[\n [1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]\n][scenario]", "description": "", "group": "Ungrouped variables", "name": "decision_matrix"}, "n12": {"templateType": "randrange", "definition": "random(90..99#1)", "description": "", "group": "Ungrouped variables", "name": "n12"}, "e21": {"templateType": "anything", "definition": "precround(250*{r2}/690,1)", "description": "", "group": "Ungrouped variables", "name": "e21"}, "r1": {"templateType": "anything", "definition": "{n11}+{n12}+{n13}", "description": "", "group": "Ungrouped variables", "name": "r1"}, "e12": {"templateType": "anything", "definition": "precround(240*{r1}/690,1)", "description": "", "group": "Ungrouped variables", "name": "e12"}, "n22": {"templateType": "randrange", "definition": "random(112..130#1)", "description": "", "group": "Ungrouped variables", "name": "n22"}, "n21": {"templateType": "randrange", "definition": "random(95..104#1)", "description": "", "group": "Ungrouped variables", "name": "n21"}, "scenario": {"templateType": "anything", "definition": "sum(map(abs(test_statistic)