// Numbas version: finer_feedback_settings {"name": "Brad's copy of Perform chi-squared test for differences in preferences", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"metadata": {"description": "
Uses the $\\chi^2$ test to see if there is any significant difference in preferences.
", "licence": "Creative Commons Attribution 4.0 International"}, "advice": "\nStep 3
\n\n
Completing the table we have $E= \\var{t}/5=\\var{t/5}$ for all brands.
\nWe do the last column calculations for brand A.
\n$\\displaystyle \\frac{(O -E) ^ 2}{ E} = \\frac{(\\var{a} -\\var{e1}) ^ 2} {\\var{e1}} = \\var{x[0]}$
\nto 2 decimal places.
\n$O$ | $E$ | $\\displaystyle \\frac{(O-E)^2}{E}$ | |
---|---|---|---|
A | \n$\\var{a}$ | \n$\\var{e1}$ | \n$\\var{x[0]}$ | \n
B | \n$\\var{b}$ | \n$\\var{e1}$ | \n$\\var{x[1]}$ | \n
C | \n$\\var{c}$ | \n$\\var{e1}$ | \n$\\var{x[2]}$ | \n
D | \n$\\var{d}$ | \n$\\var{e1}$ | \n$\\var{x[3]}$ | \n
E | \n$\\var{f}$ | \n$\\var{e1}$ | \n$\\var{x[4]}$ | \n
\n | \n | \n | $\\chi^2=\\;\\var{chi}$ |
The test statistic is then:
\n\\[\\displaystyle \\chi ^ 2 = \\sum \\frac{(O -E)^2}{E} = \\var{x[0]} + \\var{x[1]} + \\var{x[2]} + \\var{x[3]} + \\var{x[4]} = \\var{chi}\\]
\nStep 4:
\nThe degrees of freedom is given by: $\\nu$= no. of categories $- 1 = 5-1=4$
\nThe following are the critical values for $\\nu=4$.
\n{table1([['Critical Value',{crit[0]},{crit[1]},{crit[2]}]],['p-value','10%','5%','1%'],false,false,false,false)}
\nLooking at this test statistic we see that the p-range {choices[pval]}.
\nThe conclusion we come to is that {correctc} Hence {correcth}
\n ", "extensions": ["stats"], "preamble": {"js": "", "css": ""}, "statement": "Some marketing research studies indicate the \"positive impact of store brand penetration on store profitability as measured by market share\" (Lal,M.C.(2000). Building Store Loyalty Through Store Brands, Journal of Marketing Research, 37, no. 3, pp281).
\nThe manager of a local supermarket that sells four national brands (A, B, C and D) and one store brand (E) of {this} wants to find out whether or not customers have a preference for a particular brand. Over the course of a {thislong}, the number of customers buying each brand of {this} was noted; the results are shown in the table below:
\n{table1([['A',{a}],['B',{b}],['C',{c}],['D',{d}],['E',{f}]],['Brand','No. of Customers'],true,false,false,true)}
\nTest the null hypothesis that, in fact, customers at this supermarket do not have a preference for a particular brand of {this}.
\n", "variables": {"choices": {"definition": "['is greater than $10$%','lies between $10$% and $5$%','lies between $5$% and $1$%','is smaller than $1$%']", "name": "choices", "templateType": "anything", "description": "", "group": "Ungrouped variables"}, "mm": {"definition": "switch(pval=0,[1,0,0,0],pval=1,[0,1,0,0],pval=2,[0,0,1,0],[0,0,0,1])", "name": "mm", "templateType": "anything", "description": "", "group": "Ungrouped variables"}, "w": {"definition": "random(1,-1)", "name": "w", "templateType": "anything", "description": "", "group": "Ungrouped variables"}, "pval": {"definition": "switch(chi
Step 1: Null hypothesis
\n$\\operatorname{H}_0:\\;$ Customers do not have a preference for a particular brand of {this}.
\nStep 2: Alternative hypothesis
\n$\\operatorname{H}_1:\\;$ Customers do have a preference for a particular brand of {this}.
\n\n ", "type": "information", "scripts": {}, "customMarkingAlgorithm": "", "showFeedbackIcon": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "showCorrectAnswer": true}, {"sortAnswers": false, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "customName": "", "unitTests": [], "prompt": "\n
Step 3: Test statistic
\nComplete the following table: (input all values in the expected column $E$ as exact decimals and input in the last column to 2 decimal places).
\n$O$ | $E$ | $\\displaystyle \\frac{(O-E)^2}{E}$ | |
---|---|---|---|
A | \n$\\var{a}$ | \n[[0]] | \n[[1]] | \n
B | \n$\\var{b}$ | \n[[2]] | \n[[3]] | \n
C | \n$\\var{c}$ | \n[[4]] | \n[[5]] | \n
D | \n$\\var{d}$ | \n[[6]] | \n[[7]] | \n
E | \n$\\var{f}$ | \n[[8]] | \n[[9]] | \n
Hence the test statistic is : $\\chi^2=\\;$[[10]]
\nInput the test statistic to 2 decimal places.
\n ", "type": "gapfill", "scripts": {}, "customMarkingAlgorithm": "", "gaps": [{"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "e1", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "e1", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0.2, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "x[0]-tol", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "x[0]+tol", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0.6, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "e1", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "e1", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0.2, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "x[1]-tol", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "x[1]+tol", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0.6, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "e1", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "e1", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0.2, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "x[2]-tol", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "x[2]+tol", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0.6, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "e1", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "e1", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0.2, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "x[3]-tol", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "x[3]+tol", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0.6, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "e1", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "e1", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0.2, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "x[4]-tol", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "x[4]+tol", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0.6, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "chi-tol", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "chi+tol", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 1, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}], "showFeedbackIcon": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "showCorrectAnswer": true}, {"sortAnswers": false, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "customName": "", "unitTests": [], "prompt": "\nStep 4: p-value range
\nCalculate , the degrees of freedom, for this test: $\\nu=\\;?$[[0]]
\nUse tables to find a range for your -value. Choose the correct choice below.
\n[[1]]
\n ", "type": "gapfill", "scripts": {}, "customMarkingAlgorithm": "", "gaps": [{"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "minValue": "n-1", "customName": "", "unitTests": [], "correctAnswerStyle": "plain", "type": "numberentry", "correctAnswerFraction": false, "scripts": {}, "customMarkingAlgorithm": "", "maxValue": "n-1", "mustBeReduced": false, "mustBeReducedPC": 0, "showFeedbackIcon": true, "showFractionHint": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 1, "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "allowFractions": false}, {"minMarks": 0, "choices": ["{choices[0]}", "{choices[1]}", "{choices[2]}", "{choices[3]}"], "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "shuffleChoices": false, "customName": "", "unitTests": [], "type": "1_n_2", "scripts": {}, "customMarkingAlgorithm": "", "matrix": "mm", "displayType": "radiogroup", "showCellAnswerState": true, "showFeedbackIcon": true, "maxMarks": 0, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "displayColumns": 0, "showCorrectAnswer": true}], "showFeedbackIcon": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "showCorrectAnswer": true}, {"sortAnswers": false, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "customName": "", "unitTests": [], "prompt": "\nStep 5: Conclusion
\nGiven the - value and the range you have found what is the strength of evidence against the null hypothesis?
\n[[0]]
\nYour Decision in relation to the null hypothesis:
\n[[1]]
\nConclusion:
\n[[2]]
\n ", "type": "gapfill", "scripts": {}, "customMarkingAlgorithm": "", "gaps": [{"minMarks": 0, "choices": ["{evi[0]}", "{evi[1]}", "{evi[2]}", "{evi[3]}"], "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "shuffleChoices": false, "customName": "", "unitTests": [], "type": "1_n_2", "scripts": {}, "customMarkingAlgorithm": "", "matrix": "mm", "displayType": "radiogroup", "showCellAnswerState": true, "showFeedbackIcon": true, "maxMarks": 0, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "displayColumns": 0, "showCorrectAnswer": true}, {"minMarks": 0, "choices": ["Retain", "Reject"], "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "shuffleChoices": false, "customName": "", "unitTests": [], "type": "1_n_2", "scripts": {}, "customMarkingAlgorithm": "", "matrix": "dmm", "displayType": "radiogroup", "showCellAnswerState": true, "showFeedbackIcon": true, "maxMarks": 0, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "displayColumns": 0, "showCorrectAnswer": true}, {"minMarks": 0, "choices": ["{fac}", "{correctc}"], "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "shuffleChoices": true, "customName": "", "unitTests": [], "type": "1_n_2", "scripts": {}, "customMarkingAlgorithm": "", "matrix": [0, 1], "displayType": "radiogroup", "showCellAnswerState": true, "showFeedbackIcon": true, "maxMarks": 0, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "displayColumns": 0, "distractors": ["", ""], "showCorrectAnswer": true}], "showFeedbackIcon": true, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "marks": 0, "showCorrectAnswer": true}], "variablesTest": {"condition": "", "maxRuns": 100}, "variable_groups": [], "type": "question", "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Brad Allison", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3394/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Brad Allison", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3394/"}]}