// Numbas version: exam_results_page_options {"name": "Bivariate categorical data and chi squared test", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"tags": [], "rulesets": {}, "extensions": [], "preamble": {"css": "", "js": ""}, "statement": "

In this question, you will be completing two way tables and calculating associated probabilities. Then you will calculate the expected frequencies under the assumption of independence between the two variables before finding the chi squared statistic for the original observations in the first table. This will then be used to test the assumption that the two variables presented in the data table are independent.

\n

\n

As you progress through the question, you might like to check your working after each stage, as the subsequent stages rely on correct answers to previous stages.

", "variablesTest": {"maxRuns": 100, "condition": ""}, "name": "Bivariate categorical data and chi squared test", "parts": [{"showFeedbackIcon": true, "scripts": {}, "customName": "Two-way table", "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "gaps": [{"showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "minValue": "{a11}", "customName": "", "allowFractions": false, "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "marks": 1, "scripts": {}, "maxValue": "{a11}", "useCustomName": false, "type": "numberentry", "mustBeReducedPC": 0, "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "correctAnswerStyle": "plain", "showFractionHint": true}, {"showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "minValue": "{a12}", "customName": "", "allowFractions": false, "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "marks": 1, "scripts": {}, "maxValue": "{a12}", "useCustomName": false, "type": "numberentry", "mustBeReducedPC": 0, "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "correctAnswerStyle": "plain", "showFractionHint": true}, {"showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "minValue": "{a22}", "customName": "", "allowFractions": false, "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "marks": 1, "scripts": {}, "maxValue": "{a22}", "useCustomName": false, "type": "numberentry", "mustBeReducedPC": 0, "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "correctAnswerStyle": "plain", "showFractionHint": true}, {"showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "minValue": "{a11+a21}", "customName": "", "allowFractions": false, "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "marks": 1, "scripts": {}, "maxValue": "{a11+a21}", "useCustomName": false, "type": "numberentry", "mustBeReducedPC": 0, "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "correctAnswerStyle": "plain", "showFractionHint": true}, {"showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "minValue": "{total}", "customName": "", "allowFractions": false, "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "marks": 1, "scripts": {}, "maxValue": "{total}", "useCustomName": false, "type": "numberentry", "mustBeReducedPC": 0, "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "correctAnswerStyle": "plain", "showFractionHint": true}], "unitTests": [], "marks": 0, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "prompt": "

Calculate and fill in the missing quantities in the two-way table.

\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
Preference
ABTOTAL
GroupC[[0]][[1]]{A11+a12}
D{A21}[[2]]{A21+a22}
TOTAL[[3]]{A12+a22}[[4]]
\n

\n

", "variableReplacements": [], "useCustomName": true}, {"showFeedbackIcon": true, "scripts": {}, "customName": "Percentages", "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "gaps": [{"showFeedbackIcon": true, "precision": "1", "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "strictPrecision": false, "marks": 1, "scripts": {}, "customName": "", "type": "numberentry", "mustBeReducedPC": 0, "useCustomName": false, "correctAnswerFraction": false, "minValue": "{a11}/(a11+a12)*100", "customMarkingAlgorithm": "", "precisionType": "dp", "precisionPartialCredit": 0, "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "extendBaseMarkingAlgorithm": true, "maxValue": "{a11}/(a11+a12)*100", "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": false, "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "precision": "1", "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "strictPrecision": false, "marks": 1, "scripts": {}, "customName": "", "type": "numberentry", "mustBeReducedPC": 0, "useCustomName": false, "correctAnswerFraction": false, "minValue": "{a12}/(a11+a12)*100", "customMarkingAlgorithm": "", "precisionType": "dp", "precisionPartialCredit": 0, "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "extendBaseMarkingAlgorithm": true, "maxValue": "{a12}/(a11+a12)*100", "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": false, "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "precision": "1", "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "strictPrecision": false, "marks": 1, "scripts": {}, "customName": "", "type": "numberentry", "mustBeReducedPC": 0, "useCustomName": false, "correctAnswerFraction": false, "minValue": "{a22/(a21+a22)*100}", "customMarkingAlgorithm": "", "precisionType": "dp", "precisionPartialCredit": 0, "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "extendBaseMarkingAlgorithm": true, "maxValue": "{a22/(a21+a22)*100}", "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": false, "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "precision": "1", "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "strictPrecision": false, "marks": 1, "scripts": {}, "customName": "", "type": "numberentry", "mustBeReducedPC": 0, "useCustomName": false, "correctAnswerFraction": false, "minValue": "{(a11+a21)/(a11+a21+a22+a12)*100}", "customMarkingAlgorithm": "", "precisionType": "dp", "precisionPartialCredit": 0, "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "extendBaseMarkingAlgorithm": true, "maxValue": "{(a11+a21)/(a11+a21+a22+a12)*100}", "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": false, "correctAnswerStyle": "plain"}], "unitTests": [], "marks": 0, "extendBaseMarkingAlgorithm": true, "type": "gapfill", "sortAnswers": false, "prompt": "

Now complete the row percentage version of the two-way table. Round your answers to 1 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\n\n\n\n\n\n\n\n
Preference
ABTOTAL
GroupC[[0]][[1]]100%
D{precround(A21/(a21+a22)*100,1)}[[2]]100%
TOTAL[[3]]{precround((A12+a22)/(a11+a21+a22+a12)*100,1)}100%
\n

\n

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

Under the assumption of independence, that is that there is no relationship between group membership and preference, what would the expected frequencies be in the two-way table? Calculate them and put your answers in the table 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
Preference
ABTOTAL
GroupC[[0]][[1]]{a11+a12}
D[[2]][[3]]{a21+a22}
TOTAL{a11+a21}{a12+a22}{total}
\n

\n

", "variableReplacements": [], "useCustomName": true}, {"showFeedbackIcon": true, "precision": "2", "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "strictPrecision": false, "marks": 1, "scripts": {}, "customName": "chi-squared statistic", "type": "numberentry", "mustBeReducedPC": 0, "useCustomName": true, "correctAnswerFraction": false, "minValue": "chisq", "customMarkingAlgorithm": "", "precisionType": "dp", "precisionPartialCredit": 0, "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "showCorrectAnswer": true, "unitTests": [], "extendBaseMarkingAlgorithm": true, "maxValue": "chisq", "prompt": "

Now that you have the expected and observed frequencies, calculate the chi-squared statistic and enter the value (round to two decimal places) below.

\n

\n

", "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "showPrecisionHint": false, "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "displayColumns": 0, "customName": "How likely is that?", "showCellAnswerState": true, "useCustomName": true, "marks": 0, "scripts": {}, "type": "1_n_2", "shuffleChoices": false, "displayType": "radiogroup", "maxMarks": 0, "variableReplacements": [], "minMarks": 0, "distractors": ["", "", "", "", ""], "customMarkingAlgorithm": "", "showCorrectAnswer": true, "unitTests": [], "extendBaseMarkingAlgorithm": true, "matrix": ["if(chisq<=1.32,1,0)", "if(chisq>1.32,if(chisq<=2.71,1,0),0)", "if(chisq>2.71,if(chisq<=3.84,1,0),0)", "if(chisq>3.84,if(chisq<=6.63,1,0),0)", "if(chisq>6.63,1,0)"], "prompt": "

Based on what you have calculated in the parts so far, use the following chi square table to make a conclusion about the independence of the two variables represented in the data.

\n

The chi square statistic calculated in the previous part of the question lies between

\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\n\n\n\n
Degrees of freedomProbability of a larger chi squared value
0.250.10.050.01
11.322.713.846.63
22.774.615.999.21
34.116.257.8111.34
45.397.789.4913.28
", "choices": ["greater than or equal to 0.25", "less than 0.25 but greater than or equal to 0.1", "less than 0.1 but greater than or equal to 0.05", "less than 0.05 but greater than or equal to 0.01", "less than 0.01"], "variableReplacementStrategy": "originalfirst"}, {"showFeedbackIcon": true, "displayColumns": 0, "customName": "Conclusion", "showCellAnswerState": true, "useCustomName": true, "marks": 0, "scripts": {}, "type": "1_n_2", "shuffleChoices": false, "displayType": "radiogroup", "maxMarks": 0, "variableReplacements": [], "minMarks": 0, "distractors": ["", ""], "customMarkingAlgorithm": "", "showCorrectAnswer": true, "unitTests": [], "extendBaseMarkingAlgorithm": true, "matrix": ["if(chisq>3.84,1,0)", "if(chisq<=3.84,1,0)"], "prompt": "

Given the calculated chi squared statistic, and how likely it is to obtain this under the assumption that the variables are independent, which of the followin is the correct conclusion? Assume we require a confidence level of 0.05.

", "choices": ["The assumption of independence should be rejected because it is so unlikely that this data would be observed if the variables were truly independent.", "The assumption of independence should be maintained as an assumption as it's not that unlikely to observe this data, given the variables are independent."], "variableReplacementStrategy": "originalfirst"}], "variables": {"e21": {"definition": "(a11+a21)*(a21+a22)/total", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "e21"}, "A12": {"definition": "random(30 .. 120#1)", "description": "", "templateType": "randrange", "group": "Ungrouped variables", "name": "A12"}, "e11": {"definition": "(a11+a12)*(a11+a21)/total", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "e11"}, "A21": {"definition": "random(40 .. 130#1)", "description": "", "templateType": "randrange", "group": "Ungrouped variables", "name": "A21"}, "chisq": {"definition": "(a11-e11)^2/e11+(a12-e12)^2/e12+(a21-e21)^2/e21+(a22-e22)^2/e22", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "chisq"}, "Total": {"definition": "a11+a12+a21+a22", "description": "

The total of the sample for the 2 way table.

", "templateType": "anything", "group": "Ungrouped variables", "name": "Total"}, "e22": {"definition": "(a21+a22)*(a12+a22)/total", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "e22"}, "e12": {"definition": "(a11+a12)*(a12+a22)/total", "description": "", "templateType": "anything", "group": "Ungrouped variables", "name": "e12"}, "A22": {"definition": "random(40 .. 160#1)", "description": "", "templateType": "randrange", "group": "Ungrouped variables", "name": "A22"}, "A11": {"definition": "random(30 .. 120#1)", "description": "", "templateType": "randrange", "group": "Ungrouped variables", "name": "A11"}}, "advice": "", "variable_groups": [], "ungrouped_variables": ["Total", "A11", "A12", "A21", "A22", "e11", "e12", "e21", "e22", "chisq"], "metadata": {"licence": "All rights reserved", "description": "This question provides students with an example that requires them to fill in missing quantities in a two-way frequency table for bivariate categorical data, calculate percentages from that table, and to test for independence between the variables using a chi square test."}, "functions": {}, "type": "question", "contributors": [{"name": "Dann Mallet", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/800/"}]}]}], "contributors": [{"name": "Dann Mallet", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/800/"}]}