// Numbas version: exam_results_page_options {"name": "Simon's copy of Perform chi-squared test on 2D frequency table", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"ch11": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch11", "definition": "precround((f1-e11)^2/e11,3)"}, "t90": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "t90", "definition": "13.36"}, "r5": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "r5", "definition": "a2+b2+c2"}, "ch7": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch7", "definition": "precround((a1-e7)^2/e7,3)"}, "f": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "f", "definition": "random(15..25)"}, "ch13": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch13", "definition": "precround((a2-e13)^2/e13,3)"}, "ch12": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch12", "definition": "precround((t1-e12)^2/e12,3)"}, "r2": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "r2", "definition": "d+f+t"}, "summary": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "summary", "definition": "if(pval>=2,'There is evidence to suggest an association between degree subject and performance.','There is insufficient evidence to suggest an association between degree subject and performance.')"}, "tot": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "tot", "definition": "col1+col2+col3"}, "e1": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "e1", "definition": "precround(r1*col1/tot,3)"}, "ch5": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch5", "definition": "precround((f-e5)^2/e5,3)"}, "ch": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch", "definition": "precround(ch1+ch2+ch3+ch4+ch5+ch6+ch7+ch8+ch9+ch10+ch11+ch12+ch13+ch14+ch15,3)"}, "col2": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "col2", "definition": "b+f+b1+f1+b2"}, "f1": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "f1", "definition": "random(10..18)"}, "ch1": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch1", "definition": "precround((a-e1)^2/e1,3)"}, "ch14": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch14", "definition": "precround((b2-e14)^2/e14,3)"}, "e2": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "e2", "definition": "precround(r1*col2/tot,3)"}, "a": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "a", "definition": "random(15..35)"}, "e3": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "e3", "definition": "precround(r1*col3/tot,3)"}, "ch10": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch10", "definition": "precround((d1-e10)^2/e10,3)"}, "r1": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "r1", "definition": "a+b+c"}, "mm": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "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])"}, "ch9": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch9", "definition": "precround((c1-e9)^2/e9,3)"}, "t99": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "t99", "definition": "20.09"}, "ch8": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch8", "definition": "precround((b1-e8)^2/e8,3)"}, "a2": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "a2", "definition": "random(20..35)"}, "b2": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "b2", "definition": "random(10..20)"}, "e9": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "e9", "definition": "precround(r3*col3/tot,3)"}, "c2": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "c2", "definition": "random(5..15)"}, "ch4": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "ch4", "definition": "precround((d-e4)^2/e4,3)"}, "e8": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "e8", "definition": "precround(r3*col2/tot,3)"}, "e13": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "e13", "definition": "precround(r5*col1/tot,3)"}, "retain": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "retain", "definition": "if(pval>=2,'reject $H_0$ and accept $H_1$','retain $H_0$')"}, "r3": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "r3", "definition": "a1+b1+c1"}, "pval": {"group": "Ungrouped variables", "templateType": "anything", "description": "", "name": "pval", "definition": "switch(ch\n

(a)

\n

The expected frequencies are given by replacing a value in the table by the expected value:

\n

\\[E = \\frac{\\textrm{row total} \\times \\textrm{column total}}{\\textrm{overall total}}\\]

\n

For example, the Excellent category for Marketing & Management lies in the second row (with sum $\\var{r2}$) and the first column (with sum $\\var{col1}$).

\n

So the expected frequency of Excellent Marketing & Management students is:
\\[E = \\simplify[]{({r2}*{col1})/({tot})} = \\var{e4}\\]

\n

Hence we get the following table of expected frequencies:

\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
EXPECTED FREQUENCIESExcellentStrongAverage
Marketing{e1}{e2}{e3}
Marketing & Management{e4}{e5}{e6}
Business Management{e7}{e8}{e9}
Accounting & Finance{e10}{e11}{e12}
Mathematics{e13}{e14}{e15}
\n

In order to test to see if there is an association we compare this table with the table of observed values and calculate the test statistic by looking at

\n

\\[\\chi^2 = \\sum \\frac{(O - E)^2}{E}\\]

\n

Calculating the values for Business Management and Mathematics, all to 3 decimal places, you should obtain:

\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
$\\frac{(O - E)^2}{E}$ExcellentStrongAverage
Marketing{ch1}{ch2}{ch3}
Marketing & Management{ch4}{ch5}{ch6}
Business Management{ch7}{ch8}{ch9}
Accounting & Finance{ch10}{ch11}{ch12}
Mathematics{ch13}{ch14}{ch15}
\n

