// Numbas version: finer_feedback_settings {"name": "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": [{"variable_groups": [], "variables": {"col1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "a+d+a1+d1+a2", "description": "", "name": "col1"}, "e10": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(r4*col1/tot,3)", "description": "", "name": "e10"}, "b": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..35)", "description": "", "name": "b"}, "f1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(10..18)", "description": "", "name": "f1"}, "e11": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(r4*col2/tot,3)", "description": "", "name": "e11"}, "d1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(12..20)", "description": "", "name": "d1"}, "pval": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(ch=2,'There is evidence to suggest an association between degree subject and performance.','There is no evidence to suggest an association between degree subject and performance.')", "description": "", "name": "summary"}, "ch7": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((a1-e7)^2/e7,3)", "description": "", "name": "ch7"}, "a": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(15..35)", "description": "", "name": "a"}, "c": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(10..22)", "description": "", "name": "c"}, "ch": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ch1+ch2+ch3+ch4+ch5+ch6+ch7+ch8+ch9+ch10+ch11+ch12+ch13+ch14+ch15,3)", "description": "", "name": "ch"}, "e6": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(r2*col3/tot,3)", "description": "", "name": "e6"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(15..25)", "description": "", "name": "t"}, "a1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(10..20)", "description": "", "name": "a1"}, "col3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "c+t+c1+t1+c2", "description": "", "name": "col3"}, "e8": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(r3*col2/tot,3)", "description": "", "name": "e8"}, "ch6": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((t-e6)^2/e6,3)", "description": "", "name": "ch6"}, "e9": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(r3*col3/tot,3)", "description": "", "name": "e9"}, "presult": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pval=0,'is greater than $10$%',pval=1,'lies between $10$% and $5$%',pval=2,'lies between $5$% and $1$%','is less than $1$%')", "description": "", "name": "presult"}, "mm": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pval=0,[1,0,0,0],pval=1,[0,1,0,0],pval=2,[0,0,1,0],[0,0,0,1])", "description": "", "name": "mm"}, "e2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(r1*col2/tot,3)", "description": "", "name": "e2"}, "e1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(r1*col1/tot,3)", "description": "", "name": "e1"}, "e14": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(r5*col2/tot,3)", "description": "", "name": "e14"}, "f": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(15..25)", "description": "", "name": "f"}, "b1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(10..22)", "description": "", "name": "b1"}, "t99": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20.09", "description": "", "name": "t99"}, "r3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "a1+b1+c1", "description": "", "name": "r3"}, "ch3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((c-e3)^2/e3,3)", "description": "", "name": "ch3"}, "ch4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((d-e4)^2/e4,3)", "description": "", "name": "ch4"}, "retain": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(pval>=2,'reject $H_0$ and accept $H_1$','retain $H_0$')", "description": "", "name": "retain"}, "evi": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pval=0,'no',pval=1,'slight',pval=2,'moderate','strong')", "description": "", "name": "evi"}, "ch9": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((c1-e9)^2/e9,3)", "description": "", "name": "ch9"}, "ch13": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((a2-e13)^2/e13,3)", "description": "", "name": "ch13"}}, "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"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "name": "Perform chi-squared test on 2D frequency table", "functions": {}, "showQuestionGroupNames": false, "parts": [{"type": "information", "prompt": "\n\n\n

Step 1: Null hypothesis

\n\n\n\n

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

\n\n\n\n

Step 2: Alternate hypothesis

\n\n\n\n

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

\n\n\n \n", "showCorrectAnswer": true, "scripts": {}, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "e7", "minValue": "e7", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "e8", "minValue": "e8", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "e9", "minValue": "e9", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "e13", "minValue": "e13", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "e14", "minValue": "e14", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "e15", "minValue": "e15", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ch+0.006", "minValue": "ch-0.006", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "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

Input the test statistic to $3$ decimal places.

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "8", "minValue": "8", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"displayType": "radiogroup", "choices": ["

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

", "

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

", "

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

", "

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

"], "displayColumns": 1, "distractors": ["", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "Mm", "marks": 0}], "type": "gapfill", "prompt": "\n

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]]

\n \n", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"displayType": "radiogroup", "choices": ["

None

", "

Slight

", "

Moderate

", "

Strong

"], "displayColumns": 0, "distractors": ["", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "Mm", "marks": 0}, {"displayType": "radiogroup", "choices": ["

Retain $H_0$

", "

Reject $H_0$

"], "displayColumns": 0, "distractors": ["", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": ["if(pval<2,1,0)", "if(pval>=2,1,0)"], "marks": 0}, {"displayType": "radiogroup", "choices": ["

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

", "

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

"], "displayColumns": 1, "distractors": ["", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": ["if(pval>=2,1,0)", "if(pval<2,1,0)"], "marks": 0}], "type": "gapfill", "prompt": "\n

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]]

\n \n", "showCorrectAnswer": true, "marks": 0}], "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", "tags": ["checked2015", "MAS1403"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

3/01/2012:

\n \t\t

This is the example used in the mathssample exam and was translated from the iassess MAS1403 originally. The table is not created from the inbuilt table function. Included tag sc to indicate that this can be used for other applications.

\n \t\t", "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.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

Step 3

\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

Step 4

\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

Step 5: Conclusion

\n

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

\n

Hence we {retain}.

\n

{summary}

", "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}