To find the $\\chi^2$ statistic you sum these fifteen values to get:

\n

\\[\\begin{eqnarray} \\chi^2 &=& \\var{ch1} + \\var{ch2} + \\var{ch3} + \\var{ch4} + \\var{ch5} +\\\\ && \\var{ch6} + \\var{ch7} + \\var{ch8} + \\var{ch9} + \\var{ch10} +\\\\ && \\var{ch11} + \\var{ch12} + \\var{ch13} + \\var{ch14} + \\var{ch15} \\\\ &=& \\var{ch}. \\end{eqnarray}\\]

\n

\n

\n

(b)

\n

The degrees of freedom is given by:

\n

\\[\\nu = (\\textrm{no. of rows} - 1) \\times (\\textrm{no. of columns} - 1) = 4 \\times 2 = 8\\]

\n

The following are the critical values for $\\nu = 8$:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$p$-value$10 \\%$$5 \\%$$1 \\%$
Critical value$\\var{t90}$$\\var{t95}$$\\var{t99}$
\n

Comparing these values with the the test statistic we see that the $p$-value {pResult}.

\n

\n

\n

\n

(c)

\n

As the $p$-value {pResult}, there is {evi} evidence against $H_0$.

\n

Hence we {retain}.

\n

{summary}

", "preamble": {"css": "", "js": ""}, "tags": [], "parts": [{"customMarkingAlgorithm": "", "marks": 0, "unitTests": [], "variableReplacementStrategy": "originalfirst", "useCustomName": false, "type": "information", "showFeedbackIcon": true, "variableReplacements": [], "showCorrectAnswer": true, "prompt": "

Step 1: Null hypothesis

\n

$H_0$: There is no association between degree subject and performance.

\n

Step 2: Alternate hypothesis

\n

$H_1$: There is an association between degree subject and performance.

", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"customMarkingAlgorithm": "", "marks": 0, "unitTests": [], "variableReplacementStrategy": "originalfirst", "useCustomName": false, "type": "gapfill", "showFeedbackIcon": true, "sortAnswers": false, "variableReplacements": [], "showCorrectAnswer": true, "gaps": [{"variableReplacementStrategy": "originalfirst", "unitTests": [], "strictPrecision": false, "useCustomName": false, "showPrecisionHint": false, "minValue": "e7", "showFeedbackIcon": true, "precision": "3", "allowFractions": false, "notationStyles": ["plain", "en", "si-en"], "precisionMessage": "You have not given your answer to the correct precision.", "mustBeReducedPC": 0, "mustBeReduced": false, "correctAnswerStyle": "plain", "correctAnswerFraction": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "marks": 1, "precisionPartialCredit": 0, "precisionType": "dp", "variableReplacements": [], "type": "numberentry", "maxValue": "e7", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"variableReplacementStrategy": "originalfirst", "unitTests": [], "strictPrecision": false, "useCustomName": false, "showPrecisionHint": false, "minValue": "e8", "showFeedbackIcon": true, "precision": "3", "allowFractions": false, "notationStyles": ["plain", "en", "si-en"], "precisionMessage": "You have not given your answer to the correct precision.", "mustBeReducedPC": 0, "mustBeReduced": false, "correctAnswerStyle": "plain", "correctAnswerFraction": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "marks": 1, "precisionPartialCredit": 0, "precisionType": "dp", "variableReplacements": [], "type": "numberentry", "maxValue": "e8", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"variableReplacementStrategy": "originalfirst", "unitTests": [], "strictPrecision": false, "useCustomName": false, "showPrecisionHint": false, "minValue": "e9", "showFeedbackIcon": true, "precision": "3", "allowFractions": false, "notationStyles": ["plain", "en", "si-en"], "precisionMessage": "You have not given your answer to the correct precision.", "mustBeReducedPC": 0, "mustBeReduced": false, "correctAnswerStyle": "plain", "correctAnswerFraction": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "marks": 1, "precisionPartialCredit": 0, "precisionType": "dp", "variableReplacements": [], "type": "numberentry", "maxValue": "e9", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"variableReplacementStrategy": "originalfirst", "unitTests": [], "strictPrecision": false, "useCustomName": false, "showPrecisionHint": false, "minValue": "e13", "showFeedbackIcon": true, "precision": "3", "allowFractions": false, "notationStyles": ["plain", "en", "si-en"], "precisionMessage": "You have not given your answer to the correct precision.", "mustBeReducedPC": 0, "mustBeReduced": false, "correctAnswerStyle": "plain", "correctAnswerFraction": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "marks": 1, "precisionPartialCredit": 0, "precisionType": "dp", "variableReplacements": [], "type": "numberentry", "maxValue": "e13", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"variableReplacementStrategy": "originalfirst", "unitTests": [], "strictPrecision": false, "useCustomName": false, "showPrecisionHint": false, "minValue": "e14", "showFeedbackIcon": true, "precision": "3", "allowFractions": false, "notationStyles": ["plain", "en", "si-en"], "precisionMessage": "You have not given your answer to the correct precision.", "mustBeReducedPC": 0, "mustBeReduced": false, "correctAnswerStyle": "plain", "correctAnswerFraction": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "marks": 1, "precisionPartialCredit": 0, "precisionType": "dp", "variableReplacements": [], "type": "numberentry", "maxValue": "e14", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"variableReplacementStrategy": "originalfirst", "unitTests": [], "strictPrecision": true, "useCustomName": false, "showPrecisionHint": false, "minValue": "e15", "showFeedbackIcon": true, "precision": "3", "allowFractions": false, "notationStyles": ["plain", "en", "si-en"], "precisionMessage": "You have not given your answer to the correct precision.", "mustBeReducedPC": 0, "mustBeReduced": false, "correctAnswerStyle": "plain", "correctAnswerFraction": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "marks": 1, "precisionPartialCredit": 0, "precisionType": "dp", "variableReplacements": [], "type": "numberentry", "maxValue": "e15", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"variableReplacementStrategy": "originalfirst", "unitTests": [], "strictPrecision": false, "useCustomName": false, "showPrecisionHint": true, "minValue": "ch-0.005", "showFeedbackIcon": true, "precision": "3", "allowFractions": false, "notationStyles": ["plain", "en", "si-en"], "precisionMessage": "You have not given your answer to the correct precision.", "mustBeReducedPC": 0, "mustBeReduced": false, "correctAnswerStyle": "plain", "correctAnswerFraction": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "marks": 1, "precisionPartialCredit": 0, "precisionType": "dp", "variableReplacements": [], "type": "numberentry", "maxValue": "ch+0.005", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}], "prompt": "

Step 3: Test statistic

\n

You are given the expected frequencies (all to $3$ decimal places) for Marketing, Marketing & Management and Accounting & Finance.

\n

You have to calculate the expected frequencies for Business Management and Mathematics and put them in the following table.

\n

Input each expected frequency to $3$ decimal places.

\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
EXPECTED FREQUENCIESExcellentStrongAverage
Marketing{e1}{e2}{e3}
Marketing & Management{e4}{e5}{e6}
Business Management[[0]][[1]][[2]]
Accounting & Finance{e10}{e11}{e12}
Mathematics[[3]][[4]][[5]]
\n

In order to test to see if there is an association we compare this table with the table of observed values and calculate the test statistic by finding:

\n

\\[\\chi^2 = \\sum \\frac{(O - E)^2}{E}\\]

\n

Now calculate the test statistic $\\chi^2 = \\phantom{{}}$[[6]] 

\n

", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"customMarkingAlgorithm": "", "marks": 0, "unitTests": [], "variableReplacementStrategy": "originalfirst", "useCustomName": false, "type": "gapfill", "showFeedbackIcon": true, "sortAnswers": false, "variableReplacements": [], "showCorrectAnswer": true, "gaps": [{"allowFractions": false, "correctAnswerFraction": false, "customMarkingAlgorithm": "", "marks": 1, "unitTests": [], "showFractionHint": true, "minValue": "8", "variableReplacementStrategy": "originalfirst", "useCustomName": false, "type": "numberentry", "showFeedbackIcon": true, "variableReplacements": [], "showCorrectAnswer": true, "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "maxValue": "8", "scripts": {}, "mustBeReduced": false, "correctAnswerStyle": "plain", "customName": "", "extendBaseMarkingAlgorithm": true}, {"minMarks": 0, "customMarkingAlgorithm": "", "marks": 0, "unitTests": [], "maxMarks": 0, "showCellAnswerState": true, "variableReplacementStrategy": "originalfirst", "useCustomName": false, "type": "1_n_2", "showFeedbackIcon": true, "choices": ["

$p$ is bigger than $10 \\%$

", "

$p$ lies between $10 \\%$ and $5 \\%$

", "

$p$ lies between $5 \\%$ and $1 \\%$

", "

$p$ is less than $1 \\%$

"], "variableReplacements": [], "showCorrectAnswer": true, "displayType": "radiogroup", "matrix": "Mm", "shuffleChoices": false, "displayColumns": 1, "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}], "prompt": "

Step 4: $p$-value range

\n

Calculate $\\nu$, the degrees of freedom, for this test.

\n

$\\nu = \\phantom{{}}$[[0]]

\n

Use tables to find a range for your $p$-value. Choose from the options below.

\n

[[1]]

", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"customMarkingAlgorithm": "", "marks": 0, "unitTests": [], "variableReplacementStrategy": "originalfirst", "useCustomName": false, "type": "gapfill", "showFeedbackIcon": true, "sortAnswers": false, "variableReplacements": [], "showCorrectAnswer": true, "gaps": [{"minMarks": 0, "customMarkingAlgorithm": "", "marks": 0, "unitTests": [], "maxMarks": 0, "showCellAnswerState": true, "variableReplacementStrategy": "originalfirst", "useCustomName": false, "type": "1_n_2", "showFeedbackIcon": true, "choices": ["

None

", "

Slight

", "

Moderate

", "

Strong

"], "variableReplacements": [], "showCorrectAnswer": true, "displayType": "radiogroup", "matrix": "Mm", "shuffleChoices": false, "displayColumns": 0, "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"minMarks": 0, "customMarkingAlgorithm": "", "marks": 0, "unitTests": [], "distractors": ["", ""], "maxMarks": 0, "showCellAnswerState": true, "variableReplacementStrategy": "originalfirst", "useCustomName": false, "type": "1_n_2", "showFeedbackIcon": true, "choices": ["

Retain $H_0$

", "

Reject $H_0$

"], "variableReplacements": [], "showCorrectAnswer": true, "displayType": "radiogroup", "matrix": ["if(pval<2,1,0)", "if(pval>=2,1,0)"], "shuffleChoices": false, "displayColumns": 0, "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}, {"minMarks": 0, "customMarkingAlgorithm": "", "marks": 0, "unitTests": [], "distractors": ["", ""], "maxMarks": 0, "showCellAnswerState": true, "variableReplacementStrategy": "originalfirst", "useCustomName": false, "type": "1_n_2", "showFeedbackIcon": true, "choices": ["

There is evidence to suggest an association between degree subject and performance.

", "

There is insufficient evidence to suggest an association between degree subject and performance.

"], "variableReplacements": [], "showCorrectAnswer": true, "displayType": "radiogroup", "matrix": ["if(pval>=2,1,0)", "if(pval<2,1,0)"], "shuffleChoices": false, "displayColumns": 1, "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}], "prompt": "

Step 5: Conclusion

\n

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis?

\n

[[0]]

\n

Your decision:

\n

[[1]]

\n

Your conclusion:

\n

[[2]]

", "scripts": {}, "customName": "", "extendBaseMarkingAlgorithm": true}], "ungrouped_variables": ["f1", "ch", "presult", "a", "d", "r2", "pval", "b1", "b2", "t95", "t1", "c1", "d1", "e11", "e10", "e13", "e12", "e15", "e14", "tot", "ch15", "e3", "b", "t", "r4", "ch13", "col2", "col3", "col1", "a1", "a2", "e9", "t99", "ch9", "e5", "e4", "e7", "e6", "e1", "c2", "e2", "ch12", "evi", "c", "ch11", "r1", "ch14", "f", "mm", "ch10", "r3", "summary", "t90", "ch1", "ch2", "ch3", "ch4", "ch5", "ch6", "ch7", "ch8", "retain", "r5", "e8"], "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

The human resources department of a large finance company is attempting to determine if an employee’s performance is influenced by their undergraduate degree subject. Personnel ratings are used to judge performance and the task is to use expected frequencies and the chi-squared statistic to test the null hypothesis that there is no association.

"}, "rulesets": {}, "statement": "\n

The human resources department of a large finance company is attempting to determine if an employee’s performance is influenced by their undergraduate degree subject.

\n

The 5 subjects considered are: Marketing, Marketing & Management, Business Management, Accounting & Finance and Mathematics.

\n

Personnel ratings are grouped as Excellent, Strong and Average.

\n

A recent assessment gave the following results:

\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 \n \n \n \n \n \n \n \n \n \n
 ExcellentStrongAverageTotals
Marketing{a}{b}{c}{r1}
Marketing & Management{d}{f}{t}{r2}
Business Management{a1}{b1}{c1}{r3}
Accounting & Finance{d1}{f1}{t1}{r4}
Mathematics{a2}{b2}{c2}{r5}
Totals{col1}{col2}{col3}{tot}
\n

Test the null hypothesis that there is no association between degree subject and performance.

\n", "variable_groups": [], "functions": {}, "extensions": ["stats"], "name": "Simon's copy of Perform chi-squared test on 2D frequency table", "type": "question", "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}]}