// Numbas version: finer_feedback_settings {"variable_groups": [], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Calculate Pearson correlation coefficient", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "darr(n,m,[random(1..20)])", "description": "", "name": "r1"}, "spxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sxy-t[0]*t[1]/n", "description": "", "name": "spxy"}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "description": "", "name": "ssq"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2)]", "description": "", "name": "t"}, "rr1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r1)", "description": "", "name": "rr1"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "description": "", "name": "n"}, "ssd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(x^2,x,d))", "description": "", "name": "ssd"}, "corrcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spxy/sqrt(ss[0]*ss[1]),3)", "description": "", "name": "corrcoef"}, "d": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(rr1)-vector(rr2))", "description": "", "name": "d"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20", "description": "", "name": "m"}, "spcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1-6*ssd/(n*(n^2-1)),3)", "description": "", "name": "spcoef"}, "vs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(aspcoef >=0.952,[1,0,0,0,0],aspcoef>=0.881,[0,1,0,0,0],aspcoef>=0.738,[0,0,1,0,0],aspcoef>=0.643,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "vs"}, "rr2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r2)", "description": "", "name": "rr2"}, "sxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "description": "", "name": "sxy"}, "aspcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "abs(spcoef)", "description": "", "name": "aspcoef"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(corrcoef >=0.847,[1,0,0,0,0],corrcoef>=0.765,[0,1,0,0,0],corrcoef>=0.632,[0,0,1,0,0],corrcoef>=0.549,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "obj": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['A','B','C','D','E','F','G','H','I','J']", "description": "", "name": "obj"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tesarr(r1,darr(n,m,[random(1..m)]),11,m)", "description": "", "name": "r2"}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "description": "", "name": "ss"}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n,t[1]^2/n]", "description": "", "name": "tsqovern"}}, "ungrouped_variables": ["aspcoef", "spcoef", "vs", "sxy", "spxy", "tol", "ssq", "corrcoef", "ssd", "rr2", "rr1", "r1", "tsqovern", "obj", "d", "r2", "ss", "k", "m", "n", "t", "v"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"darr": {"type": "list", "language": "jme", "definition": "if(n=1,a,darr(n-1,m,[random(1..m except a)]+a))", "parameters": [["n", "number"], ["m", "number"], ["a", "list"]]}, "rk": {"type": "list", "language": "javascript", "definition": "\n /*This gives the ranking of the entries in a, c counts the ties */\n var out = [];\n for(var j=0;ja[i]){s+=1;}\n else\n if(a[j]==a[i]){c+=1;}\n }\n out[j]=(2*s+c+1)/2;\n }\n return out;\n ", "parameters": [["a", "list"]]}, "pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}, "marr": {"type": "number", "language": "jme", "definition": "if(length(a)=2,max(a[0],a[1]),max(a[0],marr(a[1..length(a)])))", "parameters": [["a", "list"]]}, "tesarr": {"type": "list", "language": "jme", "definition": "if(marr(map(abs(x),x,list(vector(a)-vector(b))))\n \n Wife $(X)$\n $\\sum x=\\;$[[0]]\n $\\sum x^2=\\;$[[1]]\n \n Husband $(Y)$\n $\\sum y=\\;$[[2]]\n $\\sum y^2=\\;$[[3]]\n \n \n \n

Also find $\\sum xy=\\;$[[4]] and then:

\n

$\\displaystyle SSX = \\;$[[5]]

\n

$\\displaystyle SSY = \\;$[[6]]

\n

$\\displaystyle SPXY = \\;$[[7]]

\n

Hence calculate the correlation coefficient $r$:

\n

$r=\\;$[[8]]

\n

 

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.549", "minValue": "0.549", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.632", "minValue": "0.632", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.765", "minValue": "0.765", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.847", "minValue": "0.847", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"displayType": "radiogroup", "choices": ["$p \\leq 0.002$, very strong evidence to reject the null hypothesis that there is no association.", "$0.002 \\lt p \\leq 0.01$, strong evidence to reject the null hypothesis that there is no association.", "$0.01 \\lt p \\leq 0.05$, there is evidence to reject the null hypothesis that there is no association.", "$0.05 \\lt p \\leq 0.1$, weak evidence against, do not reject the null hypothesis but consider further investigation.", "$p \\gt 0.1$, no evidence to reject the null hypothesis that there is no association."], "displayColumns": 1, "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}], "type": "gapfill", "prompt": "\n

Give the value of the correlation coefficient you have found, choose the range for the $p$ value by looking up the relevant table. Input the required values from the table here:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.2\\%$
[[0]][[1]][[2]][[3]]
\n

Then make a decision based on the $p$-value you have found by choosing one of these options:

\n

[[4]]

\n ", "showCorrectAnswer": true, "marks": 0}], "statement": "

It is well known that similarity in attitudes, beliefs and interests plays an important role in interpersonal attraction. A researcher developed a questionnaire which was completed by 10 married couples. One question sought to place each individual on a 20 point scale in which low scores represent liberal attitudes and high scores represent conservative attitudes. The data were:

\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
Couple$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$$\\var{obj[8]}$$\\var{obj[9]}$
Wife $(X)$$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Husband $(Y)$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
\n

In this exercise you will find the Pearson correlation coefficent for the above paired data and comment on the significance of the calculated correlation.

\n

The null hypothesis you are testing is:

\n

$H_0$: There is no association between the attitudes of wives and husbands.

", "tags": ["checked2015", "correlation coefficient", "data analysis", "hypothesis testing", "Pearson correlation coefficient", "PSY2010", "statistics"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

30/09/2102:

\n \t\t

Introduced three functions:

\n \t\t

1. To produce the ranking of a list of 8 numbers.

\n \t\t

2. To produce a list of 8 numbers from a scale of 1..20 which are all distinct.

\n \t\t

3. To produce the maximum of the numbers in a list.

\n \t\t

4. Given an array such as in 2. to find another such array which has max diff between any two corresponding entries less than a given number. This is to ensure that the two array produced do not differ too much, as the point of the exercise is to show that there is a positive high correlation.

\n \t\t

 

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Calculate the Pearson correlation coefficient on paired data and comment on the significance.

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

The answers to all parts are given on revealing.

"}, {"name": "Calculate Spearman rank correlation coefficient and p-values", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "darr(n,m,[random(1..20)])", "description": "", "name": "r1"}, "spxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sxy-t[0]*t[1]/n", "description": "", "name": "spxy"}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "description": "", "name": "ssq"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2)]", "description": "", "name": "t"}, "rr1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r1)", "description": "", "name": "rr1"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "description": "", "name": "n"}, "ssd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(x^2,x,d))", "description": "", "name": "ssd"}, "corrcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spxy/sqrt(ss[0]*ss[1]),3)", "description": "", "name": "corrcoef"}, "d": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(rr1)-vector(rr2))", "description": "", "name": "d"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20", "description": "", "name": "m"}, "spcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1-6*ssd/(n*(n^2-1)),3)", "description": "", "name": "spcoef"}, "vs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(aspcoef >=0.879,[1,0,0,0,0],aspcoef>=0.794,[0,1,0,0,0],aspcoef>=0.648,[0,0,1,0,0],aspcoef>=0.564,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "vs"}, "rr2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r2)", "description": "", "name": "rr2"}, "sxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "description": "", "name": "sxy"}, "aspcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "abs(spcoef)", "description": "", "name": "aspcoef"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(corrcoef >=0.905,[1,0,0,0,0],corrcoef>=0.834,[0,1,0,0,0],corrcoef>=0.707,[0,0,1,0,0],corrcoef>=0.621,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "obj": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['A','B','C','D','E','F','G','H','I','J']", "description": "", "name": "obj"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tesarr(r1,darr(n,m,[random(1..m)]),9,m)", "description": "", "name": "r2"}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "description": "", "name": "ss"}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n,t[1]^2/n]", "description": "", "name": "tsqovern"}}, "ungrouped_variables": ["aspcoef", "spcoef", "vs", "sxy", "spxy", "tol", "ssq", "corrcoef", "ssd", "rr2", "rr1", "r1", "tsqovern", "obj", "d", "r2", "ss", "k", "m", "n", "t", "v"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"darr": {"type": "list", "language": "jme", "definition": "if(n=1,a,darr(n-1,m,[random(1..m except a)]+a))", "parameters": [["n", "number"], ["m", "number"], ["a", "list"]]}, "rk": {"type": "list", "language": "javascript", "definition": "\n /*This gives the ranking of the entries in a, c counts the ties */\n var out = [];\n for(var j=0;ja[i]){s+=1;}\n else\n if(a[j]==a[i]){c+=1;}\n }\n out[j]=(2*s+c+1)/2;\n }\n return out;\n \n ", "parameters": [["a", "list"]]}, "pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}, "marr": {"type": "number", "language": "jme", "definition": "if(length(a)=2,max(a[0],a[1]),max(a[0],marr(a[1..length(a)])))", "parameters": [["a", "list"]]}, "tesarr": {"type": "list", "language": "jme", "definition": "if(marr(map(abs(x),x,list(vector(a)-vector(b))))Spearman Correlation Coefficient

\n

In order to find the Spearman correlation coefficient for the original score data you need to supply the ranked data for the wives and the husbands in the table below. Lowest rank has rank $1$, highest score has rank $10$. Also supply the differences in the ranks, i.e. for each couple find wife's score - husband's score.

\n

Now fill in the ranks given by

\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
Couple$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$$\\var{obj[8]}$$\\var{obj[9]}$
Wife $(X)$[[0]][[1]][[2]][[3]][[4]][[5]][[6]][[7]][[8]][[9]]
Husband $(Y)$[[10]][[11]][[12]][[13]][[14]][[15]][[16]][[17]][[18]][[19]]
Differences[[20]][[21]][[22]][[23]][[24]][[25]][[26]][[27]][[28]][[29]]
\n

 

\n

Hence calculate the Spearman correlation coefficient to 3 decimal places:

\n

$r_s=\\;$[[30]]

\n

Click on Show steps for the Spearman correlation coefficient formula. You will not lose any marks by doing so.

", "steps": [{"type": "information", "prompt": "

If there are two sets of ranks $x_1,x_2,\\ldots,x_n$ and  $y_1,y_2,\\ldots,y_n$ where both sets have no ties, and differences are $d_i=x_i-y_i$ then if $\\sum d_i^2=D$ we have:

\n

\\[r_s=1-\\frac{6 \\times D}{n(n^2-1)}\\]

", "showCorrectAnswer": true, "scripts": {}, "marks": 0}], "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.564", "minValue": "0.564", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.648", "minValue": "0.648", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.794", "minValue": "0.794", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.879", "minValue": "0.879", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Give the value of the Spearman correlation coefficient you have found, find the the significance level by looking up the appropriate values in a table. 

\n

First supply the table values you need from your notes:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.2\\%$
[[0]][[1]][[2]][[3]]
\n

 

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["$p \\leq 0.002$, very strong evidence to reject the hypothesis.", "$0.002 \\lt p \\leq 0.01$, strong evidence to reject the hypothesis.", "$0.01 \\lt p \\leq 0.05$, there is evidence to reject the hypothesis.", "$0.05 \\lt p \\leq 0.1$, weak evidence against, do not reject the hypothesis but consider further investigation.", "$p \\gt 0.1$, no evidence to reject the hypothesis."], "displayColumns": 1, "prompt": "

Given the data above, what decision can you come to as to the hypothesis that the wife and husband in these married couples have the same attitude in relation to liberal and conservative values?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "vs", "marks": 0}], "statement": "

It is well known that similarity in attitudes, beliefs and interests plays an important role in interpersonal attraction. A researcher developed a questionnaire which was completed by 10 married couples. One question sought to place each individual on a 20 point scale in which low scores represent liberal attitudes and high scores represent conservative attitudes. The data were:

\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
Couple$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$$\\var{obj[8]}$$\\var{obj[9]}$
Wife $(X)$$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Husband $(Y)$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
\n

In this exercise you will find Spearman's correlation coefficient for this data and comment on the significance of the correlation as regards the following null hypothesis:

\n

$H_0$: There is no association between the attitudes of wives and husbands.

", "tags": ["checked2015", "data analysis", "hypothesis testing", "PSY2010", "ranked data", "ranks", "Spearman correlation coefficient", "statistics"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t \t\t

30/09/2102:

\n \t\t \t\t

Introduced three functions:

\n \t\t \t\t

1. To produce the ranking of a list of 8 numbers.

\n \t\t \t\t

2. To produce a list of 8 numbers from a scale of 1..20 which are all distinct.

\n \t\t \t\t

3. To produce the maximum of the numbers in a list.

\n \t\t \t\t

4. Given an array such as in 2. to find another such array which has max diff between any two corresponding entries less than a given number. This is to ensure that the two array produced do not differ too much, as the point of the exercise is to show that there is a positive high correlation.

\n \t\t \t\t

 

\n \t\t \n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Spearman rank correlation calculated. 10 paired observations.

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

When the question is revealed you will see all the answers.

"}, {"name": "Find and use linear regression equation for a small sample", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"group": "Ungrouped variables", "templateType": "anything", "definition": "0.001", "name": "tol", "description": ""}, "r1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "repeat(round(normalsample(67,8)),10)", "name": "r1", "description": ""}, "spxy": {"group": "Ungrouped variables", "templateType": "anything", "definition": "sxy-t[0]*t[1]/n", "name": "spxy", "description": ""}, "a": {"group": "Ungrouped variables", "templateType": "anything", "definition": "precround(1/n*(t[1]-spxy/ss[0]*t[0]),3)", "name": "a", "description": ""}, "ssq": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "name": "ssq", "description": ""}, "sc": {"group": "Ungrouped variables", "templateType": "anything", "definition": "r1[ch]", "name": "sc", "description": ""}, "ch": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(0..9)", "name": "ch", "description": ""}, "b1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(0.25..0.45#0.05)", "name": "b1", "description": ""}, "t": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[sum(r1),sum(r2)]", "name": "t", "description": ""}, "a1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(10..20)", "name": "a1", "description": ""}, "sxy": {"group": "Ungrouped variables", "templateType": "anything", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "name": "sxy", "description": ""}, "ss": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "name": "ss", "description": ""}, "n": {"group": "Ungrouped variables", "templateType": "anything", "definition": "10", "name": "n", "description": ""}, "obj": {"group": "Ungrouped variables", "templateType": "anything", "definition": "['A','B','C','D','E','F','G','H','I','J']", "name": "obj", "description": ""}, "r2": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(round(a1+b1*x+random(-9..9)),x,r1)", "name": "r2", "description": ""}, "b": {"group": "Ungrouped variables", "templateType": "anything", "definition": "precround(spxy/ss[0],3)", "name": "b", "description": ""}, "ls": {"group": "Ungrouped variables", "templateType": "anything", "definition": "precround(a+b*sc,2)", "name": "ls", "description": ""}, "res": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(precround(r2[x]-(a+b*r1[x]),2),x,0..n-1)", "name": "res", "description": ""}, "tsqovern": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[t[0]^2/n,t[1]^2/n]", "name": "tsqovern", "description": ""}}, "ungrouped_variables": ["tsqovern", "a", "b", "obj", "r1", "r2", "ss", "res", "ssq", "n", "a1", "ch", "spxy", "ls", "tol", "t", "sc", "sxy", "b1"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "showQuestionGroupNames": false, "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "parts": [{"marks": 0, "scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "showCorrectAnswer": true, "minValue": "b-tol", "maxValue": "b+tol", "precision": "3", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerFraction": false, "marks": 1}, {"precisionPartialCredit": 0, "allowFractions": false, "showCorrectAnswer": true, "minValue": "a-tol", "maxValue": "a+tol", "precision": "3", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerFraction": false, "marks": 1}], "type": "gapfill", "showCorrectAnswer": true, "steps": [{"type": "information", "showCorrectAnswer": true, "prompt": "

To find $a$ and $b$ you first find  $\\displaystyle b = \\frac{SPXY}{SSX}$ where:

\n

$\\displaystyle SPXY=\\sum xy - \\frac{(\\sum x)\\times (\\sum y)}{10}$

\n

$\\displaystyle SSX=\\sum x^2 - \\frac{(\\sum x)^2}{10}$

\n

Then $\\displaystyle a = \\frac{1}{10}\\left[\\sum y-b \\sum x\\right]$

\n

Now go back and fill in the values for $a$ and $b$.

", "scripts": {}, "marks": 0}], "prompt": "

Calculate the equation of the best fitting regression line:

\n

\\[Y = a + b \\times X.\\] Find $a$ and $b$ to 5 decimal places, then input them below to 3 decimal places. You will use these approximate values in the rest of the question. 

\n

$b=\\;$[[0]],      $a=\\;$[[1]] (enter both to 3 decimal places).

\n

You are given the following information:

\n \n \n \n \n \n \n \n \n \n \n \n
First Test$(X)$$\\sum x=\\;\\var{t[0]}$$\\sum x^2=\\;\\var{ssq[0]}$
Later Score$(Y)$$\\sum y=\\;\\var{t[1]}$$\\sum y^2=\\;\\var{ssq[1]}$
\n

Also you are given $\\sum xy = \\var{sxy}$.

\n

Click on Show steps if you want more information on calculating $a$ and $b$. You will not lose any marks by doing so.

\n

 

", "stepsPenalty": 0}, {"precisionPartialCredit": 0, "allowFractions": false, "showCorrectAnswer": true, "minValue": "ls-0.01", "prompt": "

What is the predicted Later score for employee $\\var{obj[ch]}$?

\n

Use the values of $a$ and $b$ you input above.

\n

Enter the predicted Later score here: (to 2 decimal places)

", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerFraction": false, "marks": 1, "maxValue": "ls+0.01"}, {"marks": 0, "scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "showCorrectAnswer": true, "minValue": "res[ch]-0.01", "maxValue": "res[ch]+0.01", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerFraction": false, "marks": 1}], "type": "gapfill", "showCorrectAnswer": true, "steps": [{"type": "information", "showCorrectAnswer": true, "prompt": "

The residual value is given by:

\n

RESIDUAL = OBSERVED - FITTED.

\n

In this case the observed value for $\\var{obj[ch]}$ is $\\var{r2[ch]}$ and you get the fitted value by feeding the First test value  $\\var{r1[ch]}$ into the regression equation.

\n

 

", "scripts": {}, "marks": 0}], "prompt": "

Use the result above to calculate the residual value for employee $\\var{obj[ch]}$.

\n

Click on Show steps to see what is meant by the residual value if you have forgotten. You will not lose any marks by doing so.

\n

Residual value =  (to 2 decimal places).[[0]]

", "stepsPenalty": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "

To monitor its staff appraisal methods, a personnel department compares the results of the tests carried out on employees at their first appraisal with an assessment score of the same individuals two years later. The resulting data are as follows:

\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
Employee$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$$\\var{obj[8]}$$\\var{obj[9]}$
First Test $(X)$$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Later Score $(Y)$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
\n ", "tags": ["checked2015", "data analysis", "fitted value", "PSY2010", "regression", "residual value", "statistics"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

30/09/2102:

\n \t\t

Introduced three functions:

\n \t\t

1. To produce the ranking of a list of 8 numbers.

\n \t\t

2. To produce a list of 8 numbers from a scale of 1..20 which are all distinct.

\n \t\t

3. To produce the maximum of the numbers in a list.

\n \t\t

4. Given an array such as in 2. to find another such array which has max diff between any two corresponding entries less than a given number. This is to ensure that the two array produced do not differ too much, as the point of the exercise is to show that there is a positive high correlation.

\n \t\t

 

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Find a regression equation.

"}, "advice": ""}, {"name": "Multiple and partial correlation(old)", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"datax1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(datay)+vector(repeat(random(-4,-3,4,5,6),10)))", "description": "", "name": "datax1"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spyx1/sqrt(ssy*ssx1),2)", "description": "", "name": "r1"}, "spyx1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "syx1-t[0]*t[1]/10", "description": "", "name": "spyx1"}, "pcc": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((r2-r1*r12)/(sqrt((1-r1^2)*(1-r12^2))),3)", "description": "", "name": "pcc"}, "ssqy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datay)*vector(datay))[0]", "description": "", "name": "ssqy"}, "datax2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(datay)+vector(repeat(random(-4,-3,-2,-1,3,4,5),10)))", "description": "", "name": "datax2"}, "ssx2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ssqx2-t[2]^2/10", "description": "", "name": "ssx2"}, "sx1x2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datax1)*vector(datax2))[0]", "description": "", "name": "sx1x2"}, "ssy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ssqy-t[0]^2/10", "description": "", "name": "ssy"}, "spyx2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "syx2-t[0]*t[2]/10", "description": "", "name": "spyx2"}, "syx1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datax1)*vector(datay))[0]", "description": "", "name": "syx1"}, "r12": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spx1x2/sqrt(ssx2*ssx1),2)", "description": "", "name": "r12"}, "spx1x2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sx1x2-t[1]*t[2]/10", "description": "", "name": "spx1x2"}, "ssqx1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datax1)*vector(datax1))[0]", "description": "", "name": "ssqx1"}, "datay": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(5..20),10)", "description": "", "name": "datay"}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1*r12", "description": "", "name": "r"}, "ssx1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ssqx1-t[1]^2/10", "description": "", "name": "ssx1"}, "rsq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((r1^2+r2^2-(2*r1*r2*r12))/(1-r12^2),2)", "description": "", "name": "rsq"}, "syx2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datax2)*vector(datay))[0]", "description": "", "name": "syx2"}, "s": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ceil(20*r1*r2/(r1^2+r2^2))", "description": "", "name": "s"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spyx2/sqrt(ssy*ssx2),2)", "description": "", "name": "r2"}, "ssqx2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datax2)*vector(datax2))[0]", "description": "", "name": "ssqx2"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(datay),sum(datax1),sum(datax2)]", "description": "", "name": "t"}, "remv": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(100*pcc^2,2)", "description": "", "name": "remv"}}, "ungrouped_variables": ["spx1x2", "ssqx2", "ssqx1", "r12", "sx1x2", "pcc", "syx1", "syx2", "ssy", "spyx2", "spyx1", "ssqy", "datax2", "rsq", "ssx2", "r1", "r2", "ssx1", "datax1", "remv", "s", "r", "datay", "t"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "round(100*r1^2)", "minValue": "round(100*r1^2)", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "round(100*r2^2)", "minValue": "round(100*r2^2)", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "round(100*Rsq)", "minValue": "round(100*Rsq)", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

What proportion of the variability in $Y$ is explained by:

\n

(i) $X_1$ alone? $R^2=\\;$[[0]]%

\n

(ii) $X_2$ alone? $R^2=\\;$[[1]]%

\n

(iii) $X_1$ and $X_2$ together? $R^2=\\;$[[2]]%

\n

All percentages to the nearest whole number.

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "pcc+0.001", "minValue": "pcc-0.001", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "remv+0.01", "minValue": "remv-0.01", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

What is the partial correlation coefficient between $Y$ and $X_2$ after fitting $X_1$?

\n

Partial correlation coefficient = [[0]].

\n

Input your answer to 3 decimal places.

\n

How much of the remaining variability in $Y$ is explained by $X_2$ after fitting $X_1$?

\n

Input your answer here as a percentage to 2 decimal places: [[1]]%

", "showCorrectAnswer": true, "marks": 0}], "statement": "

In a multiple regression example, it is found that:

\n

1. The correlation coefficient of $Y$ with $X_1$ is $\\var{r1}$.

\n

2. The correlation coefficient of $Y$ with $X_2$ is $\\var{r2}$.

\n

3. The correlation coefficent of $X_1$ with $X_2$ is $\\var{r12}$.

\n

Answer the following questions:

", "tags": ["checked2015", "correlation coefficients", "fitting a regression", "multiple correlation", "multiple regression", "partial correlation coefficient", "proportion of variability", "unused", "variability"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

The correlation coefficients are generated by $Y$ a random sample of 10 numbers between 5 and 20, $X_1$ obtained from $Y$ by adding on some noise and similarly for $X_2$. The correlation coefficients are then worked out from these samples.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Multiple correlation question. Given the correlation coefficent of $Y$ with $X_1$ is $r_{01}$, the correlation coefficent of $Y$ with $X_2$ is $r_{02}$ and the correlation coefficent of $X_1$ with $X_2$ is $r_{12}$ then explain the proportion of variablity of $Y$. Also find the partial corr coeff between $Y$ and $X_2$ after fitting $X_1$ and find how much of the remaining variability in $Y$ is explained by $X_2$ after fitting $X_1$.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": ""}, {"name": "Perform a paired sample t-test, ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ttest(0,d,2),3)", "name": "pvalue", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),12)", "name": "r1", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(tvalue>=t999,[1,0,0,0,0],if(tvalue>=t99,[0,1,0,0,0],if(tvalue>=t95,[0,0,1,0,0],if(tvalue>=t90,[0,0,0,1,0],[0,0,0,0,1]))))", "name": "v", "description": ""}, "pmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "name": "pmsg", "description": ""}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..3#0.2)", "name": "sig1", "description": ""}, "t90": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1.796", "name": "t90", "description": ""}, "tvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(abs(meandiff*sqrt(n)/stdiff),3)", "name": "tvalue", "description": ""}, "cmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "name": "cmsg", "description": ""}, "t99": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3.106", "name": "t99", "description": ""}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(18..25#0.5)", "name": "mu1", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "name": "t", "description": ""}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..4#0.2)", "name": "sig2", "description": ""}, "meandiff": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(d),3)", "name": "meandiff", "description": ""}, "t999": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4.437", "name": "t999", "description": ""}, "d": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(r2)-vector(r1))", "name": "d", "description": ""}, "object": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'Individual'", "name": "object", "description": ""}, "stdiff": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(d),3)", "name": "stdiff", "description": ""}, "t95": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2.201", "name": "t95", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "12", "name": "n", "description": ""}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),12)", "name": "r2", "description": ""}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu1+random(2..4#0.1)", "name": "mu2", "description": ""}, "cmsg1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['very strong','strong','slight','no','no']", "name": "cmsg1", "description": ""}, "msg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['is greater than $\\\\var{t999}$','lies between $\\\\var{t99}$ and $\\\\var{t999}$','lies between $\\\\var{t95}$ and $\\\\var{t99}$','lies between $\\\\var{t90}$ and $\\\\var{t95}$','is less than $\\\\var{t90}$']", "name": "msg", "description": ""}}, "ungrouped_variables": ["pmsg", "msg", "cmsg1", "t999", "meandiff", "object", "sig1", "tvalue", "stdiff", "sig2", "t99", "t95", "t90", "cmsg", "d", "mu1", "r1", "r2", "mu2", "n", "t", "v", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{meandiff}", "maxValue": "{meandiff}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{stdiff}", "maxValue": "{stdiff}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{tvalue}", "maxValue": "{tvalue}", "marks": 1}], "type": "gapfill", "prompt": "

Find the mean and standard deviations of the difference between left and right {attempt}s.

\n

Calculate differences for left {attempt} times – right {attempt} times. Make sure you take the differences this way round.

\n

Mean of difference = [[0]] (input  to 3 decimal places )

\n

Standard deviation of difference = [[1]] (input to 3 decimal places)

\n

Now find the t-test statistic $T$ using the values you have just calculated and  input the absolute value $|T|$ here: [[2]] (3 decimal places). 

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

$p$ less than $0.1 \\%$

", "

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

", "

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

", "

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

", "

$p$ is greater than $10\\%$

"], "displayColumns": 0, "prompt": "

Give the value of the t-statistic you have found, choose the range for the $p$ value by looking up the t-statistic tables:

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

Very Strong Evidence

", "

Strong Evidence

", "

Evidence

", "

Weak Evidence

", "

No Evidence

"], "displayColumns": 0, "prompt": "

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the average times for the left and right hands?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}], "statement": "

The following data was obtained from $12$ individuals. The observations consist of the time taken to complete a dexterity task using their left and right hands.

\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
{object}ABCDEFGHIJKL
Right$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$$\\var{r1[10]}$$\\var{r1[11]}$
Left$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$$\\var{r2[10]}$$\\var{r2[11]}$
\n

Carry out by hand a paired t-test to test whether there is evidence of a difference in the average times for the left and right hands.

", "tags": ["ACE2013", "average", "checked2015", "data analysis", "differences", "elementary statistics", "hypothesis testing", "mean", "mean ", "mean of differences", "paired t-test", "PSY2010", "standard deviation", "standard deviation of differences", "statistics", "stats", "t-test", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t \t\t

11/07/2012:

\n \t\t \t\t


Added tags.

\n \t\t \t\t

Calculation not yet tested.

\n \t\t \t\t

23/07/2012:

\n \t\t \t\t

Added description.

\n \t\t \t\t

Checked calculation.

\n \t\t \t\t

Changed display slightly in Advice.

\n \t\t \t\t

3/08/2012:

\n \t\t \t\t

Added tags.

\n \t\t \t\t

Question appears to be working correctly.

\n \t\t \n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Paired t-test to see if there is a difference between times take in a task.

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

The table of differences is given by:

\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
{object}ABCDEFGHIJKL
Right$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$$\\var{r1[10]}$$\\var{r1[11]}$
Left$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$$\\var{r2[10]}$$\\var{r2[11]}$
Differences$\\var{d[0]}$$\\var{d[1]}$$\\var{d[2]}$$\\var{d[3]}$$\\var{d[4]}$$\\var{d[5]}$$\\var{d[6]}$$\\var{d[7]}$$\\var{d[8]}$$\\var{d[9]}$$\\var{d[10]}$$\\var{d[11]}$
\n

We test the following hypothesis:

\n

$H_0:\\;\\mu_d=0$ versus $H_1:\\;\\mu_d\\neq 0$

\n

$n=\\var{n}$ and the mean of the differences is $\\overline{d}=\\var{meandiff}$.

\n

The variance $V$ of the differences is calculated to be $\\var{pstdev(d)^2}$

Hence we have the standard deviation $s_d= \\sqrt{V}=\\var{stdiff}$ to 3 decimal places.

\n

The paired t-statistic is given by:

\n

\\[\\begin{eqnarray*} T&=&\\frac{\\overline{d}-\\mu_d}{\\frac{s_d}{\\sqrt{n}}}\\\\&=&\\frac{\\var{meandiff}-0}{\\frac{\\var{stdiff}}{\\sqrt{\\var{n}}}}\\\\&=&\\var{tvalue}\\end{eqnarray*}\\]

\n

(Using the null hypothesis that the means are the same i.e. $\\mu_d=0$.)

\n

Hence our test statistic  $|T|=\\var{tvalue}$.

\n

Looking up this value on the T-distribution table for $t_{11}$

\n

\\[\\begin{array}{r|rrrrr}&0.20&0.10&0.05&0.01&0.001\\\\\\hline11&1.363&1.796&2.201&3.106&4.437\\end{array}\\]

\n

We see that the t-statistic {msg[t]} and the table tells us that the $p$ value {pmsg[t]}.

\n

Hence we conclude that we {cmsg[t]} the null hypothesis. There is {cmsg1[t]} evidence of a difference between the average scores of the two groups.

\n

 

"}, {"name": "Perform an independent two sample t-test", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "name": "tol", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),10)", "name": "r1", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(atvalue>=t999,[1,0,0,0,0],if(atvalue>=t99,[0,1,0,0,0],if(atvalue>=t95,[0,0,1,0,0],if(atvalue>=t90,[0,0,0,1,0],[0,0,0,0,1]))))", "name": "v", "description": ""}, "pmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "name": "pmsg", "description": ""}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(8..10#0.2)", "name": "sig1", "description": ""}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n1", "description": ""}, "pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ttest(atvalue,19,2)", "name": "pvalue", "description": ""}, "t90": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1.734", "name": "t90", "description": ""}, "atvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "abs(tvalue)", "name": "atvalue", "description": ""}, "cmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "name": "cmsg", "description": ""}, "t99": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2.878", "name": "t99", "description": ""}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(55..75#0.5)", "name": "mu1", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "name": "t", "description": ""}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(8..10#0.2)", "name": "sig2", "description": ""}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n2", "description": ""}, "t999": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3.922", "name": "t999", "description": ""}, "cmsg1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['very strong','strong','slight','no','no']", "name": "cmsg1", "description": ""}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mean(r1)", "name": "m1", "description": ""}, "t95": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2.101", "name": "t95", "description": ""}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mean(r2)", "name": "m2", "description": ""}, "s": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(((n1-1)*sd1^2+(n2-1)*sd2^2)/(n1+n2-2)),3)", "name": "s", "description": ""}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),10)", "name": "r2", "description": ""}, "sd1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r1),3)", "name": "sd1", "description": ""}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(65..75#0.5)", "name": "mu2", "description": ""}, "tvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((m1-m2)*sqrt(n1*n2)/(s*sqrt(n1+n2)),3)", "name": "tvalue", "description": ""}, "msg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['is greater than $\\\\var{t999}$','lies between $\\\\var{t99}$ and $\\\\var{t999}$','lies between $\\\\var{t95}$ and $\\\\var{t99}$','lies between $\\\\var{t90}$ and $\\\\var{t95}$','is less than $\\\\var{t90}$']", "name": "msg", "description": ""}, "sd2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r2),3)", "name": "sd2", "description": ""}}, "ungrouped_variables": ["sd1", "sd2", "m1", "tol", "m2", "msg", "cmsg1", "t999", "atvalue", "sig1", "tvalue", "sig2", "t99", "t95", "t90", "cmsg", "mu1", "r1", "r2", "mu2", "pmsg", "s", "t", "v", "n1", "n2", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"marks": 0, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{m1}", "maxValue": "{m1}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{sd1}", "maxValue": "{sd1}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{m2}", "maxValue": "{m2}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{sd2}", "maxValue": "{sd2}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{abs(tvalue)-tol}", "maxValue": "{abs(tvalue)+tol}", "marks": 1}], "type": "gapfill", "showCorrectAnswer": true, "steps": [{"type": "information", "showCorrectAnswer": true, "prompt": "

The two-sample t-statistic for two independent sets of data where one set has $n_1$ datapoints and the other set $n_2$ datapoints is calculated as follows:

\n

\\[T=\\frac{(\\overline{x}_1-\\overline{x}_2)-(\\mu_1-\\mu_2)}{s\\times\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}}\\;\\;\\;\\]

\n

where $\\overline{x}_1,\\;\\overline{x}_2$ are the sample means and 

\n

\\[s^2=\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}\\]

\n

where $s_1,\\;s_2$ are the sample standard deviations.

\n

Use the values you calculated to 3 decimal places in order to find $T$.

", "marks": 0, "scripts": {}}], "prompt": "

Find the mean and standard deviations of the scores of the two groups:

\n

Mean scores of Group 1= [[0]] (input to 3 decimal places)

\n

Standard deviation of scores for Group 1 = [[1]] (input to 3 decimal places)

\n

Mean scores of Group 2= [[2]] (input to 3 decimal places)

\n

Standard deviation of scores for Group 2 = [[3]] (input to 3 decimal places)

\n

Now find the two sample t-test statistic $T$ using the values you have just calculated to 3 decimal places and input $|T|$ here: [[4]] (3 decimal places)

", "stepsPenalty": 0}, {"displayType": "radiogroup", "choices": ["

$p$ less than $0.1\\%$

", "

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

", "

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

", "

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

", "

$p$ is greater than $10\\%$

"], "displayColumns": 0, "prompt": "

Give the value $|T|$ of the t-statistic you have found, choose the range for the $p$ value by looking up the t tables:

\n

 

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

Very Strong Evidence

", "

Strong Evidence

", "

Evidence

", "

Weak Evidence

", "

No Evidence

"], "displayColumns": 0, "prompt": "

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the average times for the left and right hands?

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

We reject the null hypothesis at the $0.1\\%$ level

", "

We reject the null hypothesis at the $1\\%$ level.

", "

We reject the null hypothesis at the $5\\%$ level.

", "

We do not reject the null hypothesis but consider further investigation.

", "

We do not reject the null hypothesis.

"], "displayColumns": 0, "prompt": "

Hence what is your decision based on the above analysis?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}], "statement": "

An educational psychologist claimed that the order in which questions were asked affected the student’s ability to answer them correctly and hence their total score. In order to test this, $20$ students were randomly divided into two groups of $10$. The first group were given questions in increasing order of difficulty and the second group in decreasing order of difficulty. The ordered test scores obtained were:

\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
Group 1$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Group 2$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
\n

Carry out by hand a two-sample t-test to test if there is evidence of a difference in the average test scores for the two sets of students.

", "tags": ["average", "checked2015", "data analysis", "differences", "elementary statistics", "hypothesis testing", "mean", "mean ", "PSY2010", "standard deviation", "statistics", "stats", "t-test", "two sample t-test", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t \t\t

11/07/2012:

\n \t\t \t\t


Added tags.

\n \t\t \t\t

Calculation not yet tested.

\n \t\t \t\t

23/07/2012:

\n \t\t \t\t

Added description.

\n \t\t \t\t

Checked calculation.

\n \t\t \t\t

Changed display slightly in Advice.

\n \t\t \t\t

3/08/2012:

\n \t\t \t\t

Added tags.

\n \t\t \t\t

Question appears to be working correctly.

\n \t\t \n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Two sample t-test to see if there is a difference between scores on questions between two groups when the questions are asked in a different order.

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

We test the following hypothesis,

\n

$H_0:\\; \\mu_1=\\mu_2$ versus $H_1:\\; \\mu_1 \\neq \\mu_2$

\n

We find that the mean score of Group 1 is $\\overline{x}_1=\\var{m1}$ with standard deviation $s_1=\\var{sd1}$ and the mean score of Group 2 is $\\overline{x}_2=\\var{m2}$ with standard deviation $s_2=\\var{sd2}$.

\n

All calculated to 3 decimal places.

\n

Using the formula for the two-sample t-statistic as  shown above with $n_1=n_2=10$:

\n

The estimate of the pooled variance is calculated to be:

\n

\\[s^2=\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}= \\frac{\\var{n1-1}\\times \\var{sd1}^2+\\var{n2-1}\\times \\var{sd2}^2}{\\var{n1+n2-2}}=\\var{s^2}.\\] 

\n

Hence $s= \\sqrt{\\var{s^2}}=\\var{s}$ to 3 decimal places.

\n

We find that the t-statistic has value:

\n

\\[\\begin{eqnarray*}T&=& \\frac{(\\overline{x}_1-\\overline{x}_2)-(\\mu_1-\\mu_2)}{s\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}}\\\\&=&\\frac{(\\var{m1}-\\var{m2})-(0)}{\\var{s}\\sqrt{\\frac{1}{\\var{n1}}+\\frac{1}{\\var{n2}}}}\\\\&=&\\var{tvalue}\\end{eqnarray*}\\] to 3 decimal places.

\n

Our test statistic is $|T|=\\var{abs(tvalue)}$.

\n

Given that we have $n_1+n_2-2=18$ degrees of freedom, we look up this value on the T-distribution table for $t_{18}$

\n

\\[\\begin{array}{r|rrrrr}&0.20&0.10&0.05&0.01&0.001\\\\\\hline18&1.330&1.734&2.101&2.878&3.922\\end{array}\\]

\n

We see that the t-statistic {msg[t]} and the table tells us that the $p$ value {pmsg[t]}.

\n

Hence we conclude that we {cmsg[t]} the null hypothesis. There is {cmsg1[t]} evidence of a difference between the average scores of the two groups.

\n

 

"}, {"name": "LSD and Tukey yardsticks, and one-way ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ftest(VR,2,15),3)", "name": "pvalue", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),6)", "name": "r1", "description": ""}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2)),sum(map(x^2,x,r3))]", "name": "ssq", "description": ""}, "btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stovern-G^2/N,2)", "name": "btss", "description": ""}, "sd1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r1),2)", "name": "sd1", "description": ""}, "tss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ss-G^2/N,2)", "name": "tss", "description": ""}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "name": "k", "description": ""}, "dfbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "k-1", "name": "dfbt", "description": ""}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "name": "sig2", "description": ""}, "v1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pvalue<=0.001,[1,0,0,0,0],pvalue<=0.01,[0,1,0,0,0],pvalue<=0.05,[0,0,1,0,0],pvalue<=0.1,[0,0,0,1,0],[0,0,0,0,1])", "name": "v1", "description": ""}, "vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(MBT/MRS,2)", "name": "vr", "description": ""}, "w1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(m1-m2)>=tukey,[1,0,0],abs(m1-m2)>=lsd,[0,1,0],[0,0,1])", "name": "w1", "description": ""}, "rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ss-stovern,2)", "name": "rss", "description": ""}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "name": "n1", "description": ""}, "sd3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r3),2)", "name": "sd3", "description": ""}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(ssq)", "name": "ss", "description": ""}, "w2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(m3-m2)>=tukey,[1,0,0],abs(m3-m2)>=lsd,[0,1,0],[0,0,1])", "name": "w2", "description": ""}, "sig3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "name": "sig3", "description": ""}, "mbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(BTSS/dfbt,2)", "name": "mbt", "description": ""}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),6)", "name": "r2", "description": ""}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu1+random(3..6)", "name": "mu2", "description": ""}, "g": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(t)", "name": "g", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2),sum(r3)]", "name": "t", "description": ""}, "sd2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r2),2)", "name": "sd2", "description": ""}, "w": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[w1,w2,w3]", "name": "w", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "name": "tol", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vr>=11.34,[1,0,0,0,0],vr>=6.36,[0,1,0,0,0],vr>=3.68,[0,0,1,0,0],vr>=2.7,[0,0,0,1,0],[0,0,0,0,1])", "name": "v", "description": ""}, "pmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "name": "pmsg", "description": ""}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..4#0.2)", "name": "sig1", "description": ""}, "sqrms": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(mrs),2)", "name": "sqrms", "description": ""}, "mrs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(RSS/dfrs,2)", "name": "mrs", "description": ""}, "u": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "name": "u", "description": ""}, "m3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r3),2)", "name": "m3", "description": ""}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "name": "n2", "description": ""}, "cmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "name": "cmsg", "description": ""}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..25#0.5)", "name": "mu1", "description": ""}, "stovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(tsqovern)", "name": "stovern", "description": ""}, "lsd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(2.131*sqrms*sqrt(2/n1),2)", "name": "lsd", "description": ""}, "dfrs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "N-k", "name": "dfrs", "description": ""}, "yn": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(yeaornay(x),x,w[z]),z,0..2)", "name": "yn", "description": ""}, "tukey": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(3.67*sqrms*1/sqrt(n1),2)", "name": "tukey", "description": ""}, "w3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(m3-m1)>=tukey,[1,0,0],abs(m3-m1)>=lsd,[0,1,0],[0,0,1])", "name": "w3", "description": ""}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r1),2)", "name": "m1", "description": ""}, "r3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu3,sig3)),6)", "name": "r3", "description": ""}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r2),2)", "name": "m2", "description": ""}, "n3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "name": "n3", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n1+n2+n3", "name": "n", "description": ""}, "stderror": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mrs/sqrt(n1),2)", "name": "stderror", "description": ""}, "mu3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu2+random(4..6)", "name": "mu3", "description": ""}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n1,t[1]^2/n2,t[2]^2/n3]", "name": "tsqovern", "description": ""}}, "ungrouped_variables": ["lsd", "tukey", "sd1", "sd2", "sd3", "vr", "w3", "w2", "w1", "mbt", "n", "pmsg", "mu3", "stderror", "sqrms", "dfrs", "m1", "m3", "m2", "btss", "stovern", "tss", "dfbt", "tol", "yn", "ssq", "sig1", "v1", "sig3", "sig2", "cmsg", "rss", "tsqovern", "mu1", "g", "r2", "mu2", "ss", "k", "r3", "mrs", "r1", "u", "t", "w", "v", "n1", "n2", "n3", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}, "yeaornay": {"type": "string", "language": "jme", "definition": "if(n=1,'Yes','No')", "parameters": [["n", "number"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "sqrms-tol", "maxValue": "sqrms+tol", "marks": 1}], "type": "gapfill", "prompt": "\n

You are given the following ANOVA table for this data:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
SourcedfSSMSVR
Between Treatments$\\var{dfbt}$$\\var{btss}$$\\var{mbt}$$\\var{vr}$
Residual$\\var{dfrs}$$\\var{rss}$$\\var{mrs}$-
Total$\\var{n-1}$$\\var{tss}$--
\n

 

\n

 Input $\\sqrt{RMS}$ here: [[0]] to 2 decimal places.

\n

 

\n

This will be used to calculate the LSD and Tukey yardstick values later.

\n \n ", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["Very strong", "Strong", "Moderate", "Weak", "None"], "displayColumns": 0, "prompt": "\n

Using ANOVA

\n

Using the $VR$ value given in the table and one-way ANOVA, what is the strength of evidence against the null hypothesis that the mean times taken are the same for the three groups?

\n ", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["We reject the null hypothesis at the $0.1\\%$ level", "We reject the null hypothesis at the $1\\%$ level.", "We reject the null hypothesis at the $5\\%$ level.", "We do not reject the null hypothesis but consider further investigation.", "We do not reject the null hypothesis."], "displayColumns": 1, "prompt": "

Hence what is your decision based on the above ANOVA analysis?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m1", "maxValue": "m1", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m2", "maxValue": "m2", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m3", "maxValue": "m3", "marks": 1}], "type": "gapfill", "prompt": "\n

Using the Yardsticks

\n

Fill in this table with the appropriate values for the mean values of the groups, all decimals to 2 decimal places:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 $\\overline{x}_i$
Group A[[0]]
Group B[[1]]
Group C[[2]]
\n

 

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "lsd-tol", "maxValue": "lsd+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "tukey-tol", "maxValue": "tukey+tol", "marks": 1}, {"layout": {"expression": ""}, "choices": ["Groups $A$ and $B$", "Groups $B$ and $C$", "Groups $A$ and $C$"], "matrix": "w", "type": "m_n_x", "maxAnswers": 0, "shuffleChoices": false, "marks": 0, "scripts": {}, "minMarks": 0, "minAnswers": 0, "maxMarks": 0, "shuffleAnswers": false, "showCorrectAnswer": true, "answers": ["Definite Significant Difference", "Possible Significant Difference", "No Significant Difference"]}], "type": "gapfill", "prompt": "

Now find the LSD and Tukey yardsticks from the above data. Use the value to 2 decimal places you found for $\\sqrt{RMS}$:

\n

   LSD= [[0]]

\n

Tukey= [[1]]

\n

 Using these yardsticks fill in the following table indicating if there is a possible or definite significant difference between the pairs of groups mean times in undertaking the tasks:

\n

[[2]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "\n

The following data arose in a comparison of the effects of alcohol on the time taken to complete a task. There were three groups of subjects; Group A had no alcohol, Group B had two units over 1 hour and Group C had 4 units over 1 hour. The responses are the times (in seconds) taken to complete a word-matching task.

\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
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$
\n

 

\n \n ", "tags": ["ANOVA", "average", "checked2015", "data analysis", "definite significant difference", "degrees of freedom", "F-test", "hypothesis testing", "Least significant difference", "lsd", "LSD", "mean ", "possible significant difference", "PSY2010", "standard deviation", "statistics", "stats", "Tukey", "tukey ", "variance", "yardsticks", "Yardsticks"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t \t\t

15/11/2012:

\n \t\t \t\t


This question cones from editing a one-way Anova example

\n \t\t \t\t

Added tags and description

\n \t\t \t\t

 

\n \t\t \n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

LSD and Tukey yardsticks on three treatments. Also one-way Anova test on same set of data.

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

Using the Yardsticks

\n

The mean values for each group are:

\n

  

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 $\\overline{x}_i$
Group A$\\var{m1}$
Group B$\\var{m2}$
Group C$\\var{m3}$  
\n

The differences between the mean values for the groups are:

\n

Between $A$ and $B=\\;|\\var{m1}-\\var{m2}|=\\var{abs(m1-m2)}$

\n

Between $B$ and $C=\\;|\\var{m2}-\\var{m3}|=\\var{abs(m2-m3)}$

\n

Between $A$ and $C=\\;|\\var{m1}-\\var{m3}|=\\var{abs(m1-m3)}$

\n

We compare these differences with the LSD and Tukey yardsticks:

\n

LSD yardstick = $2.131\\times\\var{sqrms}\\times\\sqrt{2/\\var{n1}}=\\var{lsd}$ to 2 decimal places, where $\\var{sqrms}$ is the value of $\\sqrt{RMS}$ found above.

\n

Tukey yardstick = $3.67\\times\\var{sqrms}\\times\\sqrt{1/\\var{n1}}=\\var{tukey}$ to 2 decimal places.

\n

If the difference of the means:

\n
    \n
  • is greater than the Tukey yardstick we say that there is evidence of a definite significant difference.
  • \n
\n

 

\n
    \n
  • less than the Tukey yardstick but greater than the LSD yardstick we say that there is evidence of a possible significant difference.
  • \n
\n

 

\n
    \n
  • is less than the LSD yardstick then we say that there is no  evidence of a significant difference.
  • \n
\n

 

\n

Hence we have the following for the groups:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Pairs of GroupsDefinite Significant DifferencePossible Significant DifferenceNo Significant Difference
Means of Groups A and B{yn[0][0]}{yn[0][1]}{yn[0][2]}
Means of Groups B and C{yn[1][0]}{yn[1][1]}{yn[1][2]}
Means of Groups A and C{yn[2][0]}{yn[2][1]}{yn[2][2]}
"}, {"name": "LSD and Tukey yardsticks, and two-way ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sum(map(x^2,x,cols))/n-tot^2/(m*n),2)", "name": "btss", "description": ""}, "sig": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..7#0.2)", "name": "sig", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(repeat(round(normalsample(mu[x],sig)),5),x,0..m-1)", "name": "r1", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vr>=10.8,[1,0,0,0,0],vr>=5.95,[0,1,0,0,0],vr>=3.49,[0,0,1,0,0],vr>=2.61,[0,0,0,1,0],[0,0,0,0,1])", "name": "v", "description": ""}, "v1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pvalue<=0.001,[1,0,0,0,0],pvalue<=0.01,[0,1,0,0,0],pvalue<=0.05,[0,0,1,0,0],pvalue<=0.1,[0,0,0,1,0],[0,0,0,0,1])", "name": "v1", "description": ""}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(sum(map(x^2,x,r[y])),y,0..n-1))", "name": "ssq", "description": ""}, "vrbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(msbb/rs,2)", "name": "vrbb", "description": ""}, "t90": {"templateType": "anything", "group": "Ungrouped variables", "definition": "13.36", "name": "t90", "description": ""}, "tss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ssq-tot^2/(m*n),2)", "name": "tss", "description": ""}, "mu": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[random(30..40),random(35..40),random(25..35),random(40..45),random(20..40)]", "name": "mu", "description": ""}, "rs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(rss/dfr,2)", "name": "rs", "description": ""}, "w6": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[2]-me[3])>=tukey,[1,0,0],abs(me[2]-me[3])>=lsd,[0,1,0],[0,0,1])", "name": "w6", "description": ""}, "dfbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m-1", "name": "dfbt", "description": ""}, "msbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(btss/(m-1),2)", "name": "msbt", "description": ""}, "w4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[1]-me[2])>=tukey,[1,0,0],abs(me[1]-me[2])>=lsd,[0,1,0],[0,0,1])", "name": "w4", "description": ""}, "bbss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sum(map(x^2,x,t))/m-tot^2/20,2)", "name": "bbss", "description": ""}, "lsd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(2.179*sqrms*sqrt(2/5),2)", "name": "lsd", "description": ""}, "w5": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[1]-me[3])>=tukey,[1,0,0],abs(me[1]-me[3])>=lsd,[0,1,0],[0,0,1])", "name": "w5", "description": ""}, "vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(msbt/rs,2)", "name": "vr", "description": ""}, "cols": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(rt[x]),x,0..m-1)", "name": "cols", "description": ""}, "w1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[0]-me[1])>=tukey,[1,0,0],abs(me[0]-me[1])>=lsd,[0,1,0],[0,0,1])", "name": "w1", "description": ""}, "pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ftest(VR,3,12),3)", "name": "pvalue", "description": ""}, "tot": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(cols)", "name": "tot", "description": ""}, "dfr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m*n-m-n+1", "name": "dfr", "description": ""}, "tukey": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(4.2*sqrms*sqrt(1/5),2)", "name": "tukey", "description": ""}, "w": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[w1,w2,w3,w4,w5,w6]", "name": "w", "description": ""}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4", "name": "m", "description": ""}, "msbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(bbss/(n-1),2)", "name": "msbb", "description": ""}, "dfbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n-1", "name": "dfbb", "description": ""}, "w3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[0]-me[3])>=tukey,[1,0,0],abs(me[0]-me[3])>=lsd,[0,1,0],[0,0,1])", "name": "w3", "description": ""}, "sqrms": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(rs),2)", "name": "sqrms", "description": ""}, "t99": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20.09", "name": "t99", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "name": "tol", "description": ""}, "t95": {"templateType": "anything", "group": "Ungrouped variables", "definition": "15.51", "name": "t95", "description": ""}, "w2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[0]-me[2])>=tukey,[1,0,0],abs(me[0]-me[2])>=lsd,[0,1,0],[0,0,1])", "name": "w2", "description": ""}, "yn": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(yeaornay(x),x,w[z]),z,0..5)", "name": "yn", "description": ""}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r1)))", "name": "r", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "5", "name": "n", "description": ""}, "me": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(mean(r1[x]),x,0..3)", "name": "me", "description": ""}, "stderror": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(rs/n),2)", "name": "stderror", "description": ""}, "rt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r)))", "name": "rt", "description": ""}, "rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tss-btss-bbss", "name": "rss", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(r[x]),x,0..n-1)", "name": "t", "description": ""}}, "ungrouped_variables": ["lsd", "tukey", "stderror", "bbss", "cols", "vrbb", "w6", "vr", "w4", "w3", "w2", "w1", "dfr", "rt", "rs", "t90", "tot", "sqrms", "sig", "tol", "btss", "tss", "dfbt", "yn", "msbt", "ssq", "v1", "dfbb", "t99", "t95", "msbb", "rss", "me", "r1", "m", "w5", "n", "mu", "r", "t", "w", "v", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"yeaornay": {"type": "string", "language": "jme", "definition": "if(n=1, \"Yes\", \"No\")", "parameters": [["n", "number"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "sqrms-tol", "maxValue": "sqrms+tol", "marks": 1}], "type": "gapfill", "prompt": "

Here is the ANOVA table corresponding to this data:

\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
SourcedfSSMSVR
Between Treatments$\\var{m-1}$$\\var{btss}$$\\var{msbt}$$\\var{vr}$
Between Blocks$\\var{n-1}$$\\var{bbss}$$\\var{msbb}$$\\var{vrbb}$
Residual$\\var{dfr}$$\\var{rss}$$\\var{rs}$-
Total$\\var{m*n-1}$$\\var{tss}$--
\n

Input $\\sqrt{RMS}$ here: [[0]] to 2 decimal places.

\n

This will be used later to calculate the yardsticks.

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

$p$ less than $0.1\\%$

", "

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

", "

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

", "

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

", "

$p$ is greater than $10\\%$

"], "displayColumns": 1, "prompt": "

Given the value of $VR$ in the table above, find the range for the $p$ value by looking up the critical values of $F_{3,12}$ (one-sided).

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$2.61$$3.49$$5.95$$10.8$
", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["Very strong", "Strong", "Moderate", "Weak", "None"], "displayColumns": 0, "prompt": "

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the treatments offered by the sun-creams?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["We reject the null hypothesis at the $0.1\\%$ level", "We reject the null hypothesis at the $1\\%$ level.", "We reject the null hypothesis at the $5\\%$ level.", "We do not reject the null hypothesis but more investigation is needed.", "We do not reject the null hypothesis."], "displayColumns": 1, "prompt": "

Hence what is your decision based on the above ANOVA analysis?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "me[0]-tol", "maxValue": "me[0]+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "me[1]-tol", "maxValue": "me[1]+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "me[2]-tol", "maxValue": "me[2]+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "me[3]-tol", "maxValue": "me[3]+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "lsd-tol", "maxValue": "lsd+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "tukey-tol", "maxValue": "tukey+tol", "marks": 1}], "type": "gapfill", "prompt": "

Using the yardsticks

\n

Enter the sample means for the sun-creams:

\n

W: [[0]], X:[[1]], Y:[[2]], Z:[[3]] (to 2 decimal places).

\n

Calclate the LSD and Tukey yardsticks using the value for $\\sqrt{RMS}$ to 2 decimal places obtained above.

\n

 

\n

LSD yardstick value =    [[4]] (to 2 decimal places).

\n

 

\n

Tukey yardstick value = [[5]] (to 2 decimal places).

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"layout": {"expression": ""}, "choices": ["$W$ and $X$", "$W$ and $Y$", "$W$ and $Z$", "$X$ and $Y$", "$X$ and $Z$", "$Y$ and $Z$"], "matrix": "w", "prompt": "

Using these yardsticks fill in the following table indicating if there is a possible or definite significant difference between the sample means of pairs of sun-creams.

\n

 

", "type": "m_n_x", "maxAnswers": 0, "shuffleChoices": false, "marks": 0, "scripts": {}, "maxMarks": 0, "minAnswers": 0, "minMarks": 0, "shuffleAnswers": false, "showCorrectAnswer": true, "answers": ["Definite Significant Difference", "Possible Significant Difference", "No Significant Difference"]}], "statement": "

To test the effectiveness of sun-tan creams, five volunteers A, B, C, D, E each tried four creams W, X, Y, Z on various parts of their legs. They were then subjected to ultra-violet radiation and an estimate of the degree of burning was made (higher figures indicate greater burning). The results are given below with some totals:

\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 \n \n \n \n \n \n \n
 WXYZTotals
A{r[0][0]}{r[0][1]}{r[0][2]}{r[0][3]}{t[0]}
B{r[1][0]}{r[1][1]}{r[1][2]}{r[1][3]}{t[1]}
C{r[2][0]}{r[2][1]}{r[2][2]}{r[2][3]}{t[2]}
D{r[3][0]}{r[3][1]}{r[3][2]}{r[3][3]}{t[3]}
E{r[4][0]}{r[4][1]}{r[4][2]}{r[4][3]}{t[4]}
Totals{cols[0]}{cols[1]}{cols[2]}{cols[3]}{tot}
\n

 

\n
    \n
  • Test the null-hypothesis using two-way ANOVA that the creams are equally effective.
  • \n
\n

 

\n
    \n
  • Write down the sample mean for each sun-cream together with the LSD and Tukey yardsticks so that you can see if there is any significant difference between the sample means given by these yardsticks..
  • \n
", "tags": ["ANOVA", "checked2015", "hypothesis testing", "lsd", "LSD", "PSY2010", "sample means", "significant difference", "statistics", "Tukey", "tukey ", "two-way ANOVA", "yardsticks", "Yardsticks"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

LSD and Tukey yardsticks on five treatments. Also two-way Anova test on same set of data.

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

 Using the Yardsticks

\n

The mean values for each sun-cream are:

\n

  

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 $\\overline{x}_i$
W$\\var{me[0]}$
X$\\var{me[1]}$
Y$\\var{me[2]}$
Z$\\var{me[3]}$
\n

The differences between the mean values for the sun-creams are:

\n

Between $W$ and $X=\\;|\\var{me[0]}-\\var{me[1]}|=\\var{abs(me[0]-me[1])}$

\n

Between $W$ and $Y=\\;|\\var{me[0]}-\\var{me[2]}|=\\var{abs(me[0]-me[2])}$

\n

Between $W$ and $Z=\\;|\\var{me[0]}-\\var{me[3]}|=\\var{abs(me[0]-me[3])}$

\n

Between $X$ and $Y=\\;|\\var{me[1]}-\\var{me[2]}|=\\var{abs(me[1]-me[2])}$

\n

Between $X$ and $Z=\\;|\\var{me[1]}-\\var{me[3]}|=\\var{abs(me[1]-me[3])}$

\n

Between $Y$ and $Z=\\;|\\var{me[2]}-\\var{me[3]}|=\\var{abs(me[2]-me[3])}$

\n

We compare these differences with the LSD and Tukey yardsticks:

\n

LSD yardstick = $2.179\\times\\var{sqrms}\\times\\sqrt{2/\\var{n}}=\\var{lsd}$ to 2 decimal places, where $\\var{sqrms}$ is the value of $\\sqrt{RMS}$ found above.

\n

Tukey yardstick = $4.2\\times\\var{sqrms}\\times\\sqrt{1/\\var{n}}=\\var{tukey}$ to 2 decimal places.

\n

If the difference of the means:

\n
    \n
  • is greater than the Tukey yardstick we say that there is evidence of a definite significant difference.
  • \n
\n

 

\n
    \n
  • less than the Tukey yardstick but greater than the LSD yardstick we say that there is evidence of a possible significant difference.
  • \n
\n

 

\n
    \n
  • is less than the LSD yardstick then we say that there is no  evidence of a significant difference.
  • \n
\n

 

\n

Hence we have the following for the sun-creams:

\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
Pairs of Sun-creamsDefinite Significant DifferencePossible Significant DifferenceNo Significant Difference
Means of W and X{yn[0][0]}{yn[0][1]}{yn[0][2]}
Means of W and Y{yn[1][0]}{yn[1][1]}{yn[1][2]}
Means of W and Z{yn[2][0]}{yn[2][1]}{yn[2][2]}
Means of X and Y{yn[3][0]}{yn[3][1]}{yn[3][2]}
Means of X and Z{yn[4][0]}{yn[4][1]}{yn[4][2]}
Means of Y and Z{yn[5][0]}{yn[5][1]}{yn[5][2]}
"}, {"name": "Perform a one-way ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stovern-G^2/N,2)", "description": "", "name": "btss"}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),6)", "description": "", "name": "r1"}, "dfbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "k-1", "description": "", "name": "dfbt"}, "pmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "description": "", "name": "pmsg"}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..5#0.2)", "description": "", "name": "sig1"}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2)),sum(map(x^2,x,r3))]", "description": "", "name": "ssq"}, "pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ftest(VR,2,15),3)", "description": "", "name": "pvalue"}, "mrs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(RSS/dfrs,2)", "description": "", "name": "mrs"}, "sd1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r1),2)", "description": "", "name": "sd1"}, "tss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ss-G^2/N,2)", "description": "", "name": "tss"}, "m3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r3),2)", "description": "", "name": "m3"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "cmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "description": "", "name": "cmsg"}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..25#0.5)", "description": "", "name": "mu1"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n1+n2+n3", "description": "", "name": "n"}, "stovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(tsqovern)", "description": "", "name": "stovern"}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "description": "", "name": "sig2"}, "v1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pvalue<=0.001,[1,0,0,0,0],pvalue<=0.01,[0,1,0,0,0],pvalue<=0.05,[0,0,1,0,0],pvalue<=0.1,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v1"}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(22..28#0.5)", "description": "", "name": "mu2"}, "n3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n3"}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n2"}, "vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(MBT/MRS,2)", "description": "", "name": "vr"}, "dfrs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "N-k", "description": "", "name": "dfrs"}, "rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ss-stovern,2)", "description": "", "name": "rss"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2),sum(r3)]", "description": "", "name": "t"}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n1"}, "sd3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r3),2)", "description": "", "name": "sd3"}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r1),2)", "description": "", "name": "m1"}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(ssq)", "description": "", "name": "ss"}, "r3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu3,sig3)),6)", "description": "", "name": "r3"}, "sig3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "description": "", "name": "sig3"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vr>=11.34,[1,0,0,0,0],vr>=6.36,[0,1,0,0,0],vr>=3.68,[0,0,1,0,0],vr>=2.7,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r2),2)", "description": "", "name": "m2"}, "stderror": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(mrs)/sqrt(n1),2)", "description": "", "name": "stderror"}, "mbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(BTSS/dfbt,2)", "description": "", "name": "mbt"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),6)", "description": "", "name": "r2"}, "mu3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(24..32#0.5)", "description": "", "name": "mu3"}, "g": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(t)", "description": "", "name": "g"}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n1,t[1]^2/n2,t[2]^2/n3]", "description": "", "name": "tsqovern"}, "u": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "description": "", "name": "u"}, "sd2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r2),2)", "description": "", "name": "sd2"}}, "ungrouped_variables": ["sd1", "sd2", "sd3", "mrs", "r2", "vr", "mbt", "pmsg", "stderror", "dfrs", "m1", "m3", "m2", "btss", "u", "tss", "dfbt", "tol", "ssq", "sig1", "v1", "sig3", "sig2", "cmsg", "rss", "tsqovern", "mu1", "g", "mu3", "mu2", "ss", "k", "r3", "n", "r1", "stovern", "t", "v", "n1", "n2", "n3", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "m1", "maxValue": "m1", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "sd1", "maxValue": "sd1", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "t[0]", "maxValue": "t[0]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "ssq[0]", "maxValue": "ssq[0]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "m2", "maxValue": "m2", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "sd2", "maxValue": "sd2", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "t[1]", "maxValue": "t[1]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "ssq[1]", "maxValue": "ssq[1]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "m3", "maxValue": "m3", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "sd3", "maxValue": "sd3", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "t[2]", "maxValue": "t[2]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "ssq[2]", "maxValue": "ssq[2]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "g", "maxValue": "g", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "ss", "maxValue": "ss", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}], "type": "gapfill", "prompt": "\n

First fill in this table with the appropriate values, all decimals to 2 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 \n
 $\\overline{x}_i$$s_i$$T_i$$\\sum x^2$$n_i$
Group A[[0]][[1]][[2]][[3]]6
Group B[[4]][[5]][[6]][[7]]6
Group C[[8]][[9]][[10]][[11]]6
   $G=\\;$[[12]]Sum of Squares=[[13]]$N=18$
\n

Note that in doing this you will have supplied the sample means and sample standard deviations for the three groups.

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "tss", "minValue": "tss", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "btss", "minValue": "btss", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "rss", "minValue": "rss", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n

Now find the following, all to 2 decimal places:

\n

$\\displaystyle TSS\\;=\\;$[[0]], $\\displaystyle BTSS\\;=\\;$[[1]], $\\displaystyle RSS\\;=\\;$[[2]]

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "dfbt", "maxValue": "dfbt", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "btss", "maxValue": "btss", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "mbt", "maxValue": "mbt", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "vr", "maxValue": "vr", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": true, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "dfrs", "maxValue": "dfrs", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "rss", "maxValue": "rss", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "mrs", "maxValue": "mrs", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "n-1", "maxValue": "n-1", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "tss", "maxValue": "tss", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "stderror-tol", "maxValue": "stderror+tol", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 1}], "type": "gapfill", "prompt": "

Now complete the ANOVA table using the values to 2 decimal places obtained above:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
SourcedfSSMSVR
Between Treatments[[0]][[1]][[2]][[3]]
Residual[[4]][[5]][[6]]-
Total[[7]][[8]]--
\n

Also calculate the estimated standard error of the mean : [[9]]

\n

Note that VR is found by taking the ratio of two of the values in this table.

\n

Input all numbers to 2 decimal places.

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

$p$ less than $0.1\\%$

", "

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

", "

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

", "

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

", "

$p$ is greater than $10\\%$

"], "displayColumns": 1, "prompt": "\n

Give the value of $VR$ you have found, choose the range for the $p$ value by looking up the critical values of $F_{2,15}$ (one-sided).

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$2.70$$3.68$$6.36$$11.34$
\n ", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["

Very Strong Evidence

", "

Strong Evidence

", "

Evidence

", "

Weak Evidence

", "

No Evidence

"], "displayColumns": 0, "prompt": "

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that the mean times taken are the same for the three groups?

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

We reject the null hypothesis at the $0.1\\%$ level

", "

We reject the null hypothesis at the $1\\%$ level.

", "

We reject the null hypothesis at the $5\\%$ level.

", "

We do not reject the null hypothesis but consider further investigation.

", "

We do not reject the null hypothesis.

"], "displayColumns": 1, "prompt": "

Hence what is your decision based on the above ANOVA analysis?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}], "statement": "\n

The following data arose in a comparison of the effects of alcohol on the time taken to complete a task. There were three groups of subjects; Group A had no alcohol, Group B had two units over 1 hour and Group C had 4 units over 1 hour. The responses are the times (in seconds) taken to complete a word-matching task.

\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
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$
\n
    \n
  • Write down the sample mean and standard deviation for each group together with an estimate of the standard error of a mean, $\\displaystyle\\frac{s}{\\sqrt{n}}$, to 2 decimal places.
  • \n
  • Test the null hypothesis that the alcohol consumption does not affect the mean time taken to complete the task.
  • \n
\n

 

\n ", "tags": ["ANOVA", "average", "checked2015", "data analysis", "degrees of freedom", "F-test", "hypothesis testing", "mean", "mean ", "one-way Anova", "one-way ANOVA", "PSY2010", "standard deviation", "statistics", "stats", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

11/07/2012:

\n \t\t


Added tags.

\n \t\t

Calculation not yet tested.

\n \t\t

23/07/2012:

\n \t\t

Added description.

\n \t\t

Checked calculation.

\n \t\t

3/08/2012:

\n \t\t

Added tags.

\n \t\t

Question appears to be working correctly.

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

One-way ANOVA example

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": ""}, {"name": "Perform a two-way ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sum(map(x^2,x,cols))/n-tot^2/(m*n),2)", "name": "btss", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "name": "tol", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(repeat(round(normalsample(mu[x],sig)),5),x,0..m-1)", "name": "r1", "description": ""}, "dfbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m-1", "name": "dfbt", "description": ""}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(sum(map(x^2,x,r[y])),y,0..n-1))", "name": "ssq", "description": ""}, "sig": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..7#0.2)", "name": "sig", "description": ""}, "t90": {"templateType": "anything", "group": "Ungrouped variables", "definition": "13.36", "name": "t90", "description": ""}, "tss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ssq-tot^2/(m*n),2)", "name": "tss", "description": ""}, "mu": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[random(30..40),random(35..40),random(25..35),random(40..45),random(20..40)]", "name": "mu", "description": ""}, "rs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(rss/dfr,2)", "name": "rs", "description": ""}, "t99": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20.09", "name": "t99", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vr>=10.8,[1,0,0,0,0],vr>=5.95,[0,1,0,0,0],vr>=3.49,[0,0,1,0,0],vr>=2.61,[0,0,0,1,0],[0,0,0,0,1])", "name": "v", "description": ""}, "msbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(btss/(m-1),2)", "name": "msbt", "description": ""}, "v1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pvalue<=0.001,[1,0,0,0,0],pvalue<=0.01,[0,1,0,0,0],pvalue<=0.05,[0,0,1,0,0],pvalue<=0.1,[0,0,0,1,0],[0,0,0,0,1])", "name": "v1", "description": ""}, "bbss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sum(map(x^2,x,t))/m-tot^2/20,2)", "name": "bbss", "description": ""}, "vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(msbt/rs,2)", "name": "vr", "description": ""}, "cols": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(rt[x]),x,0..m-1)", "name": "cols", "description": ""}, "pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ftest(VR,3,12),3)", "name": "pvalue", "description": ""}, "dfr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m*n-m-n+1", "name": "dfr", "description": ""}, "rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tss-btss-bbss", "name": "rss", "description": ""}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4", "name": "m", "description": ""}, "msbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(bbss/(n-1),2)", "name": "msbb", "description": ""}, "dfbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n-1", "name": "dfbb", "description": ""}, "vrbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(msbb/rs,2)", "name": "vrbb", "description": ""}, "t95": {"templateType": "anything", "group": "Ungrouped variables", "definition": "15.51", "name": "t95", "description": ""}, "tot": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(cols)", "name": "tot", "description": ""}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r1)))", "name": "r", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "5", "name": "n", "description": ""}, "stderror": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(rs/n),2)", "name": "stderror", "description": ""}, "rt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r)))", "name": "rt", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(r[x]),x,0..n-1)", "name": "t", "description": ""}}, "ungrouped_variables": ["stderror", "bbss", "cols", "vrbb", "vr", "rt", "rs", "msbb", "tot", "dfr", "sig", "tol", "btss", "tss", "dfbt", "msbt", "ssq", "v1", "dfbb", "t99", "t95", "t90", "rss", "r1", "m", "n", "mu", "r", "t", "v", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "tss-tol", "maxValue": "tss+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "btss-tol", "maxValue": "btss+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "bbss-tol", "maxValue": "bbss+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "rss-tol", "maxValue": "rss+tol", "marks": 1}], "type": "gapfill", "prompt": "

Treatment totals are:

\n

$T_1=\\var{cols[0]},\\;T_2=\\var{cols[1]},\\;T_3=\\var{cols[2]},\\;T_4=\\var{cols[3]}$

\n

Subject totals are:

\n

$B_1=\\var{t[0]},\\;B_2=\\var{t[1]},\\;B_3=\\var{t[2]},\\;B_4=\\var{t[3]},\\;B_5=\\var{t[4]}$

\n

$\\sum \\sum x^2 = \\var{ssq}$ and $G= \\var{tot}$

\n

Now using the above find the following, all to 2 decimal places:

\n

$\\displaystyle TSS\\;=\\;$[[0]], $\\displaystyle BTSS\\;=\\;$[[1]]

\n

$\\displaystyle BBSS \\;=\\;$[[2]], $\\displaystyle RSS\\;=\\;$[[3]]

\n

(Find $RSS$ using the values to 2 decimal places for $TSS,\\;BTSS,\\;BBSS$.)

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m-1", "maxValue": "m-1", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "btss-tol", "maxValue": "btss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "msbt-tol", "maxValue": "msbt+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "vr-0.01", "maxValue": "vr+0.01", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "n-1", "maxValue": "n-1", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "bbss-tol", "maxValue": "bbss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "msbb-0.01", "maxValue": "msbb+0.01", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "vrbb-0.01", "maxValue": "vrbb+0.01", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "dfr", "maxValue": "dfr", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "rss-tol", "maxValue": "rss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "rs-0.01", "maxValue": "rs+0.01", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m*n-1", "maxValue": "m*n-1", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "tss-tol", "maxValue": "tss+tol", "marks": 0.5}], "type": "gapfill", "prompt": "

Now complete the ANOVA table using the values obtained to 2 decimal places above:

\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
SourcedfSSMSVR
Between Treatments[[0]][[1]][[2]][[3]]
Between Blocks[[4]][[5]][[6]][[7]]
Residual[[8]][[9]][[10]]-
Total[[11]][[12]]--
\n

Input all numbers to 2 decimal places.

\n

 Note that VR is found by taking the ratio of two of the values in this table.

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

$p$ less than $0.1\\%$

", "

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

", "

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

", "

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

", "

$p$ is greater than $10\\%$

"], "displayColumns": 1, "prompt": "

Give the value of $VR$ you have found, choose the range for the $p$ value by looking up the critical values of $F_{3,12}$ (one-sided).

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$2.61$$3.49$$5.95$$10.8$
", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["

Very Strong Evidence

", "

Strong Evidence

", "

Evidence

", "

Weak Evidence

", "

No Evidence

"], "displayColumns": 0, "prompt": "

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the treatments offered by the sun-creams?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["We reject the null hypothesis at the $0.1\\%$ level", "We reject the null hypothesis at the $1\\%$ level.", "We reject the null hypothesis at the $5\\%$ level.", "We do not reject the null hypothesis but more investigation is needed.", "We do not reject the null hypothesis."], "displayColumns": 1, "prompt": "

Hence what is your decision based on the above ANOVA analysis?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "mean(r1[0])-tol", "maxValue": "mean(r1[0])+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "mean(r1[1])-tol", "maxValue": "mean(r1[1])+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "mean(r1[2])-tol", "maxValue": "mean(r1[2])+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "mean(r1[3])-tol", "maxValue": "mean(r1[3])+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "stderror-tol", "maxValue": "stderror+tol", "marks": 1}], "type": "gapfill", "prompt": "

Enter the sample means for the sun-creams:

\n

W: [[0]], X:[[1]], Y:[[2]], Z:[[3]]

\n

Also enter an estimate of the standard error of the mean: [[4]]

\n

(Use the value to 2 decimal places you obtained above for $RMS$ to calculate the standard error of the mean).

", "showCorrectAnswer": true, "marks": 0}], "statement": "

To test the effectiveness of sun-tan creams, five volunteers A, B, C, D, E each tried four creams W, X, Y, Z on various parts of their legs. They were then subjected to ultra-violet radiation and an estimate of the degree of burning was made (higher figures indicate greater burning). The results are given below with some totals:

\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 \n \n \n \n \n \n \n
 WXYZTotals
A{r[0][0]}{r[0][1]}{r[0][2]}{r[0][3]}{t[0]}
B{r[1][0]}{r[1][1]}{r[1][2]}{r[1][3]}{t[1]}
C{r[2][0]}{r[2][1]}{r[2][2]}{r[2][3]}{t[2]}
D{r[3][0]}{r[3][1]}{r[3][2]}{r[3][3]}{t[3]}
E{r[4][0]}{r[4][1]}{r[4][2]}{r[4][3]}{t[4]}
Totals{cols[0]}{cols[1]}{cols[2]}{cols[3]}{tot}
\n

You are given that $\\sum \\sum x^2=\\var{ssq}$ is the uncorrected sum of squares of the observations and you are asked to:

\n
    \n
  • Complete the two-way analysis of variance and test the null-hypothesis that the creams are equally effective.
  • \n
\n

 

\n
    \n
  • Write down the sample mean for each sun-cream together with an estimate of the standard error of the mean, $\\frac{s}{\\sqrt{n}}$.
  • \n
", "tags": ["ANOVA", "checked2015", "hypothesis testing", "PSY2010", "statistics", "two-way ANOVA"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

Two-way ANOVA example, 5 subjects, 4 treatments.

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

 

\n

 

"}, {"name": "Apply Friedman test", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variablesTest": {"condition": "", "maxRuns": 100}, "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(repeat(round(normalsample(mu[x],sig)),5),x,0..m-1)", "description": "", "name": "r1"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(fr>=16.266,[1,0,0,0,0],fr >=11.345,[0,1,0,0,0],fr>=7.815,[0,0,1,0,0],fr>=6.251,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "sig": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..7#0.2)", "description": "", "name": "sig"}, "sun": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['A','B','C','D','E']", "description": "", "name": "sun"}, "surk": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(list(srk)[x]),x,0..3)", "description": "", "name": "surk"}, "rs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "matrix(map(rep(rk(r[x])[4..8]),x,0..4))", "description": "", "name": "rs"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "5", "description": "", "name": "n"}, "mu": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[random(30..40),random(35..40),random(25..35),random(40..45),random(20..40)]", "description": "", "name": "mu"}, "fr1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "12/(n*m*(m+1))*sum(map(surk[x]^2,x,0..3))-3*n*(m+1)", "description": "", "name": "fr1"}, "disptab": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(if(scorr[x]=0,'',table(tiesplus[x],['Subject $'+sun[x]+'$','Number of Ties','Contribution','Value'])),x,0..4)", "description": "", "name": "disptab"}, "dec": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,'we very strongly reject the null hypothesis at the $0.11\\\\%$ level and conclude that the suncreams differ in their effect.',\n v[1]=1,'we strongly reject the null hypothesis at the $1\\\\%$ level and conclude that the suncreams differ in their effect.',\n v[2]=1,'we have evidence to reject the null hypothesis at the $5\\\\%$ level and conclude that the suncreams differ in their effect.',\n v[3]=1,'we only have weak evidence against the null hypothesis at the $10\\\\%$ level and we do not reject it',\n 'there is no evidence against the null hypothesis and we accept it.')", "description": "", "name": "dec"}, "vties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(round(rs[y][x]/(x+1))*(((x+1)^3-(x+1))/(n*(m^3-m))),x,1..abs(rs[y])-1),y,0..4)\n", "description": "", "name": "vties"}, "tieslist": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(round(rs[y][x]/(x+1)),x,1..m-1),y,0..4)\n", "description": "", "name": "tieslist"}, "nties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(tieslist[x]),x,0..4)", "description": "", "name": "nties"}, "mess1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(tscorr=0, '(no ties, so $T=0$).','')", "description": "", "name": "mess1"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4", "description": "", "name": "m"}, "scorr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(vties[x]),x,0..4)", "description": "", "name": "scorr"}, "fr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(fr1/(1-tscorr),2)", "description": "", "name": "fr"}, "tscorr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(scorr)", "description": "", "name": "tscorr"}, "tiesplus": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(['Ties of size $'+(x+1)+'$.','$'+round(rs[y][x]/(x+1))+'$', '$\\\\,\\\\,\\\\,\\\\,\\\\, \\\\displaystyle '+round(rs[y][x]/(x+1))+'\\\\times \\\\displaystyle \\\\frac{'+(x+1)+'^3-'+(x+1)+'}{'+n+'('+m+'^3-'+m+')}$','$'+vties[y][x-1]+'$'],x,1..abs(rs[y])-1),y,0..4)", "description": "", "name": "tiesplus"}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r1)))", "description": "", "name": "r"}, "rnk": {"templateType": "anything", "group": "Ungrouped variables", "definition": "matrix(map(rk(r[x])[0..4],x,0..4))", "description": "", "name": "rnk"}, "rt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r)))", "description": "", "name": "rt"}, "messtab": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(tscorr=0, 'that there are no ties.','that there are ties as follows:')", "description": "", "name": "messtab"}, "srk": {"templateType": "anything", "group": "Ungrouped variables", "definition": "transpose((rnk))", "description": "", "name": "srk"}}, "ungrouped_variables": ["tieslist", "vties", "rt", "scorr", "rs", "sun", "sig", "tol", "disptab", "rnk", "tiesplus", "fr", "surk", "mess1", "messtab", "nties", "tscorr", "r1", "srk", "m", "n", "mu", "fr1", "r", "v", "dec"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"rep": {"type": "list", "language": "javascript", "definition": "/*the list a contains natural numbers up to a maximum value M. \n This function outputs an array where arr[j]/(j+1)=number of ties of size j+1*/\n var b=a.sort(function(c,d){return c-d});\n var M=b[a.length-1];\n var arr=[];\n for(var j=1;j<=M;j++){\nvar s=0;\nfor(var i=0;il[i]){s+=1;}\n else\nif(l[j]==l[i]){c+=1;}\n}\n out[j]=(2*s+c+1)/2;\n rep[j]=c;\n }\n return out.concat(rep);\n\n", "parameters": [["l", "list"]]}}, "variable_groups": [], "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][0]", "minValue": "srk[0][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][1]", "minValue": "srk[0][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][2]", "minValue": "srk[0][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][3]", "minValue": "srk[0][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][4]", "minValue": "srk[0][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[0]", "minValue": "surk[0]", "showCorrectAnswer": true, "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][0]", "minValue": "srk[1][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][1]", "minValue": "srk[1][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][2]", "minValue": "srk[1][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][3]", "minValue": "srk[1][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][4]", "minValue": "srk[1][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[1]", "minValue": "surk[1]", "showCorrectAnswer": true, "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][0]", "minValue": "srk[2][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][1]", "minValue": "srk[2][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][2]", "minValue": "srk[2][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][3]", "minValue": "srk[2][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][4]", "minValue": "srk[2][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[2]", "minValue": "surk[2]", "showCorrectAnswer": true, "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][0]", "minValue": "srk[3][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][1]", "minValue": "srk[3][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][2]", "minValue": "srk[3][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][3]", "minValue": "srk[3][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][4]", "minValue": "srk[3][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[3]", "minValue": "surk[3]", "showCorrectAnswer": true, "marks": 0.5}], "type": "gapfill", "prompt": "\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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
SubjectABCDETotals
Suncream      
W$\\var{r1[0][0]}$$\\var{r1[0][1]}$$\\var{r1[0][2]}$$\\var{r1[0][3]}$$\\var{r1[0][4]}$ 
Rank[[0]][[1]][[2]][[3]][[4]]$R_1=\\;$[[5]]
X$\\var{r1[1][0]}$$\\var{r1[1][1]}$$\\var{r1[1][2]}$$\\var{r1[1][3]}$$\\var{r1[1][4]}$ 
Rank[[6]][[7]][[8]][[9]][[10]]$R_2=\\;$[[11]]
Y$\\var{r1[2][0]}$$\\var{r1[2][1]}$$\\var{r1[2][2]}$$\\var{r1[2][3]}$$\\var{r1[2][4]}$ 
Rank[[12]][[13]][[14]][[15]][[16]]$R_3=\\;$[[17]]
Z$\\var{r1[3][0]}$$\\var{r1[3][1]}$$\\var{r1[3][2]}$$\\var{r1[3][3]}$$\\var{r1[3][4]}$ 
Rank[[18]][[19]][[20]][[21]][[22]]$R_4=\\;$[[23]]
\n

Rank each column separately and enter the ranks in the table, using the method you used for the Kruskal-Wallis question. (Hence the sum of the ranks in each column should be 10). Also input the sums of the ranks $R_1,\\;R_2,\\;R_3$ and $R_4$ for each row.

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "fr1", "minValue": "fr1", "showCorrectAnswer": true, "marks": 2}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "1-tscorr", "minValue": "1-tscorr", "showCorrectAnswer": true, "marks": 2}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "fr+tol", "minValue": "fr-tol", "showCorrectAnswer": true, "marks": 1}], "type": "gapfill", "prompt": "

Next you  work out the uncorrected (for ties) Friedman statistic $\\chi_r^2$.

\n

Here:

\n

$t = \\;$ number of treatments i.e. suncreams $\\;=4$

\n

$b=\\;$ number of subjects $\\;=5$.

\n

$\\displaystyle \\chi_r^2= \\frac{12}{b\\times t \\times (t+1)}\\left[\\sum R_i^2 \\right]-\\left\\{3\\times b\\times (t+1)\\right\\}=\\;$[[0]] (Input to 2 decimal places).

\n

Now input the correction term due to the ties:

\n

$C=\\;$[[1]] (Input to 2 decimal places).

\n

Hence the corrected Friedman test statistic is:

\n

$\\chi_r^{2^*}=\\;$[[2]]  (Input to 2 decimal places).

\n

 

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

We have very strong evidence to  reject the null hypothesis at the $0.1\\%$ level and conclude that the suncreams differ in their effect.

", "

We have strong evidence to reject the null hypothesis at the $1\\%$ level and conclude that the suncreams differ in their effect.

", "

We have evidence to reject the null hypothesis at the $5\\%$ level and conclude that the suncreams differ in their effect.

", "

We only have weak evidence against the null hypothesis at the $10\\%$ level and so we retain the null hypothesis.

", "

We have no  evidence against the null hypothesis so we retain the null hypothesis that the suncreams have the same effect.

"], "matrix": "v", "prompt": "

Give the value of $\\chi_r^{2^*}$ you have found, and the $\\chi^2$ table data:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$6.251$$7.815$$11.345$$16.266$
\n

What is your decision?

\n

\n

 

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "maxMarks": 0, "type": "1_n_2", "minMarks": 0, "showCorrectAnswer": true, "displayColumns": 1, "marks": 0}], "statement": "

To test the effectiveness of sun-tan creams, five volunteers A, B, C, D, E each tried four creams W, X, Y, Z on various parts of their legs. They were then subjected to ultra-violet radiation and an estimate of the degree of burning was made (higher figures indicate greater burning). The results are given below with some totals:

\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
 WXYZ
A{r[0][0]}{r[0][1]}{r[0][2]}{r[0][3]}
B{r[1][0]}{r[1][1]}{r[1][2]}{r[1][3]}
C{r[2][0]}{r[2][1]}{r[2][2]}{r[2][3]}
D{r[3][0]}{r[3][1]}{r[3][2]}{r[3][3]}
E{r[4][0]}{r[4][1]}{r[4][2]}{r[4][3]}
\n

 

\n

Apply the Friedman test to this data in relation to the null hypothesis that there is no difference in the effectiveness of the suncreams.

", "tags": ["checked2015", "correction term", "Friedman statistic", "hypothesis testing", "PSY2010", "ranks", "statistics", "ties", "treatments"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

Friedman test, 5 subjects, 4 treatments.

"}, "advice": "

Step 1.

\n

First we present the data as in the next table, changing rows to columns, and work out the ranks of each of the columns. So all we are doing is ranking the four numbers in each column separately. We use the method of finding ranks as explained for the Kruskal-Wallis example. Then we sum over the ranks in each row.

\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\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
SubjectABCDETotals
Suncream      
W$\\var{r1[0][0]}$$\\var{r1[0][1]}$$\\var{r1[0][2]}$$\\var{r1[0][3]}$$\\var{r1[0][4]}$ 
Rank{srk[0][0]}{srk[0][1]}{srk[0][2]}{srk[0][3]}{srk[0][4]}$R_1=\\;${surk[0]}
X$\\var{r1[1][0]}$$\\var{r1[1][1]}$$\\var{r1[1][2]}$$\\var{r1[1][3]}$$\\var{r1[1][4]}$ 
Rank{srk[1][0]}{srk[1][1]}{srk[1][2]}{srk[1][3]}{srk[1][4]}$R_2=\\;${surk[1]}
Y$\\var{r1[2][0]}$$\\var{r1[2][1]}$$\\var{r1[2][2]}$$\\var{r1[2][3]}$$\\var{r1[2][4]}$ 
Rank{srk[2][0]}{srk[2][1]}{srk[2][2]}{srk[2][3]}{srk[2][4]}$R_3=\\;${surk[2]}
Z$\\var{r1[3][0]}$$\\var{r1[3][1]}$$\\var{r1[3][2]}$$\\var{r1[3][3]}$$\\var{r1[3][4]}$ 
Rank{srk[3][0]}{srk[3][1]}{srk[3][2]}{srk[3][3]}{srk[3][4]}$R_4=\\;${surk[3]}
 
Ties{nties[0]}{nties[1]}{nties[2]}{nties[3]}{nties[4]}$\\var{sum(nties)}$
\n

 

\n

 

\n

Step 2: Next we work out the uncorrected (for ties) Friedman statistic $\\chi_r^2$.

\n

Here:

\n

$t = \\;$ number of treatments i.e. suncreams $\\;=4$

\n

$b=\\;$ number of subjects $\\;=5$.

\n

\\[\\begin{eqnarray*}\\chi_r^2&=& \\frac{12}{b\\times t \\times (t+1)}\\left[\\sum R_i^2 \\right]-\\left\\{3\\times b\\times (t+1)\\right\\}\\\\&=&\\left\\{\\frac{12}{\\var{n}\\times\\var{m}\\times\\var{m+1}}\\left[\\var{surk[0]}^2+\\var{surk[1]}^2+\\var{surk[2]}^2+\\var{surk[3]}^2\\right]\\right\\}-\\left\\{3\\times\\var{n}\\times \\var{m+1}\\right\\}\\\\&=&\\var{fr}\\end{eqnarray*}\\]

\n

 Step 3: Next we calculate the Correction Factor $C$

\n

Only necessary if there are some ties, otherwise $C=1$.

\n

For each tie in a column with $g$ equal values we calculate $\\displaystyle \\frac{g^3-g}{b(t^3-t)}$.

\n

$T$ is the sum of all these values and then the Correction Factor $C= 1-T$. 

\n

So for this example we note  {messtab}

\n

{table(disptab,[])}

\n

Summing over the values {mess1} we find $T=\\var{tscorr} \\Rightarrow C=1- \\var{tscorr}=\\var{1-tscorr}$.

\n

Step 4.

\n

Next we calculate the corrected Friedman statistic allowing for ties.

\n

$ \\displaystyle \\chi_r^{2^*}=\\frac{\\chi_r^{2}}{C} = \\frac{\\var{fr1}}{\\var{1-tscorr}}=\\var{fr}$ to 2 decimal places.

\n

Step 5. Make a decision.

\n

Looking at the table in conjunction with the test statistic we have just worked out, {dec}

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$6.251$$7.815$$11.345$$16.266$
"}, {"name": "Apply Kruskal-Wallis test", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"s1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['$\\\\bf{Ordered\\\\;\\\\; times}$']+sort(biglist)", "description": "", "name": "s1"}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "ran": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(biglist)", "description": "", "name": "ran"}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..5#0.2)", "description": "", "name": "sig1"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n1+n2+n3", "description": "", "name": "n"}, "sr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(ran[x..x+6]),x,[0,6,12])", "description": "", "name": "sr"}, "sd1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r1),2)", "description": "", "name": "sd1"}, "corr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1-1/(n^3-n)*g", "description": "", "name": "corr"}, "m3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r3),2)", "description": "", "name": "m3"}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n2"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "rs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rep(ran[18..36])", "description": "", "name": "rs"}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(22..28#0.5)", "description": "", "name": "mu2"}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..25#0.5)", "description": "", "name": "mu1"}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "description": "", "name": "sig2"}, "ties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(['Number of ties of size $'+x+1+'$ =', round(rs[x]/(x+1))],x,1..abs(rs)-1)", "description": "", "name": "ties"}, "kw": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(h/corr,2)", "description": "", "name": "kw"}, "dec": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(w[0]=1,'we very strongly reject the null hypothesis at the $0.1\\\\%$ level and conclude that reaction times differ depending upon alcohol uptake.',\n w[1]=1,'we strongly reject the null hypothesis at the $1\\\\%$ level and conclude that reaction times differ depending on alcohol uptake.',\n w[2]=1,'we have evidence against the null hypothesis at the $5\\\\%$ level and we reject it',\n w[3]=1, 'we only have weak evidence against the null hypothesis at the $10\\\\%$ level so we do not reject it.',\n'there is no evidence against the null hypothesis and so we accept it.' )", "description": "", "name": "dec"}, "g": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(ran[x]^2-1,x,18..35))", "description": "", "name": "g"}, "rkt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ran[0..18]", "description": "", "name": "rkt"}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r2),2)", "description": "", "name": "m2"}, "w": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(kw>=13.816,[1,0,0,0,0],kw >=9.210,[0,1,0,0,0],kw>=5.991,[0,0,1,0,0],kw>=4.605,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "w"}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n1"}, "sd3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r3),2)", "description": "", "name": "sd3"}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r1),2)", "description": "", "name": "m1"}, "r3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu3,sig3)),6)", "description": "", "name": "r3"}, "tiesplus": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(['Ties of size $'+(x+1)+'$','$'+round(rs[x]/(x+1))+'$', '$\\\\,\\\\,\\\\,\\\\,\\\\, \\\\displaystyle '+round(rs[x]/(x+1))+'\\\\times \\\\displaystyle \\\\frac{'+(x+1)+'^3-'+(x+1)+'}{'+n+'^3-'+n+'}$','$'+vties[x-1]+'$'],x,1..abs(rs)-1)+[['Total',' ',' ','$T='+sum(vties)+'$']]", "description": "", "name": "tiesplus"}, "n3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n3"}, "sig3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "description": "", "name": "sig3"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),6)", "description": "", "name": "r2"}, "s3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['$\\\\bf{Rank}$']+ sort(rkt)", "description": "", "name": "s3"}, "biglist": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1+r2+r3", "description": "", "name": "biglist"}, "mu3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(24..32#0.5)", "description": "", "name": "mu3"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),6)", "description": "", "name": "r1"}, "sd2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r2),2)", "description": "", "name": "sd2"}, "s2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['$\\\\bf{Index}$']+map(x,x,1..18)", "description": "", "name": "s2"}, "h": {"templateType": "anything", "group": "Ungrouped variables", "definition": "12/(n*(n+1))*sum(map(x^2/n1,x,sr))-3*(n+1)", "description": "", "name": "h"}, "vties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(round(rs[x]/(x+1))*(((x+1)^3-(x+1))/(n^3-n)),x,1..abs(rs)-1)", "description": "", "name": "vties"}}, "ungrouped_variables": ["rkt", "sd1", "sd2", "sd3", "ran", "biglist", "vties", "mu3", "rs", "s3", "s2", "s1", "m1", "tol", "m2", "tiesplus", "m3", "sig1", "sig3", "sig2", "corr", "ties", "r1", "n3", "mu1", "g", "r2", "mu2", "h", "k", "r3", "n", "kw", "w", "sr", "n1", "n2", "dec"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}, "rep": {"type": "list", "language": "javascript", "definition": "\nvar b=a.sort(function(c,d){return c-d});\n var M=b[a.length-1];\n var arr=[];\n for(var j=1;j<=M;j++){\nvar s=0;\nfor(var i=0;il[i]){s+=1;}\n else\nif(l[j]==l[i]){c+=1;}\n}\n out[j]=(2*s+c+1)/2;\n rep[j]=c;\n }\n return out.concat(rep);\n\n", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[0]", "minValue": "ran[0]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[1]", "minValue": "ran[1]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[2]", "minValue": "ran[2]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[3]", "minValue": "ran[3]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[4]", "minValue": "ran[4]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[5]", "minValue": "ran[5]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "sr[0]", "minValue": "sr[0]", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[6]", "minValue": "ran[6]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[7]", "minValue": "ran[7]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[8]", "minValue": "ran[8]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[9]", "minValue": "ran[9]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[10]", "minValue": "ran[10]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[11]", "minValue": "ran[11]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "sr[1]", "minValue": "sr[1]", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[12]", "minValue": "ran[12]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[13]", "minValue": "ran[13]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[14]", "minValue": "ran[14]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[15]", "minValue": "ran[15]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[16]", "minValue": "ran[16]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[17]", "minValue": "ran[17]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "sr[2]", "minValue": "sr[2]", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Kruskal-Wallis Test

\n

First fill in this table with the appropriate values, all decimals to 1 decimal place. $R_1,\\;R_2,\\;R_3$  are the sums of the ranks in each row.

\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\n\n\n\n\n
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$ 
Rank[[0]][[1]][[2]][[3]][[4]][[5]]$R_1=\\;$[[6]]
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$ 
Rank[[7]][[8]][[9]][[10]][[11]][[12]]$R_2=\\;$[[13]]
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$ 
Rank[[14]][[15]][[16]][[17]][[18]][[19]]$R_3=\\;$[[20]]
\n

 

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "precround(H,3)+0.001", "minValue": "precround(H,3)-0.001", "correctAnswerFraction": false, "marks": 2, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "precround(corr,3)", "minValue": "precround(corr,3)", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "kw+0.01", "minValue": "kw-0.01", "correctAnswerFraction": false, "marks": 2, "showPrecisionHint": false}, {"displayType": "radiogroup", "choices": ["

We very strongly reject the null hypothesis at the $0.1\\%$ level and conclude that reaction times differ depending upon alcohol uptake.

", "

We strongly reject the null hypothesis at the $1\\%$ level and conclude that reaction times differ depending upon alcohol uptake.

", "

We have evidence against the null hypothesis at the $5\\%$ level and conclude that reaction times differ depending upon alcohol uptake.

", "

We only have weak evidence against the null hypothesis at the $10\\%$ level and so accept that reaction times do not depend upon alcohol uptake.

", "

We have no evidence against the null hypothesis and so accept that reaction times do not depend upon alcohol uptake.

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

Now calculate the Kruskal-Wallis  test statistic in the following steps as in your notes:

\n

$H=\\;$[[0]] (Assuming no ties).  Calculate to 3 decimal places.

\n

$C=\\;$[[1]] (Correction for ties). Calculate to 3 decimal places.

\n

Kruskal-Wallis statistic $H^*=\\;$ [[2]].   Calculate to 2 decimal places.

\n

 

\n

Give the value of $H^*$ you have found, determine the significance of your result by looking up the critical values in the $\\chi^2$ table.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$4.605$$5.991$$9.210$$13.816$
\n

Hence what can you say using the Kruskal-Wallis test about the null hypothesis that times to do the task do not depend upon the levels of alcohol?

\n

[[3]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "

The following data arose in a comparison of the effects of alcohol on the time taken to complete a task. There were three groups of subjects; Group A had no alcohol, Group B had two units over 1 hour and Group C had 4 units over 1 hour. The responses are the times (in seconds) taken to complete a word-matching task.

\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
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$
\n

\n Apply the Kruskal-Wallis test to this data on reaction times under alcohol in order to test the null hypothesis that the alcohol consumption does not affect the mean time taken to complete the task. \n \n

 

", "tags": ["checked2015", "correction for ties", "data analysis", "hypothesis testing", "Kruskal-Wallis", "one-way Anova", "one-way ANOVA", "PSY2010", "rank", "statistics", "stats", "ties"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

29/11/2012:

\n \t\t


Created question from one-way Anova question

\n \t\t

Added tags.

\n \t\t

Calculation not yet tested.

\n \t\t

Added description.

\n \t\t

Checked calculation.

\n \t\t

Kept Anova test in for comparison purposes.

\n \t\t

 

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Kruskal-Wallis test with ties.

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

In order to find the ranks we order, in increasing order,  all of the times for the tasks across all the three groups. We also work out the ranks for each time by including a row which simply numbers from $1$ to $\\var{n}$, this we call the index of the numbers and the last row then takes equal values in the list and gives the averages of their indices, so that they all get the same rank. So you simply add up their corresponding indices in that group and divide by the number of equal entries. So if a number is not repeated then its rank is its index. 

\n

For this example we have:

\n

{table([s1,s2,s3],[])}

\n

We see that there are ties as follows:

\n

{table(ties,[])}

\n

We use this information later to find the correction factor.

\n

Putting these ranks back into the original table gives, where $R_1,\\;R_2$ and $R_3$ are the sums of the ranks in each row:

\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\n\n\n\n\n
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$ 
Rank{rkt[0]}{rkt[1]}{rkt[2]}{rkt[3]}{rkt[4]}{rkt[5]}$R_1=\\;${sr[0]}
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$ 
Rank{rkt[6]}{rkt[7]}{rkt[8]}{rkt[9]}{rkt[10]}{rkt[11]}$R_2=\\;${sr[1]}
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$ 
Rank{rkt[12]}{rkt[13]}{rkt[14]}{rkt[15]}{rkt[16]}{rkt[17]}$R_3=\\;${sr[2]}
\n

We now have enough information to start the calculation of the Kruskal-Wallis statistic.

\n

We do this in three steps:

\n

1. Calculate the statistic $H$, which assumes there are no ties.

\n

2. Find the correction factor $C$ given by the ties in the data.

\n

3. This gives the statistic $H^*=H/C$ we want, and we make a decision based on the Kruskal-Wallis table.

\n

Step 1: Find $H$.

\n

\\[\\begin{eqnarray*}H &=& \\left[\\frac{12}{N \\times (N+1)} \\times \\left(\\sum \\frac{R_i^2}{n_i}\\right)\\right]-3(N+1)\\\\&=&\\left\\{\\frac{12}{\\var{n}\\times\\var{n+1}}\\times\\left(\\frac{\\var{sr[0]}^2}{6}+\\frac{\\var{sr[1]}^2}{6}+\\frac{\\var{sr[2]}^2}{6}\\right)\\right\\}-3\\times \\var{n+1}\\\\&=&\\var{h}\\\\&=&\\var{precround(H,3)}\\end{eqnarray*}\\] to 3 decimal places.

\n

Step 2: Find the Correction Factor $C$.

\n

For each tie with $g$ equal data values we calculate $\\displaystyle \\frac{g^3-g}{N^3-N}$ and add these together over all ties to get $T$.

\n

Then $C=1-T$.

\n

So for our data we have:

\n

{table(tiesplus,[' ','Number','Contribution','Value'])}

\n

Hence $C=1-T = 1-\\var{sum(vties)}=\\var{1-sum(vties)}=\\var{precround(corr,3)}$ to 3 decimal places.

\n

Step 3: Find the Kruskal-Wallis test statistic and make a decision.

\n

The statistic is given by $\\displaystyle H^*=\\frac{H}{C}=\\frac{\\var{precround(h,3)}}{\\var{precround(corr,3)}}=\\var{kw}$ to 2 decimal places.

\n

Looking at the $\\chi^2$ table our decision is that {dec}

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$4.605$$5.991$$9.210$$13.816$
\n

"}, {"name": "Perform a two-factor ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((stovern*N-G^2)/N,2)", "name": "btss", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),10)", "name": "r1", "description": ""}, "m4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r4),2)", "name": "m4", "description": ""}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2)),sum(map(x^2,x,r3)),sum(map(x^2,x,r4))]", "name": "ssq", "description": ""}, "f1stovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(f1tsqovern)", "name": "f1stovern", "description": ""}, "f2l1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1+r3", "name": "f2l1", "description": ""}, "f1btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((f1stovern*40-g^2)/40,2)", "name": "f1btss", "description": ""}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..3#0.2)", "name": "sig2", "description": ""}, "w1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vvr[1]>=12.88,[1,0,0,0,0],vvr[1]>=7.41,[0,1,0,0,0],vvr[1]>=4.12,[0,0,1,0,0],vvr[1]>=2.86,[0,0,0,1,0],[0,0,0,0,1])", "name": "w1", "description": ""}, "w0": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vvr[0]>=12.88,[1,0,0,0,0],vvr[0]>=7.41,[0,1,0,0,0],vvr[0]>=4.12,[0,0,1,0,0],vvr[0]>=2.86,[0,0,0,1,0],[0,0,0,0,1])", "name": "w0", "description": ""}, "m3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r3),2)", "name": "m3", "description": ""}, "rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ss-stovern,2)", "name": "rss", "description": ""}, "f1ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(f1ssq)", "name": "f1ss", "description": ""}, "r4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu4,sig1)),10)", "name": "r4", "description": ""}, "f2ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(f2ssq)", "name": "f2ss", "description": ""}, "f1t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(f1L1),sum(f1L2)]", "name": "f1t", "description": ""}, "w2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vvr[2]>=12.88,[1,0,0,0,0],vvr[2]>=7.41,[0,1,0,0,0],vvr[2]>=4.12,[0,0,1,0,0],vvr[2]>=2.86,[0,0,0,1,0],[0,0,0,0,1])", "name": "w2", "description": ""}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r2),2)", "name": "m2", "description": ""}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),10)", "name": "r2", "description": ""}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(ssq)", "name": "ss", "description": ""}, "g": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(t)", "name": "g", "description": ""}, "f2btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((f2stovern*40-g^2)/40,2)", "name": "f2btss", "description": ""}, "f1ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,f1L1)),sum(map(x^2,x,f1L2))]", "name": "f1ssq", "description": ""}, "w": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[w0,w1,w2]", "name": "w", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "name": "tol", "description": ""}, "tss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((ss*N-G^2)/N,2)", "name": "tss", "description": ""}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..3#0.2)", "name": "sig1", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n1+n2+n3+n4", "name": "n", "description": ""}, "mrs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(RSS/36,2)", "name": "mrs", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2),sum(r3),sum(r4)]", "name": "t", "description": ""}, "ivr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(interactionss/mrs,2)", "name": "ivr", "description": ""}, "interactionss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "btss-f1btss-f2btss", "name": "interactionss", "description": ""}, "vvr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[f1vr,f2vr,ivr]", "name": "vvr", "description": ""}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n2", "description": ""}, "f1l1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1+r2", "name": "f1l1", "description": ""}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..25#0.5)", "name": "mu1", "description": ""}, "stovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(tsqovern)", "name": "stovern", "description": ""}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu1-random(3..5#0.2)", "name": "mu2", "description": ""}, "mu4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu3-random(1..2#0.1)", "name": "mu4", "description": ""}, "f2stovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum([f2t[0]^2/20,f2t[1]^2/20])", "name": "f2stovern", "description": ""}, "f1l2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r3+r4", "name": "f1l2", "description": ""}, "f1tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[f1t[0]^2/20,f1t[1]^2/20]", "name": "f1tsqovern", "description": ""}, "f1rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(f1ss-f1stovern,2)", "name": "f1rss", "description": ""}, "f2ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,f2L1)),sum(map(x^2,x,f2L2))]", "name": "f2ssq", "description": ""}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n1,t[1]^2/n2,t[2]^2/n3,t[3]^2/n4]", "name": "tsqovern", "description": ""}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n1", "description": ""}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r1),2)", "name": "m1", "description": ""}, "f2vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(f2btss/mrs,2)", "name": "f2vr", "description": ""}, "r3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu3,sig1)),10)", "name": "r3", "description": ""}, "n3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n3", "description": ""}, "f2t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(f2L1),sum(f2L2)]", "name": "f2t", "description": ""}, "n4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n4", "description": ""}, "f2l2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r2+r4", "name": "f2l2", "description": ""}, "mu3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(22..26#0.5)", "name": "mu3", "description": ""}, "f1vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(f1btss/mrs,2)", "name": "f1vr", "description": ""}}, "ungrouped_variables": ["ivr", "f1vr", "f2vr", "w2", "w1", "w0", "f1l2", "f1l1", "n", "mu3", "f1ssq", "f1btss", "m4", "m1", "m3", "m2", "btss", "f2btss", "rss", "tss", "f1t", "r4", "tol", "f2ssq", "ssq", "vvr", "sig1", "sig2", "f1ss", "w", "n2", "interactionss", "tsqovern", "mu4", "mu1", "g", "r2", "mu2", "ss", "f1tsqovern", "r3", "f2ss", "mrs", "f1rss", "f2l1", "f2l2", "r1", "stovern", "t", "f1stovern", "f2t", "n1", "f2stovern", "n3", "n4"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"dec": {"type": "string", "language": "jme", "definition": "switch(vr>=12.88, 'Very strongly reject the null hypothesis ($p\\\\le 0.001$)',vr>=7.41,'Strongly reject the null hypothesis ($0.001 \\\\lt p \\\\le 0.01$)',vr>=4.12, 'Reject the null hypothesis ($0.01 \\\\lt p \\\\le 0.05$)',vr>=2.86,'Accept the null hypothesis ($0.05 \\\\lt p \\\\le 0.1$)','Accept the null hypothesis($p\\\\gt 0.1$)') ", "parameters": [["vr", "number"]]}, "pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "1", "maxValue": "1", "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f1btss-tol", "maxValue": "f1btss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f1btss-tol", "maxValue": "f1btss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f1vr-tol", "maxValue": "f1vr+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "1", "maxValue": "1", "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f2btss-tol", "maxValue": "f2btss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f2btss-tol", "maxValue": "f2btss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f2vr-tol", "maxValue": "f2vr+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "1", "maxValue": "1", "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "interactionss-tol", "maxValue": "interactionss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "interactionss-tol", "maxValue": "interactionss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "ivr-tol", "maxValue": "ivr+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "36", "maxValue": "36", "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "rss-tol", "maxValue": "rss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "mrs-tol", "maxValue": "mrs+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "39", "maxValue": "39", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "precround(f1btss+f2btss+interactionss+rss,2)-tol", "maxValue": "precround(f1btss+f2btss+interactionss+rss,2)+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m1", "maxValue": "m1", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m2", "maxValue": "m2", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m3", "maxValue": "m3", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m4", "maxValue": "m4", "marks": 0.5}], "type": "gapfill", "prompt": "

Now complete the following two factor ANOVA table from this data. Input the $SS,\\;MS$ and $VR$ data to 2 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
SourcedfSSMSVR
Personality[[0]][[1]][[2]][[3]]
Stimulus[[4]][[5]][[6]][[7]]
P-S interaction[[8]][[9]][[10]][[11]]
Residual[[12]][[13]][[14]]-
Total[[15]][[16]]--
\n

The Calculations.

\n

1. Residual Calculations. When you are calculating $TSS$ and $BTSS$ round them both to 2 decimal places, then calculate $RSS$ by taking away these rounded values. The $RMS$ value is then obtained by dividing this $RSS$ value by the residual degrees of freedom.

\n

2. For Personality, Stimulus and Interaction, calculate the estimations of their variances to 2 decimal places as well. These values go in the $MS$ column.

\n

3. The $VR$ values are obtained by dividing the first three values in the $MS$ column by the $RMS$ value. Enter the $VR$ values to 2 decimal places in the last column.

\n

 

\n

Also input the mean values of the factors at their various levels, input your answers to 2 decimal places:

\n

 

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
 $\\overline{x}_i$
Normal, Baseline[[17]]
Normal, Stress[[18]]
Antisocial, Baseline[[19]]
Antisocial, Stress[[20]]
", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"layout": {"expression": ""}, "choices": ["GSR: no dependence upon personality.", "GSR: no dependence upon stimulus.", "No interaction between the factors."], "matrix": "w", "type": "m_n_x", "maxAnswers": 0, "shuffleChoices": false, "marks": 0, "scripts": {}, "minMarks": 0, "minAnswers": 0, "maxMarks": 0, "shuffleAnswers": false, "showCorrectAnswer": true, "answers": ["Very strong rejection, $p \\le 0.001$.", "Strong rejection, $0.001\\lt p \\le 0.01$.", "Rejection, $0.01\\lt p \\le 0.05$.", "Accept, but investigate, $0.05\\lt p \\le 0.1$.", "Accept, $p \\gt 0.1$."]}], "type": "gapfill", "prompt": "

Using the following p-values for the $F_{1,36}$ statistic find the appropriate significance levels for the factors as given by their $VR$ value and then comment on the null hypotheses for each factor and the interaction.

\n

 

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$2.86$$4.12$$7.41$$12.88$
\n

 

\n

[[0]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "

 In a similar fashion to the calculation done in lectures, carry out a two factor ANOVA on the following set of data.

\n

Individuals who are identified as having an antisocial personality disorder may also have reduced physiological responses to anxiety-producing stimuli.

\n

One way of measuring this response is with ”galvanic skin response” (GSR), a measurable reduction in the electrical resistance on the skin. [This is the basis of how a lie detector works.]

\n

The following data represent the results of an experiment to compare the responses of normal and antisocial individuals in regular (baseline) and stress-provoking situations (low score reflects a more anxious individual):

\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
NormalBaseline$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Stress$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
AntisocialBaseline$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$$\\var{r3[6]}$$\\var{r3[7]}$$\\var{r3[8]}$$\\var{r3[9]}$
Stress$\\var{r4[0]}$$\\var{r4[1]}$$\\var{r4[2]}$$\\var{r4[3]}$$\\var{r4[4]}$$\\var{r4[5]}$$\\var{r4[6]}$$\\var{r4[7]}$$\\var{r4[8]}$$\\var{r4[9]}$
\n

 The null hypotheses we are testing are:

\n

1. The GSR does not depend upon the personality type.

\n

2. The GSR does not depend upon the stimulus.

\n

3. There is no interaction between personality and stimulus in determining the GSR.

\n

 

", "tags": ["ANOVA", "average", "checked2015", "data analysis", "degrees of freedom", "F-test", "factors", "hypothesis testing", "levels", "mean", "mean ", "p values", "PSY2010", "statistics", "stats", "two factor ANOVA", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

26/11/2012

\n


Added tags and description.

\n

Changed calculations for BTSS for the factors and added the interaction analysis.

\n

Uses the inbuilt ftest function from the stats extension to find p values.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Two factor ANOVA example

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

We have two factors: Personality and Stimulus.

\n

Personality has two levels: Normal and Antisocial

\n

Stimulus has two levels: Baseline and Stress.

\n

First Step:

\n

First regard the different treatment combinations as a set of independent samples and analyse as for a one-way analysis with unrelated measurements. From this analysis, we obtain the Total Sum of Squares, the Between Treatments Sum of Squares ($BTSS$) and Residual Sum of Squares ($RSS$). Note that the degrees of freedom for this step are 36=40-4 as there are 4 treatments.

\n

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 \n \n
 $\\overline{x}_i$$T_i$$\\sum x^2$$n_i$
Normal, Baseline$\\var{m1}$$\\var{t[0]}$$\\var{ssq[0]}$10
Normal, Stress$\\var{m2}$$\\var{t[1]}$$\\var{ssq[1]}$10
Antisocial, Baseline$\\var{m3}$$\\var{t[2]}$$\\var{ssq[2]}$10
Antisocial, Stress$\\var{m4}$$\\var{t[3]}$$\\var{ssq[3]}$10
  $G=\\;\\var{g}$Sum of Squares=$\\var{ss}$$N=40$
\n

From this we obtain:

\n

\\[ BTSS =\\sum \\frac{T_i^2}{10}- \\frac{G^2}{40}=\\frac{\\var{t[0]}^2}{10}+\\frac{\\var{t[1]}^2}{10}+\\frac{\\var{t[2]}^2}{10}+\\frac{\\var{t[3]}^2}{10}-\\frac{\\var{g}^2}{40}=\\var{btss}\\]

\n

\\[TSS = \\sum \\sum x^2- \\frac{G^2}{40}=\\var{ss}- \\frac{\\var{g}^2}{40}=\\var{tss}\\] both to 2 decimal places.

\n

\\[RSS = TSS-BTSS=\\var{tss}-\\var{btss}=\\var{rss}\\]

\n

Second Step.

\n

Now ignore the Stimulus factor and calculate totals $T_i$ for each level of Personality. From these totals calculate a variance estimate for personality using the same method as before. The degrees of freedom will be one fewer than the levels of Stimulus and is therefore 1.

\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
Normal (Baseline and Stress)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
Antisocial (Baseline and Stress)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$$\\var{r3[6]}$$\\var{r3[7]}$$\\var{r3[8]}$$\\var{r3[9]}$$\\var{r3[0]}$$\\var{r4[1]}$$\\var{r4[2]}$$\\var{r4[3]}$$\\var{r4[4]}$$\\var{r4[5]}$$\\var{r4[6]}$$\\var{r4[7]}$$\\var{r4[8]}$$\\var{r4[9]}$
\n

You should have the following data from this 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
 $T_i$$\\sum x^2$$n_i$ (number of observations)
Normal, (Baseline and Stress)$\\var{f1t[0]}$$\\var{f1ssq[0]}$20
Antisocial, (Baseline and Stress)$\\var{f1t[1]}$$\\var{f1ssq[1]}$20
 $G=\\;\\var{g}$Sum of Squares=$\\var{f1ss}$$N=40$
\n

So we can calculate:

\n

\\[\\mbox{Variance estimate for personality} =\\sum \\frac{T_i^2}{20}- \\frac{G^2}{40}=\\frac{\\var{f1t[0]}^2}{20}+\\frac{\\var{f1t[1]}^2}{20}-\\frac{\\var{g}^2}{40}=\\var{f1btss}\\]

\n

Third Step.

\n

Repeat step 2 with the factors switched, i.e. use the totals $T_i$ for the Stimulus factor levels ignoring Personality.This gives a Between Treatments Sum of Squares. Again the degrees of freedom will be 2-1=1.

\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
Baseline (Normal and Antisocial)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$$\\var{r2[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$$\\var{r3[6]}$$\\var{r3[7]}$$\\var{r3[8]}$$\\var{r3[9]}$
Stress (Normal and Antisocial)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$$\\var{r4[0]}$$\\var{r4[1]}$$\\var{r4[2]}$$\\var{r4[3]}$$\\var{r4[4]}$$\\var{r4[5]}$$\\var{r4[6]}$$\\var{r4[7]}$$\\var{r4[8]}$$\\var{r4[9]}$
\n

You should have the following data from this 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
 $T_i$$\\sum x^2$$n_i$ (number of observations)
Baseline (Normal and Antisocial)$\\var{f2t[0]}$$\\var{f2ssq[0]}$20
Stress (Normal and Antisocial)$\\var{f2t[1]}$$\\var{f2ssq[1]}$20
 $G=\\;\\var{g}$Sum of Squares=$\\var{f2ss}$$N=40$
\n

So we can calculate:

\n

\\[ \\mbox{Variance estimate for stimulus} =\\sum \\frac{T_i^2}{20}- \\frac{G^2}{40}=\\frac{\\var{f2t[0]}^2}{20}+\\frac{\\var{f2t[1]}^2}{20}-\\frac{\\var{g}^2}{40}=\\var{f2btss}\\]

\n

Step 4.

\n

Now determine a Sum of Squares for Interaction by subtracting the sums of squares obtained for Personality (Step 2) and Stimulus (step 3) from the overall Between Treatments Sum of squares obtained in Step 1. The degrees of freedom is also obtained by subtraction and is 1.

\n

This gives: 

\n

\\[\\mbox{Variance estimate for the interaction}= \\var{btss}-\\var{f1btss}-\\var{f2btss} = \\var{interactionss}\\]

\n

The Anova Table.

\n

We now have all the terms required to construct the ANOVA table and hence test the null hypothesis relating to each factor and to the interaction. Note that the $VR$ values are obtained by dividing the $RMS$ value into the $MS$ values for the factors and the interaction.

\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
SourcedfSSMSVRDecision
Personality1$\\var{f1btss}$$\\var{f1btss}$$\\var{f1vr}${dec(f1vr)} that GSR is independent of personality.
Stimulus1$\\var{f2btss}$$\\var{f2btss}$$\\var{f2vr}${dec(f2vr)} that GSR is independent of the stimulus.
P-S interaction1 $\\var{interactionss}$  $\\var{interactionss}$ $\\var{ivr}$ {dec(ivr)} that personality and stimulus are independent in terms of GSR.
Residual36$\\var{rss}$$\\var{mrs}$- 
Total39$\\var{precround(f1btss+f2btss+interactionss+rss,2)}$-- 
"}, {"name": "Calculate Pearson correlation coefficient", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"rr1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r1)", "description": "", "name": "rr1"}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "darr(n,m,[random(1..20)])", "description": "", "name": "r1"}, "spxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sxy-t[0]*t[1]/n", "description": "", "name": "spxy"}, "d": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(rr1)-vector(rr2))", "description": "", "name": "d"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20", "description": "", "name": "m"}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "description": "", "name": "ssq"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2)]", "description": "", "name": "t"}, "vs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(spcoef >=0.952,[1,0,0,0,0],spcoef>=0.881,[0,1,0,0,0],spcoef>=0.738,[0,0,1,0,0],spcoef>=0.643,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "vs"}, "rr2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r2)", "description": "", "name": "rr2"}, "spcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(6*ssd/(n*(n^2-1)),3)", "description": "", "name": "spcoef"}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "description": "", "name": "ss"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(corrcoef >=0.905,[1,0,0,0,0],corrcoef>=0.834,[0,1,0,0,0],corrcoef>=0.707,[0,0,1,0,0],corrcoef>=0.621,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "8", "description": "", "name": "n"}, "obj": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['A','B','C','D','E','F','G','H']", "description": "", "name": "obj"}, "ssd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(x^2,x,d))", "description": "", "name": "ssd"}, "sxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "description": "", "name": "sxy"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tesarr(r1,darr(n,m,[random(1..m)]),9,m)", "description": "", "name": "r2"}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n,t[1]^2/n]", "description": "", "name": "tsqovern"}, "corrcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spxy/sqrt(ss[0]*ss[1]),3)", "description": "", "name": "corrcoef"}}, "ungrouped_variables": ["tsqovern", "obj", "r1", "r2", "ss", "m", "k", "ssq", "ssd", "n", "spcoef", "corrcoef", "vs", "spxy", "t", "tol", "v", "sxy", "rr2", "rr1", "d"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"darr": {"type": "list", "language": "jme", "definition": "if(n=1,a,darr(n-1,m,[random(1..m except a)]+a))", "parameters": [["n", "number"], ["m", "number"], ["a", "list"]]}, "tesarr": {"type": "list", "language": "jme", "definition": "if(marr(map(abs(x),x,list(vector(a)-vector(b))))a[i]){s+=1;}\n else\n if(a[j]==a[i]){c+=1;}\n }\n out[j]=(2*s+c+1)/2;\n }\n return out;", "parameters": [["a", "list"]]}, "marr": {"type": "number", "language": "jme", "definition": "if(length(a)=2,max(a[0],a[1]),max(a[0],marr(a[1..length(a)])))", "parameters": [["a", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "t[0]", "minValue": "t[0]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ssq[0]", "minValue": "ssq[0]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "t[1]", "minValue": "t[1]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ssq[1]", "minValue": "ssq[1]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "sxy", "minValue": "sxy", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ss[0]", "minValue": "ss[0]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ss[1]", "minValue": "ss[1]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "spxy", "minValue": "spxy", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "corrcoef+tol", "minValue": "corrcoef-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n \n \n \n \n \n \n \n \n \n \n
Wife $(X)$$\\sum x=\\;$[[0]]$\\sum x^2=\\;$[[1]]
Husband $(Y)$$\\sum y=\\;$[[2]]$\\sum y^2=\\;$[[3]]
\n

Also find $\\sum xy=\\;$[[4]] and then:

\n

$\\displaystyle SSX = \\;$[[5]]

\n

$\\displaystyle SSY = \\;$[[6]]

\n

$\\displaystyle SPXY = \\;$[[7]]

\n

Hence calculate the correlation coefficient $r$:

\n

$r=\\;$[[8]]

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.621", "minValue": "0.621", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.707", "minValue": "0.707", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.834", "minValue": "0.834", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.905", "minValue": "0.905", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"displayType": "radiogroup", "choices": ["$p \\leq 0.002$, very strong evidence to reject the null hypothesis that there is no association.", "$0.002 \\lt p \\leq 0.01$, strong evidence to reject the null hypothesis that there is no association.", "$0.01 \\lt p \\leq 0.05$, there is evidence to reject the null hypothesis that there is no association.", "$0.05 \\lt p \\leq 0.1$, weak evidence against, do not reject the null hypothesis but consider further investigation.", "$p \\gt 0.1$, no evidence to reject the null hypothesis that there is no association."], "displayColumns": 1, "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}], "type": "gapfill", "prompt": "

Give the value of the correlation coefficient you have found, choose the range for the $p$ value by looking up the relevant table. Input the required values from the table here:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.2\\%$
[[0]][[1]][[2]][[3]]
\n

Then make a decision based on the $p$-value you have found by choosing one of these options:

\n

[[4]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "

It is well known that similarity in attitudes, beliefs and interests plays an important role in interpersonal attraction. A researcher developed a questionnaire which was completed by 8 married couples. One question sought to place each individual on a 20 point scale in which low scores represent liberal attitudes and high scores represent conservative attitudes. The data were:

\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
Couple$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$
Wife $(X)$$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$
Husband $(Y)$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$
\n

In this exercise you will find the Pearson correlation coefficent for the above paired data and comment on the significance of the calculated correlation.

\n

The null hypothesis you are testing is:

\n

$H_0$: There is no association between the attitudes of wives and husbands.

", "tags": ["checked2015", "correlation coefficient", "data analysis", "hypothesis testing", "Pearson correlation coefficient", "PSY2010", "statistics"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

30/09/2102:

\n

Introduced three functions:

\n

1. To produce the ranking of a list of 8 numbers.

\n

2. To produce a list of 8 numbers from a scale of 1..20 which are all distinct.

\n

3. To produce the maximum of the numbers in a list.

\n

4. Given an array such as in 2. to find another such array which has max diff between any two corresponding entries less than a given number. This is to ensure that the two array produced do not differ too much, as the point of the exercise is to show that there is a positive high correlation.

\n

 

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Calculate the Pearson correlation coefficient on paired data and comment on the significance.

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

The answers to all parts are given on revealing.

"}, {"name": "Calculate Pearson correlation coefficient", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "darr(n,m,[random(1..20)])", "description": "", "name": "r1"}, "spxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sxy-t[0]*t[1]/n", "description": "", "name": "spxy"}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "description": "", "name": "ssq"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2)]", "description": "", "name": "t"}, "rr1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r1)", "description": "", "name": "rr1"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "description": "", "name": "n"}, "ssd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(x^2,x,d))", "description": "", "name": "ssd"}, "corrcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spxy/sqrt(ss[0]*ss[1]),3)", "description": "", "name": "corrcoef"}, "d": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(rr1)-vector(rr2))", "description": "", "name": "d"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20", "description": "", "name": "m"}, "spcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1-6*ssd/(n*(n^2-1)),3)", "description": "", "name": "spcoef"}, "vs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(aspcoef >=0.952,[1,0,0,0,0],aspcoef>=0.881,[0,1,0,0,0],aspcoef>=0.738,[0,0,1,0,0],aspcoef>=0.643,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "vs"}, "rr2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r2)", "description": "", "name": "rr2"}, "sxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "description": "", "name": "sxy"}, "aspcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "abs(spcoef)", "description": "", "name": "aspcoef"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(corrcoef >=0.847,[1,0,0,0,0],corrcoef>=0.765,[0,1,0,0,0],corrcoef>=0.632,[0,0,1,0,0],corrcoef>=0.549,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "obj": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['A','B','C','D','E','F','G','H','I','J']", "description": "", "name": "obj"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tesarr(r1,darr(n,m,[random(1..m)]),11,m)", "description": "", "name": "r2"}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "description": "", "name": "ss"}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n,t[1]^2/n]", "description": "", "name": "tsqovern"}}, "ungrouped_variables": ["aspcoef", "spcoef", "vs", "sxy", "spxy", "tol", "ssq", "corrcoef", "ssd", "rr2", "rr1", "r1", "tsqovern", "obj", "d", "r2", "ss", "k", "m", "n", "t", "v"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"darr": {"type": "list", "language": "jme", "definition": "if(n=1,a,darr(n-1,m,[random(1..m except a)]+a))", "parameters": [["n", "number"], ["m", "number"], ["a", "list"]]}, "rk": {"type": "list", "language": "javascript", "definition": "\n /*This gives the ranking of the entries in a, c counts the ties */\n var out = [];\n for(var j=0;ja[i]){s+=1;}\n else\n if(a[j]==a[i]){c+=1;}\n }\n out[j]=(2*s+c+1)/2;\n }\n return out;\n ", "parameters": [["a", "list"]]}, "pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}, "marr": {"type": "number", "language": "jme", "definition": "if(length(a)=2,max(a[0],a[1]),max(a[0],marr(a[1..length(a)])))", "parameters": [["a", "list"]]}, "tesarr": {"type": "list", "language": "jme", "definition": "if(marr(map(abs(x),x,list(vector(a)-vector(b))))\n \n Wife $(X)$\n $\\sum x=\\;$[[0]]\n $\\sum x^2=\\;$[[1]]\n \n Husband $(Y)$\n $\\sum y=\\;$[[2]]\n $\\sum y^2=\\;$[[3]]\n \n \n \n

Also find $\\sum xy=\\;$[[4]] and then:

\n

$\\displaystyle SSX = \\;$[[5]]

\n

$\\displaystyle SSY = \\;$[[6]]

\n

$\\displaystyle SPXY = \\;$[[7]]

\n

Hence calculate the correlation coefficient $r$:

\n

$r=\\;$[[8]]

\n

 

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.549", "minValue": "0.549", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.632", "minValue": "0.632", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.765", "minValue": "0.765", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.847", "minValue": "0.847", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"displayType": "radiogroup", "choices": ["$p \\leq 0.002$, very strong evidence to reject the null hypothesis that there is no association.", "$0.002 \\lt p \\leq 0.01$, strong evidence to reject the null hypothesis that there is no association.", "$0.01 \\lt p \\leq 0.05$, there is evidence to reject the null hypothesis that there is no association.", "$0.05 \\lt p \\leq 0.1$, weak evidence against, do not reject the null hypothesis but consider further investigation.", "$p \\gt 0.1$, no evidence to reject the null hypothesis that there is no association."], "displayColumns": 1, "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}], "type": "gapfill", "prompt": "\n

Give the value of the correlation coefficient you have found, choose the range for the $p$ value by looking up the relevant table. Input the required values from the table here:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.2\\%$
[[0]][[1]][[2]][[3]]
\n

Then make a decision based on the $p$-value you have found by choosing one of these options:

\n

[[4]]

\n ", "showCorrectAnswer": true, "marks": 0}], "statement": "

It is well known that similarity in attitudes, beliefs and interests plays an important role in interpersonal attraction. A researcher developed a questionnaire which was completed by 10 married couples. One question sought to place each individual on a 20 point scale in which low scores represent liberal attitudes and high scores represent conservative attitudes. The data were:

\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
Couple$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$$\\var{obj[8]}$$\\var{obj[9]}$
Wife $(X)$$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Husband $(Y)$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
\n

In this exercise you will find the Pearson correlation coefficent for the above paired data and comment on the significance of the calculated correlation.

\n

The null hypothesis you are testing is:

\n

$H_0$: There is no association between the attitudes of wives and husbands.

", "tags": ["checked2015", "correlation coefficient", "data analysis", "hypothesis testing", "Pearson correlation coefficient", "PSY2010", "statistics"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

30/09/2102:

\n \t\t

Introduced three functions:

\n \t\t

1. To produce the ranking of a list of 8 numbers.

\n \t\t

2. To produce a list of 8 numbers from a scale of 1..20 which are all distinct.

\n \t\t

3. To produce the maximum of the numbers in a list.

\n \t\t

4. Given an array such as in 2. to find another such array which has max diff between any two corresponding entries less than a given number. This is to ensure that the two array produced do not differ too much, as the point of the exercise is to show that there is a positive high correlation.

\n \t\t

 

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Calculate the Pearson correlation coefficient on paired data and comment on the significance.

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

The answers to all parts are given on revealing.

"}, {"name": "Calculate Spearman rank correlation coefficient and p-values", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "darr(n,m,[random(1..20)])", "description": "", "name": "r1"}, "spxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sxy-t[0]*t[1]/n", "description": "", "name": "spxy"}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "description": "", "name": "ssq"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2)]", "description": "", "name": "t"}, "rr1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r1)", "description": "", "name": "rr1"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "description": "", "name": "n"}, "ssd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(x^2,x,d))", "description": "", "name": "ssd"}, "corrcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spxy/sqrt(ss[0]*ss[1]),3)", "description": "", "name": "corrcoef"}, "d": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(rr1)-vector(rr2))", "description": "", "name": "d"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20", "description": "", "name": "m"}, "spcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1-6*ssd/(n*(n^2-1)),3)", "description": "", "name": "spcoef"}, "vs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(aspcoef >=0.879,[1,0,0,0,0],aspcoef>=0.794,[0,1,0,0,0],aspcoef>=0.648,[0,0,1,0,0],aspcoef>=0.564,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "vs"}, "rr2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r2)", "description": "", "name": "rr2"}, "sxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "description": "", "name": "sxy"}, "aspcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "abs(spcoef)", "description": "", "name": "aspcoef"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(corrcoef >=0.905,[1,0,0,0,0],corrcoef>=0.834,[0,1,0,0,0],corrcoef>=0.707,[0,0,1,0,0],corrcoef>=0.621,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "obj": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['A','B','C','D','E','F','G','H','I','J']", "description": "", "name": "obj"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tesarr(r1,darr(n,m,[random(1..m)]),9,m)", "description": "", "name": "r2"}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "description": "", "name": "ss"}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n,t[1]^2/n]", "description": "", "name": "tsqovern"}}, "ungrouped_variables": ["aspcoef", "spcoef", "vs", "sxy", "spxy", "tol", "ssq", "corrcoef", "ssd", "rr2", "rr1", "r1", "tsqovern", "obj", "d", "r2", "ss", "k", "m", "n", "t", "v"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"darr": {"type": "list", "language": "jme", "definition": "if(n=1,a,darr(n-1,m,[random(1..m except a)]+a))", "parameters": [["n", "number"], ["m", "number"], ["a", "list"]]}, "rk": {"type": "list", "language": "javascript", "definition": "\n /*This gives the ranking of the entries in a, c counts the ties */\n var out = [];\n for(var j=0;ja[i]){s+=1;}\n else\n if(a[j]==a[i]){c+=1;}\n }\n out[j]=(2*s+c+1)/2;\n }\n return out;\n \n ", "parameters": [["a", "list"]]}, "pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}, "marr": {"type": "number", "language": "jme", "definition": "if(length(a)=2,max(a[0],a[1]),max(a[0],marr(a[1..length(a)])))", "parameters": [["a", "list"]]}, "tesarr": {"type": "list", "language": "jme", "definition": "if(marr(map(abs(x),x,list(vector(a)-vector(b))))Spearman Correlation Coefficient

\n

In order to find the Spearman correlation coefficient for the original score data you need to supply the ranked data for the wives and the husbands in the table below. Lowest rank has rank $1$, highest score has rank $10$. Also supply the differences in the ranks, i.e. for each couple find wife's score - husband's score.

\n

Now fill in the ranks given by

\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
Couple$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$$\\var{obj[8]}$$\\var{obj[9]}$
Wife $(X)$[[0]][[1]][[2]][[3]][[4]][[5]][[6]][[7]][[8]][[9]]
Husband $(Y)$[[10]][[11]][[12]][[13]][[14]][[15]][[16]][[17]][[18]][[19]]
Differences[[20]][[21]][[22]][[23]][[24]][[25]][[26]][[27]][[28]][[29]]
\n

 

\n

Hence calculate the Spearman correlation coefficient to 3 decimal places:

\n

$r_s=\\;$[[30]]

\n

Click on Show steps for the Spearman correlation coefficient formula. You will not lose any marks by doing so.

", "steps": [{"type": "information", "prompt": "

If there are two sets of ranks $x_1,x_2,\\ldots,x_n$ and  $y_1,y_2,\\ldots,y_n$ where both sets have no ties, and differences are $d_i=x_i-y_i$ then if $\\sum d_i^2=D$ we have:

\n

\\[r_s=1-\\frac{6 \\times D}{n(n^2-1)}\\]

", "showCorrectAnswer": true, "scripts": {}, "marks": 0}], "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.564", "minValue": "0.564", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.648", "minValue": "0.648", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.794", "minValue": "0.794", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.879", "minValue": "0.879", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Give the value of the Spearman correlation coefficient you have found, find the the significance level by looking up the appropriate values in a table. 

\n

First supply the table values you need from your notes:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.2\\%$
[[0]][[1]][[2]][[3]]
\n

 

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["$p \\leq 0.002$, very strong evidence to reject the hypothesis.", "$0.002 \\lt p \\leq 0.01$, strong evidence to reject the hypothesis.", "$0.01 \\lt p \\leq 0.05$, there is evidence to reject the hypothesis.", "$0.05 \\lt p \\leq 0.1$, weak evidence against, do not reject the hypothesis but consider further investigation.", "$p \\gt 0.1$, no evidence to reject the hypothesis."], "displayColumns": 1, "prompt": "

Given the data above, what decision can you come to as to the hypothesis that the wife and husband in these married couples have the same attitude in relation to liberal and conservative values?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "vs", "marks": 0}], "statement": "

It is well known that similarity in attitudes, beliefs and interests plays an important role in interpersonal attraction. A researcher developed a questionnaire which was completed by 10 married couples. One question sought to place each individual on a 20 point scale in which low scores represent liberal attitudes and high scores represent conservative attitudes. The data were:

\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
Couple$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$$\\var{obj[8]}$$\\var{obj[9]}$
Wife $(X)$$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Husband $(Y)$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
\n

In this exercise you will find Spearman's correlation coefficient for this data and comment on the significance of the correlation as regards the following null hypothesis:

\n

$H_0$: There is no association between the attitudes of wives and husbands.

", "tags": ["checked2015", "data analysis", "hypothesis testing", "PSY2010", "ranked data", "ranks", "Spearman correlation coefficient", "statistics"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t \t\t

30/09/2102:

\n \t\t \t\t

Introduced three functions:

\n \t\t \t\t

1. To produce the ranking of a list of 8 numbers.

\n \t\t \t\t

2. To produce a list of 8 numbers from a scale of 1..20 which are all distinct.

\n \t\t \t\t

3. To produce the maximum of the numbers in a list.

\n \t\t \t\t

4. Given an array such as in 2. to find another such array which has max diff between any two corresponding entries less than a given number. This is to ensure that the two array produced do not differ too much, as the point of the exercise is to show that there is a positive high correlation.

\n \t\t \t\t

 

\n \t\t \n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Spearman rank correlation calculated. 10 paired observations.

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

When the question is revealed you will see all the answers.

"}, {"name": "Calculate the Spearman rank correlation coefficient and p-value", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "darr(n,m,[random(1..20)])", "description": "", "name": "r1"}, "spxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sxy-t[0]*t[1]/n", "description": "", "name": "spxy"}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "description": "", "name": "ssq"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2)]", "description": "", "name": "t"}, "rr1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r1)", "description": "", "name": "rr1"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "8", "description": "", "name": "n"}, "ssd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(x^2,x,d))", "description": "", "name": "ssd"}, "corrcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spxy/sqrt(ss[0]*ss[1]),3)", "description": "", "name": "corrcoef"}, "d": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(rr1)-vector(rr2))", "description": "", "name": "d"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20", "description": "", "name": "m"}, "spcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1-6*ssd/(n*(n^2-1)),3)", "description": "", "name": "spcoef"}, "vs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(aspcoef >=0.952,[1,0,0,0,0],aspcoef>=0.881,[0,1,0,0,0],aspcoef>=0.738,[0,0,1,0,0],aspcoef>=0.643,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "vs"}, "rr2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(r2)", "description": "", "name": "rr2"}, "sxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "description": "", "name": "sxy"}, "aspcoef": {"templateType": "anything", "group": "Ungrouped variables", "definition": "abs(spcoef)", "description": "", "name": "aspcoef"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(corrcoef >=0.905,[1,0,0,0,0],corrcoef>=0.834,[0,1,0,0,0],corrcoef>=0.707,[0,0,1,0,0],corrcoef>=0.621,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "obj": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['A','B','C','D','E','F','G','H']", "description": "", "name": "obj"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tesarr(r1,darr(n,m,[random(1..m)]),10,m)", "description": "", "name": "r2"}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "description": "", "name": "ss"}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n,t[1]^2/n]", "description": "", "name": "tsqovern"}}, "ungrouped_variables": ["aspcoef", "spcoef", "vs", "sxy", "spxy", "tol", "ssq", "corrcoef", "ssd", "rr2", "rr1", "r1", "tsqovern", "obj", "d", "r2", "ss", "k", "m", "n", "t", "v"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"darr": {"type": "list", "language": "jme", "definition": "if(n=1,a,darr(n-1,m,[random(1..m except a)]+a))", "parameters": [["n", "number"], ["m", "number"], ["a", "list"]]}, "rk": {"type": "list", "language": "javascript", "definition": "\n /*This gives the ranking of the entries in a, c counts the ties */\n var out = [];\n for(var j=0;ja[i]){s+=1;}\n else\n if(a[j]==a[i]){c+=1;}\n }\n out[j]=(2*s+c+1)/2;\n }\n return out;\n ", "parameters": [["a", "list"]]}, "pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}, "marr": {"type": "number", "language": "jme", "definition": "if(length(a)=2,max(a[0],a[1]),max(a[0],marr(a[1..length(a)])))", "parameters": [["a", "list"]]}, "tesarr": {"type": "list", "language": "jme", "definition": "if(marr(map(abs(x),x,list(vector(a)-vector(b))))Spearman Correlation Coefficient

\n

In order to find the Spearman correlation coefficient for the original score data you need to supply the ranked data for the wives and the husbands in the table below. Lowest rank has rank $1$, highest score has rank $8$. Also supply the differences in the ranks, i.e. for each couple find wife's score - husband's score.

\n

Now fill in the ranks given by

\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
Couple$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$
Wife $(X)$[[0]][[1]][[2]][[3]][[4]][[5]][[6]][[7]]
Husband $(Y)$[[8]][[9]][[10]][[11]][[12]][[13]][[14]][[15]]
Differences[[16]][[17]][[18]][[19]][[20]][[21]][[22]][[23]]
\n

 

\n

Hence calculate the Spearman correlation coefficient to 3 decimal places:

\n

$r_s=\\;$[[24]]

\n

Click on Show steps for the Spearman correlation coefficient formula. You will not lose any marks by doing so.

\n ", "steps": [{"type": "information", "prompt": "

If there are two sets of ranks $x_1,x_2,\\ldots,x_n$ and  $y_1,y_2,\\ldots,y_n$ where both sets have no ties, and differences are $d_i=x_i-y_i$ then if $\\sum d_i^2=D$ we have:

\n

\\[r_s=1 - \\frac{6 \\times D}{n(n^2-1)}\\]

", "showCorrectAnswer": true, "scripts": {}, "marks": 0}], "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.643", "minValue": "0.643", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.738", "minValue": "0.738", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.881", "minValue": "0.881", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "0.952", "minValue": "0.952", "correctAnswerFraction": false, "marks": 0.25, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Give the value of the Spearman correlation coefficient you have found, find the the significance level by looking up the appropriate values in a table. 

\n

First supply the table values you need from your notes:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.2\\%$
[[0]][[1]][[2]][[3]]
\n

 

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["$p \\leq 0.002$, very strong evidence to reject the hypothesis.", "$0.002 \\lt p \\leq 0.01$, strong evidence to reject the hypothesis.", "$0.01 \\lt p \\leq 0.05$, there is evidence to reject the hypothesis.", "$0.05 \\lt p \\leq 0.1$, weak evidence against, do not reject the hypothesis but consider further investigation.", "$p \\gt 0.1$, no evidence to reject the hypothesis."], "displayColumns": 1, "prompt": "

Given the data above, what decision can you come to as to the hypothesis that the wife and husband in these married couples have the same attitude in relation to liberal and conservative values?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "vs", "marks": 0}], "statement": "

It is well known that similarity in attitudes, beliefs and interests plays an important role in interpersonal attraction. A researcher developed a questionnaire which was completed by 8 married couples. One question sought to place each individual on a 20 point scale in which low scores represent liberal attitudes and high scores represent conservative attitudes. The data were:

\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
Couple$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$
Wife $(X)$$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$
Husband $(Y)$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$
\n

In this exercise you will find Spearman's correlation coefficient for this data and comment on the significance of the correlation as regards the following null hypothesis:

\n

$H_0$: There is no association between the attitudes of wives and husbands.

", "tags": ["checked2015", "data analysis", "hypothesis testing", "PSY2010", "ranked data", "ranks", "Spearman correlation coefficient", "statistics"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

30/09/2102:

\n \t\t

Introduced three functions:

\n \t\t

1. To produce the ranking of a list of 8 numbers.

\n \t\t

2. To produce a list of 8 numbers from a scale of 1..20 which are all distinct.

\n \t\t

3. To produce the maximum of the numbers in a list.

\n \t\t

4. Given an array such as in 2. to find another such array which has max diff between any two corresponding entries less than a given number. This is to ensure that the two array produced do not differ too much, as the point of the exercise is to show that there is a positive high correlation.

\n \t\t

 

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Spearman rank correlation calculated. 8 paired observations.

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

When the question is revealed you will see all the answers.

"}, {"name": "Apply Friedman test", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variablesTest": {"condition": "", "maxRuns": 100}, "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(repeat(round(normalsample(mu[x],sig)),5),x,0..m-1)", "description": "", "name": "r1"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(fr>=16.266,[1,0,0,0,0],fr >=11.345,[0,1,0,0,0],fr>=7.815,[0,0,1,0,0],fr>=6.251,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "sig": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..7#0.2)", "description": "", "name": "sig"}, "sun": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['A','B','C','D','E']", "description": "", "name": "sun"}, "surk": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(list(srk)[x]),x,0..3)", "description": "", "name": "surk"}, "rs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "matrix(map(rep(rk(r[x])[4..8]),x,0..4))", "description": "", "name": "rs"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "5", "description": "", "name": "n"}, "mu": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[random(30..40),random(35..40),random(25..35),random(40..45),random(20..40)]", "description": "", "name": "mu"}, "fr1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "12/(n*m*(m+1))*sum(map(surk[x]^2,x,0..3))-3*n*(m+1)", "description": "", "name": "fr1"}, "disptab": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(if(scorr[x]=0,'',table(tiesplus[x],['Subject $'+sun[x]+'$','Number of Ties','Contribution','Value'])),x,0..4)", "description": "", "name": "disptab"}, "dec": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,'we very strongly reject the null hypothesis at the $0.11\\\\%$ level and conclude that the suncreams differ in their effect.',\n v[1]=1,'we strongly reject the null hypothesis at the $1\\\\%$ level and conclude that the suncreams differ in their effect.',\n v[2]=1,'we have evidence to reject the null hypothesis at the $5\\\\%$ level and conclude that the suncreams differ in their effect.',\n v[3]=1,'we only have weak evidence against the null hypothesis at the $10\\\\%$ level and we do not reject it',\n 'there is no evidence against the null hypothesis and we accept it.')", "description": "", "name": "dec"}, "vties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(round(rs[y][x]/(x+1))*(((x+1)^3-(x+1))/(n*(m^3-m))),x,1..abs(rs[y])-1),y,0..4)\n", "description": "", "name": "vties"}, "tieslist": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(round(rs[y][x]/(x+1)),x,1..m-1),y,0..4)\n", "description": "", "name": "tieslist"}, "nties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(tieslist[x]),x,0..4)", "description": "", "name": "nties"}, "mess1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(tscorr=0, '(no ties, so $T=0$).','')", "description": "", "name": "mess1"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4", "description": "", "name": "m"}, "scorr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(vties[x]),x,0..4)", "description": "", "name": "scorr"}, "fr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(fr1/(1-tscorr),2)", "description": "", "name": "fr"}, "tscorr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(scorr)", "description": "", "name": "tscorr"}, "tiesplus": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(['Ties of size $'+(x+1)+'$.','$'+round(rs[y][x]/(x+1))+'$', '$\\\\,\\\\,\\\\,\\\\,\\\\, \\\\displaystyle '+round(rs[y][x]/(x+1))+'\\\\times \\\\displaystyle \\\\frac{'+(x+1)+'^3-'+(x+1)+'}{'+n+'('+m+'^3-'+m+')}$','$'+vties[y][x-1]+'$'],x,1..abs(rs[y])-1),y,0..4)", "description": "", "name": "tiesplus"}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r1)))", "description": "", "name": "r"}, "rnk": {"templateType": "anything", "group": "Ungrouped variables", "definition": "matrix(map(rk(r[x])[0..4],x,0..4))", "description": "", "name": "rnk"}, "rt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r)))", "description": "", "name": "rt"}, "messtab": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(tscorr=0, 'that there are no ties.','that there are ties as follows:')", "description": "", "name": "messtab"}, "srk": {"templateType": "anything", "group": "Ungrouped variables", "definition": "transpose((rnk))", "description": "", "name": "srk"}}, "ungrouped_variables": ["tieslist", "vties", "rt", "scorr", "rs", "sun", "sig", "tol", "disptab", "rnk", "tiesplus", "fr", "surk", "mess1", "messtab", "nties", "tscorr", "r1", "srk", "m", "n", "mu", "fr1", "r", "v", "dec"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"rep": {"type": "list", "language": "javascript", "definition": "/*the list a contains natural numbers up to a maximum value M. \n This function outputs an array where arr[j]/(j+1)=number of ties of size j+1*/\n var b=a.sort(function(c,d){return c-d});\n var M=b[a.length-1];\n var arr=[];\n for(var j=1;j<=M;j++){\nvar s=0;\nfor(var i=0;il[i]){s+=1;}\n else\nif(l[j]==l[i]){c+=1;}\n}\n out[j]=(2*s+c+1)/2;\n rep[j]=c;\n }\n return out.concat(rep);\n\n", "parameters": [["l", "list"]]}}, "variable_groups": [], "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][0]", "minValue": "srk[0][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][1]", "minValue": "srk[0][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][2]", "minValue": "srk[0][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][3]", "minValue": "srk[0][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][4]", "minValue": "srk[0][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[0]", "minValue": "surk[0]", "showCorrectAnswer": true, "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][0]", "minValue": "srk[1][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][1]", "minValue": "srk[1][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][2]", "minValue": "srk[1][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][3]", "minValue": "srk[1][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][4]", "minValue": "srk[1][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[1]", "minValue": "surk[1]", "showCorrectAnswer": true, "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][0]", "minValue": "srk[2][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][1]", "minValue": "srk[2][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][2]", "minValue": "srk[2][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][3]", "minValue": "srk[2][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][4]", "minValue": "srk[2][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[2]", "minValue": "surk[2]", "showCorrectAnswer": true, "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][0]", "minValue": "srk[3][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][1]", "minValue": "srk[3][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][2]", "minValue": "srk[3][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][3]", "minValue": "srk[3][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][4]", "minValue": "srk[3][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[3]", "minValue": "surk[3]", "showCorrectAnswer": true, "marks": 0.5}], "type": "gapfill", "prompt": "\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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
SubjectABCDETotals
Suncream      
W$\\var{r1[0][0]}$$\\var{r1[0][1]}$$\\var{r1[0][2]}$$\\var{r1[0][3]}$$\\var{r1[0][4]}$ 
Rank[[0]][[1]][[2]][[3]][[4]]$R_1=\\;$[[5]]
X$\\var{r1[1][0]}$$\\var{r1[1][1]}$$\\var{r1[1][2]}$$\\var{r1[1][3]}$$\\var{r1[1][4]}$ 
Rank[[6]][[7]][[8]][[9]][[10]]$R_2=\\;$[[11]]
Y$\\var{r1[2][0]}$$\\var{r1[2][1]}$$\\var{r1[2][2]}$$\\var{r1[2][3]}$$\\var{r1[2][4]}$ 
Rank[[12]][[13]][[14]][[15]][[16]]$R_3=\\;$[[17]]
Z$\\var{r1[3][0]}$$\\var{r1[3][1]}$$\\var{r1[3][2]}$$\\var{r1[3][3]}$$\\var{r1[3][4]}$ 
Rank[[18]][[19]][[20]][[21]][[22]]$R_4=\\;$[[23]]
\n

Rank each column separately and enter the ranks in the table, using the method you used for the Kruskal-Wallis question. (Hence the sum of the ranks in each column should be 10). Also input the sums of the ranks $R_1,\\;R_2,\\;R_3$ and $R_4$ for each row.

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "fr1", "minValue": "fr1", "showCorrectAnswer": true, "marks": 2}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "1-tscorr", "minValue": "1-tscorr", "showCorrectAnswer": true, "marks": 2}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "fr+tol", "minValue": "fr-tol", "showCorrectAnswer": true, "marks": 1}], "type": "gapfill", "prompt": "

Next you  work out the uncorrected (for ties) Friedman statistic $\\chi_r^2$.

\n

Here:

\n

$t = \\;$ number of treatments i.e. suncreams $\\;=4$

\n

$b=\\;$ number of subjects $\\;=5$.

\n

$\\displaystyle \\chi_r^2= \\frac{12}{b\\times t \\times (t+1)}\\left[\\sum R_i^2 \\right]-\\left\\{3\\times b\\times (t+1)\\right\\}=\\;$[[0]] (Input to 2 decimal places).

\n

Now input the correction term due to the ties:

\n

$C=\\;$[[1]] (Input to 2 decimal places).

\n

Hence the corrected Friedman test statistic is:

\n

$\\chi_r^{2^*}=\\;$[[2]]  (Input to 2 decimal places).

\n

 

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

We have very strong evidence to  reject the null hypothesis at the $0.1\\%$ level and conclude that the suncreams differ in their effect.

", "

We have strong evidence to reject the null hypothesis at the $1\\%$ level and conclude that the suncreams differ in their effect.

", "

We have evidence to reject the null hypothesis at the $5\\%$ level and conclude that the suncreams differ in their effect.

", "

We only have weak evidence against the null hypothesis at the $10\\%$ level and so we retain the null hypothesis.

", "

We have no  evidence against the null hypothesis so we retain the null hypothesis that the suncreams have the same effect.

"], "matrix": "v", "prompt": "

Give the value of $\\chi_r^{2^*}$ you have found, and the $\\chi^2$ table data:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$6.251$$7.815$$11.345$$16.266$
\n

What is your decision?

\n

\n

 

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "maxMarks": 0, "type": "1_n_2", "minMarks": 0, "showCorrectAnswer": true, "displayColumns": 1, "marks": 0}], "statement": "

To test the effectiveness of sun-tan creams, five volunteers A, B, C, D, E each tried four creams W, X, Y, Z on various parts of their legs. They were then subjected to ultra-violet radiation and an estimate of the degree of burning was made (higher figures indicate greater burning). The results are given below with some totals:

\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
 WXYZ
A{r[0][0]}{r[0][1]}{r[0][2]}{r[0][3]}
B{r[1][0]}{r[1][1]}{r[1][2]}{r[1][3]}
C{r[2][0]}{r[2][1]}{r[2][2]}{r[2][3]}
D{r[3][0]}{r[3][1]}{r[3][2]}{r[3][3]}
E{r[4][0]}{r[4][1]}{r[4][2]}{r[4][3]}
\n

 

\n

Apply the Friedman test to this data in relation to the null hypothesis that there is no difference in the effectiveness of the suncreams.

", "tags": ["checked2015", "correction term", "Friedman statistic", "hypothesis testing", "PSY2010", "ranks", "statistics", "ties", "treatments"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

Friedman test, 5 subjects, 4 treatments.

"}, "advice": "

Step 1.

\n

First we present the data as in the next table, changing rows to columns, and work out the ranks of each of the columns. So all we are doing is ranking the four numbers in each column separately. We use the method of finding ranks as explained for the Kruskal-Wallis example. Then we sum over the ranks in each row.

\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\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
SubjectABCDETotals
Suncream      
W$\\var{r1[0][0]}$$\\var{r1[0][1]}$$\\var{r1[0][2]}$$\\var{r1[0][3]}$$\\var{r1[0][4]}$ 
Rank{srk[0][0]}{srk[0][1]}{srk[0][2]}{srk[0][3]}{srk[0][4]}$R_1=\\;${surk[0]}
X$\\var{r1[1][0]}$$\\var{r1[1][1]}$$\\var{r1[1][2]}$$\\var{r1[1][3]}$$\\var{r1[1][4]}$ 
Rank{srk[1][0]}{srk[1][1]}{srk[1][2]}{srk[1][3]}{srk[1][4]}$R_2=\\;${surk[1]}
Y$\\var{r1[2][0]}$$\\var{r1[2][1]}$$\\var{r1[2][2]}$$\\var{r1[2][3]}$$\\var{r1[2][4]}$ 
Rank{srk[2][0]}{srk[2][1]}{srk[2][2]}{srk[2][3]}{srk[2][4]}$R_3=\\;${surk[2]}
Z$\\var{r1[3][0]}$$\\var{r1[3][1]}$$\\var{r1[3][2]}$$\\var{r1[3][3]}$$\\var{r1[3][4]}$ 
Rank{srk[3][0]}{srk[3][1]}{srk[3][2]}{srk[3][3]}{srk[3][4]}$R_4=\\;${surk[3]}
 
Ties{nties[0]}{nties[1]}{nties[2]}{nties[3]}{nties[4]}$\\var{sum(nties)}$
\n

 

\n

 

\n

Step 2: Next we work out the uncorrected (for ties) Friedman statistic $\\chi_r^2$.

\n

Here:

\n

$t = \\;$ number of treatments i.e. suncreams $\\;=4$

\n

$b=\\;$ number of subjects $\\;=5$.

\n

\\[\\begin{eqnarray*}\\chi_r^2&=& \\frac{12}{b\\times t \\times (t+1)}\\left[\\sum R_i^2 \\right]-\\left\\{3\\times b\\times (t+1)\\right\\}\\\\&=&\\left\\{\\frac{12}{\\var{n}\\times\\var{m}\\times\\var{m+1}}\\left[\\var{surk[0]}^2+\\var{surk[1]}^2+\\var{surk[2]}^2+\\var{surk[3]}^2\\right]\\right\\}-\\left\\{3\\times\\var{n}\\times \\var{m+1}\\right\\}\\\\&=&\\var{fr}\\end{eqnarray*}\\]

\n

 Step 3: Next we calculate the Correction Factor $C$

\n

Only necessary if there are some ties, otherwise $C=1$.

\n

For each tie in a column with $g$ equal values we calculate $\\displaystyle \\frac{g^3-g}{b(t^3-t)}$.

\n

$T$ is the sum of all these values and then the Correction Factor $C= 1-T$. 

\n

So for this example we note  {messtab}

\n

{table(disptab,[])}

\n

Summing over the values {mess1} we find $T=\\var{tscorr} \\Rightarrow C=1- \\var{tscorr}=\\var{1-tscorr}$.

\n

Step 4.

\n

Next we calculate the corrected Friedman statistic allowing for ties.

\n

$ \\displaystyle \\chi_r^{2^*}=\\frac{\\chi_r^{2}}{C} = \\frac{\\var{fr1}}{\\var{1-tscorr}}=\\var{fr}$ to 2 decimal places.

\n

Step 5. Make a decision.

\n

Looking at the table in conjunction with the test statistic we have just worked out, {dec}

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$6.251$$7.815$$11.345$$16.266$
"}, {"name": "Input 1 PSY", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"b": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(100..200 except a)", "description": "", "name": "b"}, "a": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(100..200)", "description": "", "name": "a"}}, "ungrouped_variables": ["a", "b"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"type": "numberentry", "correctAnswerFraction": false, "showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "integerAnswer": true, "integerPartialCredit": 0, "minValue": "4", "maxValue": "4", "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Questions are often split into parts. 

\n

In each part you will see various input fields for your answers. 

\n

This is the first part and contains one question for you to answer .

\n

It will be clear from the question what you need to enter in each field.

\n

For example, a question could be:

\n

$2+2=\\;$[[0]] (enter a number)

\n

You are expected to enter the answer and then press the Submit part button.

\n

Try it. Enter the correct value, note that a box appears showing your input, press Submit part- a  tick appears. Brilliant!!

\n

Now  enter an incorrect value. Press Submit part and a cross appears. Note the Show Feedback button, clicking on that gives a more detailed feedback - in this case there is not much to say!

\n

This is the sort of feedback you get in practice mode.

\n

Try putting in 2+2 as your answer and see what happens as well. 

\n

You will be given an error message, click on OK and continue.

\n

So you must be careful and always check that the answer in the input field is what you expect it to be before you move on.

\n

Pressing the Reveal button at the bottom of the screen gives you the answers for all parts and usually also gives you a full solution for each part. This is only available in Practice mode and certainly not available in Exam mode.

\n

Also note that in Practice mode you have available a button at the bottom \"Try another question like this one\". This is useful for you to try other versions of the question, if it is randomised. The second part of this question below is randomised so you will usually see different numbers if you press this button.

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{a+b}", "minValue": "{a+b}", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{a*b}", "minValue": "{a*b}", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

This is the second part of this example and it contains 2 questions.

\n

You enter your answers for both and then press Submit part for both. 

\n

 

\n

$\\var{a}+\\var{b}=\\;$[[0]] 

\n

 

\n

$\\var{a} \\times \\var{b}=\\;$[[1]]

\n

 Try getting one right and one wrong and see the sort of feedback you get. (The % sign indicates that you got a percentage correct)

\n

Note the red exclamation marks next to the input field when you enter something the system does not like or you have submitted without answering the question - try this. Move the cursor over the mark and you will get a message saying what the problem is.

\n

The Submit all parts button at the bottom allows you to answer everything in the question at once without submitting each part separately.  In this case, the answers in both parts will be submitted.

", "showCorrectAnswer": true, "marks": 0}], "statement": "\n

This example explains how you enter your answers and submit them. 

\n

This example and the others are in practice mode - you will be given information on whether or not you have the answer correct or not. 

\n

Exam mode does not give you this information.

\n

It is very important that you submit all your answers. If you do not your results will not be recorded.  Note that the list of questions in the exam on the left of the window gives information on whether or not you have completed a question. For each question the marks you have gained by submitting are shown there, so if nothing is shown you have not attempted the question.

\n

Go to the next question. You can then come back. Note that until you quit the exam for good you can go back to any question and change your answers if you want to.

\n ", "tags": ["answers", "checked2015", "entering", "fields", "input", "introduction", "junk", "mathematical notation", "Numbas", "numbas", "parts", "practice mode", "reveal", "submit"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

Entering numbers in Numbas, Part 1.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": ""}, {"name": "Input 2 PSY", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "description": "", "name": "tol"}, "ans1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(a1/b1,2)", "description": "", "name": "ans1"}, "b": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..9)", "description": "", "name": "b"}, "c": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..9)", "description": "", "name": "c"}, "b1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(7,11,13)", "description": "", "name": "b1"}, "a": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..9)", "description": "", "name": "a"}, "a1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2,3,4,5,6,8,9,10,12)", "description": "", "name": "a1"}}, "ungrouped_variables": ["a", "c", "b", "ans1", "a1", "b1", "tol"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "a*b+c", "minValue": "a*b+c", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n

Find the result of this calculation: (This is an example of a randomised question - the next time you use this example you will probably see a different calculation to do):

\n

$\\var{a}\\times\\var{b}+\\var{c}=\\;$[[0]]

\n

 You have to input a whole number - it could be in decimal form - if the answer was 2 then you could input 2 or 2.0 - try both forms. 

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"answer": "{a*b+c}", "vsetrange": [0, 1], "checkingaccuracy": 0.001, "checkvariablenames": false, "expectedvariablenames": [], "notallowed": {"message": "

Do not enter your answer as a decimal. Enter as a whole number without the decimal point.

", "showStrings": false, "partialCredit": 0, "strings": ["."]}, "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "type": "jme", "showCorrectAnswer": true, "marks": 1, "vsetrangepoints": 5}], "type": "gapfill", "prompt": "\n

Sometimes I could force you to enter a whole number not in decimal form. But this should be no problem as you will be warned as below.

\n

Enter the result of this calculation, but enter as a whole number and not as a decimal.

\n

$\\var{a}\\times\\var{b}+\\var{c}=\\;$[[0]]

\n

Enter the correct answer as a decimal i.e. in the form 2.0 and see what happens:

\n

 

\n

 

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "{ans1+tol}", "minValue": "{ans1-tol}", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n

Decimals

\n

Many calculations will result in numbers which need to be entered in decimal notation.

\n

I will always ask for the decimal to be input to a certain number of decimal places. 

\n

Often there is a small tolerance built in so that if you get the result wrong by 1 in the last decimal place then it will be marked as correct. 

\n

But accuracy is important - so make sure that you get the calculations correct.

\n

For example: 

\n

Input $\\displaystyle \\frac{\\var{a1}}{\\var{b1}}$ as a decimal correct to 2 decimal places here: [[0]]

\n

Try putting in the correct value and submitting. Then vary the last decimal place by 1 either way and submitting  and then the last place by 2 either way and submitting.

\n

Try putting in the fraction as it is (i.e. $\\var{a1}/\\var{b1}$ ) and see what happens. 

\n

The system gives an error message  - as what you have put in is not a direct representation of a number. But you can always re-enter.

\n

So be careful - always check after submitting your answer that the input field contains the answer that you thought you input.

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"answer": "{a1+b1}/{a1*b1}", "musthave": {"message": "

Input as a fraction.

", "showStrings": false, "partialCredit": 0, "strings": ["/"]}, "vsetrange": [0, 1], "checkingaccuracy": 0.001, "showCorrectAnswer": true, "expectedvariablenames": [], "notallowed": {"message": "

Simplify into a single fraction. Do not enter as a decimal.

", "showStrings": false, "partialCredit": 0, "strings": ["+", "."]}, "showpreview": true, "checkingtype": "absdiff", "scripts": {}, "checkvariablenames": false, "type": "jme", "answersimplification": "all, fractionNumbers", "marks": 1, "vsetrangepoints": 5}], "type": "gapfill", "prompt": "\n

Fractions

\n

You will find that some questions may ask you to input fractions and not decimals.

\n

For example: 

\n

Find the following sum as a fraction:

\n

$\\displaystyle \\frac{1}{\\var{a1}}+\\frac{1}{\\var{b1}}=\\;$[[0]]

\n

(input as a fraction and not a decimal)

\n

You input the answer as {a1+b1}/{a1*b1}

\n

Try inputting the decimal version of this to as many places as you like (for example given by the calculator on the PC - you can copy this from the calculator and paste into the input field) and see what happens.

\n

 

\n ", "showCorrectAnswer": true, "marks": 0}, {"type": "information", "prompt": "

As this question is in practice mode, if you click on the Reveal button at the bottom of the window all the question fields are filled with the correct answers. Also, if available, there will be a full solution given under the heading Advice. Just scroll down to see this. However, there is no Advice available for this question as it is not needed.

\n

Finally as you are in practice mode, if you click on the \"Try another question like this one\" button at the bottom you will get this question again but with different numbers (usually!), and you can try it again. This is true for all practice mode questions which are randomised.

", "showCorrectAnswer": true, "scripts": {}, "marks": 0}], "statement": "\n

In this example we show how to enter numbers - either as 

\n

1. Whole numbers (integers).

\n

2. Decimals (to a number of decimal places)

\n

3. Fractions

\n ", "tags": ["checked2015", "decimals", "Fractions", "input", "introduction", "junk", "numbas", "Numbas", "numbers", "tolerance", "whole numbers"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

Details on inputting numbers into Numbas.

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

No advice available.

"}, {"name": "Apply Kruskal-Wallis test", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"s1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['$\\\\bf{Ordered\\\\;\\\\; times}$']+sort(biglist)", "description": "", "name": "s1"}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "ran": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(biglist)", "description": "", "name": "ran"}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..5#0.2)", "description": "", "name": "sig1"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n1+n2+n3", "description": "", "name": "n"}, "sr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(ran[x..x+6]),x,[0,6,12])", "description": "", "name": "sr"}, "sd1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r1),2)", "description": "", "name": "sd1"}, "corr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1-1/(n^3-n)*g", "description": "", "name": "corr"}, "m3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r3),2)", "description": "", "name": "m3"}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n2"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "rs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rep(ran[18..36])", "description": "", "name": "rs"}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(22..28#0.5)", "description": "", "name": "mu2"}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..25#0.5)", "description": "", "name": "mu1"}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "description": "", "name": "sig2"}, "ties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(['Number of ties of size $'+x+1+'$ =', round(rs[x]/(x+1))],x,1..abs(rs)-1)", "description": "", "name": "ties"}, "kw": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(h/corr,2)", "description": "", "name": "kw"}, "dec": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(w[0]=1,'we very strongly reject the null hypothesis at the $0.1\\\\%$ level and conclude that reaction times differ depending upon alcohol uptake.',\n w[1]=1,'we strongly reject the null hypothesis at the $1\\\\%$ level and conclude that reaction times differ depending on alcohol uptake.',\n w[2]=1,'we have evidence against the null hypothesis at the $5\\\\%$ level and we reject it',\n w[3]=1, 'we only have weak evidence against the null hypothesis at the $10\\\\%$ level so we do not reject it.',\n'there is no evidence against the null hypothesis and so we accept it.' )", "description": "", "name": "dec"}, "g": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(ran[x]^2-1,x,18..35))", "description": "", "name": "g"}, "rkt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ran[0..18]", "description": "", "name": "rkt"}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r2),2)", "description": "", "name": "m2"}, "w": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(kw>=13.816,[1,0,0,0,0],kw >=9.210,[0,1,0,0,0],kw>=5.991,[0,0,1,0,0],kw>=4.605,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "w"}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n1"}, "sd3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r3),2)", "description": "", "name": "sd3"}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r1),2)", "description": "", "name": "m1"}, "r3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu3,sig3)),6)", "description": "", "name": "r3"}, "tiesplus": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(['Ties of size $'+(x+1)+'$','$'+round(rs[x]/(x+1))+'$', '$\\\\,\\\\,\\\\,\\\\,\\\\, \\\\displaystyle '+round(rs[x]/(x+1))+'\\\\times \\\\displaystyle \\\\frac{'+(x+1)+'^3-'+(x+1)+'}{'+n+'^3-'+n+'}$','$'+vties[x-1]+'$'],x,1..abs(rs)-1)+[['Total',' ',' ','$T='+sum(vties)+'$']]", "description": "", "name": "tiesplus"}, "n3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n3"}, "sig3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "description": "", "name": "sig3"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),6)", "description": "", "name": "r2"}, "s3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['$\\\\bf{Rank}$']+ sort(rkt)", "description": "", "name": "s3"}, "biglist": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1+r2+r3", "description": "", "name": "biglist"}, "mu3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(24..32#0.5)", "description": "", "name": "mu3"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),6)", "description": "", "name": "r1"}, "sd2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r2),2)", "description": "", "name": "sd2"}, "s2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['$\\\\bf{Index}$']+map(x,x,1..18)", "description": "", "name": "s2"}, "h": {"templateType": "anything", "group": "Ungrouped variables", "definition": "12/(n*(n+1))*sum(map(x^2/n1,x,sr))-3*(n+1)", "description": "", "name": "h"}, "vties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(round(rs[x]/(x+1))*(((x+1)^3-(x+1))/(n^3-n)),x,1..abs(rs)-1)", "description": "", "name": "vties"}}, "ungrouped_variables": ["rkt", "sd1", "sd2", "sd3", "ran", "biglist", "vties", "mu3", "rs", "s3", "s2", "s1", "m1", "tol", "m2", "tiesplus", "m3", "sig1", "sig3", "sig2", "corr", "ties", "r1", "n3", "mu1", "g", "r2", "mu2", "h", "k", "r3", "n", "kw", "w", "sr", "n1", "n2", "dec"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}, "rep": {"type": "list", "language": "javascript", "definition": "\nvar b=a.sort(function(c,d){return c-d});\n var M=b[a.length-1];\n var arr=[];\n for(var j=1;j<=M;j++){\nvar s=0;\nfor(var i=0;il[i]){s+=1;}\n else\nif(l[j]==l[i]){c+=1;}\n}\n out[j]=(2*s+c+1)/2;\n rep[j]=c;\n }\n return out.concat(rep);\n\n", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[0]", "minValue": "ran[0]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[1]", "minValue": "ran[1]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[2]", "minValue": "ran[2]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[3]", "minValue": "ran[3]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[4]", "minValue": "ran[4]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[5]", "minValue": "ran[5]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "sr[0]", "minValue": "sr[0]", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[6]", "minValue": "ran[6]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[7]", "minValue": "ran[7]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[8]", "minValue": "ran[8]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[9]", "minValue": "ran[9]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[10]", "minValue": "ran[10]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[11]", "minValue": "ran[11]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "sr[1]", "minValue": "sr[1]", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[12]", "minValue": "ran[12]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[13]", "minValue": "ran[13]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[14]", "minValue": "ran[14]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[15]", "minValue": "ran[15]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[16]", "minValue": "ran[16]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[17]", "minValue": "ran[17]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "sr[2]", "minValue": "sr[2]", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Kruskal-Wallis Test

\n

First fill in this table with the appropriate values, all decimals to 1 decimal place. $R_1,\\;R_2,\\;R_3$  are the sums of the ranks in each row.

\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\n\n\n\n\n
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$ 
Rank[[0]][[1]][[2]][[3]][[4]][[5]]$R_1=\\;$[[6]]
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$ 
Rank[[7]][[8]][[9]][[10]][[11]][[12]]$R_2=\\;$[[13]]
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$ 
Rank[[14]][[15]][[16]][[17]][[18]][[19]]$R_3=\\;$[[20]]
\n

 

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "precround(H,3)+0.001", "minValue": "precround(H,3)-0.001", "correctAnswerFraction": false, "marks": 2, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "precround(corr,3)", "minValue": "precround(corr,3)", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "kw+0.01", "minValue": "kw-0.01", "correctAnswerFraction": false, "marks": 2, "showPrecisionHint": false}, {"displayType": "radiogroup", "choices": ["

We very strongly reject the null hypothesis at the $0.1\\%$ level and conclude that reaction times differ depending upon alcohol uptake.

", "

We strongly reject the null hypothesis at the $1\\%$ level and conclude that reaction times differ depending upon alcohol uptake.

", "

We have evidence against the null hypothesis at the $5\\%$ level and conclude that reaction times differ depending upon alcohol uptake.

", "

We only have weak evidence against the null hypothesis at the $10\\%$ level and so accept that reaction times do not depend upon alcohol uptake.

", "

We have no evidence against the null hypothesis and so accept that reaction times do not depend upon alcohol uptake.

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

Now calculate the Kruskal-Wallis  test statistic in the following steps as in your notes:

\n

$H=\\;$[[0]] (Assuming no ties).  Calculate to 3 decimal places.

\n

$C=\\;$[[1]] (Correction for ties). Calculate to 3 decimal places.

\n

Kruskal-Wallis statistic $H^*=\\;$ [[2]].   Calculate to 2 decimal places.

\n

 

\n

Give the value of $H^*$ you have found, determine the significance of your result by looking up the critical values in the $\\chi^2$ table.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$4.605$$5.991$$9.210$$13.816$
\n

Hence what can you say using the Kruskal-Wallis test about the null hypothesis that times to do the task do not depend upon the levels of alcohol?

\n

[[3]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "

The following data arose in a comparison of the effects of alcohol on the time taken to complete a task. There were three groups of subjects; Group A had no alcohol, Group B had two units over 1 hour and Group C had 4 units over 1 hour. The responses are the times (in seconds) taken to complete a word-matching task.

\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
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$
\n

\n Apply the Kruskal-Wallis test to this data on reaction times under alcohol in order to test the null hypothesis that the alcohol consumption does not affect the mean time taken to complete the task. \n \n

 

", "tags": ["checked2015", "correction for ties", "data analysis", "hypothesis testing", "Kruskal-Wallis", "one-way Anova", "one-way ANOVA", "PSY2010", "rank", "statistics", "stats", "ties"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

29/11/2012:

\n \t\t


Created question from one-way Anova question

\n \t\t

Added tags.

\n \t\t

Calculation not yet tested.

\n \t\t

Added description.

\n \t\t

Checked calculation.

\n \t\t

Kept Anova test in for comparison purposes.

\n \t\t

 

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Kruskal-Wallis test with ties.

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

In order to find the ranks we order, in increasing order,  all of the times for the tasks across all the three groups. We also work out the ranks for each time by including a row which simply numbers from $1$ to $\\var{n}$, this we call the index of the numbers and the last row then takes equal values in the list and gives the averages of their indices, so that they all get the same rank. So you simply add up their corresponding indices in that group and divide by the number of equal entries. So if a number is not repeated then its rank is its index. 

\n

For this example we have:

\n

{table([s1,s2,s3],[])}

\n

We see that there are ties as follows:

\n

{table(ties,[])}

\n

We use this information later to find the correction factor.

\n

Putting these ranks back into the original table gives, where $R_1,\\;R_2$ and $R_3$ are the sums of the ranks in each row:

\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\n\n\n\n\n
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$ 
Rank{rkt[0]}{rkt[1]}{rkt[2]}{rkt[3]}{rkt[4]}{rkt[5]}$R_1=\\;${sr[0]}
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$ 
Rank{rkt[6]}{rkt[7]}{rkt[8]}{rkt[9]}{rkt[10]}{rkt[11]}$R_2=\\;${sr[1]}
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$ 
Rank{rkt[12]}{rkt[13]}{rkt[14]}{rkt[15]}{rkt[16]}{rkt[17]}$R_3=\\;${sr[2]}
\n

We now have enough information to start the calculation of the Kruskal-Wallis statistic.

\n

We do this in three steps:

\n

1. Calculate the statistic $H$, which assumes there are no ties.

\n

2. Find the correction factor $C$ given by the ties in the data.

\n

3. This gives the statistic $H^*=H/C$ we want, and we make a decision based on the Kruskal-Wallis table.

\n

Step 1: Find $H$.

\n

\\[\\begin{eqnarray*}H &=& \\left[\\frac{12}{N \\times (N+1)} \\times \\left(\\sum \\frac{R_i^2}{n_i}\\right)\\right]-3(N+1)\\\\&=&\\left\\{\\frac{12}{\\var{n}\\times\\var{n+1}}\\times\\left(\\frac{\\var{sr[0]}^2}{6}+\\frac{\\var{sr[1]}^2}{6}+\\frac{\\var{sr[2]}^2}{6}\\right)\\right\\}-3\\times \\var{n+1}\\\\&=&\\var{h}\\\\&=&\\var{precround(H,3)}\\end{eqnarray*}\\] to 3 decimal places.

\n

Step 2: Find the Correction Factor $C$.

\n

For each tie with $g$ equal data values we calculate $\\displaystyle \\frac{g^3-g}{N^3-N}$ and add these together over all ties to get $T$.

\n

Then $C=1-T$.

\n

So for our data we have:

\n

{table(tiesplus,[' ','Number','Contribution','Value'])}

\n

Hence $C=1-T = 1-\\var{sum(vties)}=\\var{1-sum(vties)}=\\var{precround(corr,3)}$ to 3 decimal places.

\n

Step 3: Find the Kruskal-Wallis test statistic and make a decision.

\n

The statistic is given by $\\displaystyle H^*=\\frac{H}{C}=\\frac{\\var{precround(h,3)}}{\\var{precround(corr,3)}}=\\var{kw}$ to 2 decimal places.

\n

Looking at the $\\chi^2$ table our decision is that {dec}

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$4.605$$5.991$$9.210$$13.816$
\n

"}, {"name": "Apply Friedman test", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variablesTest": {"condition": "", "maxRuns": 100}, "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(repeat(round(normalsample(mu[x],sig)),5),x,0..m-1)", "description": "", "name": "r1"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(fr>=16.266,[1,0,0,0,0],fr >=11.345,[0,1,0,0,0],fr>=7.815,[0,0,1,0,0],fr>=6.251,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "sig": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..7#0.2)", "description": "", "name": "sig"}, "sun": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['A','B','C','D','E']", "description": "", "name": "sun"}, "surk": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(list(srk)[x]),x,0..3)", "description": "", "name": "surk"}, "rs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "matrix(map(rep(rk(r[x])[4..8]),x,0..4))", "description": "", "name": "rs"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "5", "description": "", "name": "n"}, "mu": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[random(30..40),random(35..40),random(25..35),random(40..45),random(20..40)]", "description": "", "name": "mu"}, "fr1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "12/(n*m*(m+1))*sum(map(surk[x]^2,x,0..3))-3*n*(m+1)", "description": "", "name": "fr1"}, "disptab": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(if(scorr[x]=0,'',table(tiesplus[x],['Subject $'+sun[x]+'$','Number of Ties','Contribution','Value'])),x,0..4)", "description": "", "name": "disptab"}, "dec": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,'we very strongly reject the null hypothesis at the $0.11\\\\%$ level and conclude that the suncreams differ in their effect.',\n v[1]=1,'we strongly reject the null hypothesis at the $1\\\\%$ level and conclude that the suncreams differ in their effect.',\n v[2]=1,'we have evidence to reject the null hypothesis at the $5\\\\%$ level and conclude that the suncreams differ in their effect.',\n v[3]=1,'we only have weak evidence against the null hypothesis at the $10\\\\%$ level and we do not reject it',\n 'there is no evidence against the null hypothesis and we accept it.')", "description": "", "name": "dec"}, "vties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(round(rs[y][x]/(x+1))*(((x+1)^3-(x+1))/(n*(m^3-m))),x,1..abs(rs[y])-1),y,0..4)\n", "description": "", "name": "vties"}, "tieslist": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(round(rs[y][x]/(x+1)),x,1..m-1),y,0..4)\n", "description": "", "name": "tieslist"}, "nties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(tieslist[x]),x,0..4)", "description": "", "name": "nties"}, "mess1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(tscorr=0, '(no ties, so $T=0$).','')", "description": "", "name": "mess1"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4", "description": "", "name": "m"}, "scorr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(vties[x]),x,0..4)", "description": "", "name": "scorr"}, "fr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(fr1/(1-tscorr),2)", "description": "", "name": "fr"}, "tscorr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(scorr)", "description": "", "name": "tscorr"}, "tiesplus": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(['Ties of size $'+(x+1)+'$.','$'+round(rs[y][x]/(x+1))+'$', '$\\\\,\\\\,\\\\,\\\\,\\\\, \\\\displaystyle '+round(rs[y][x]/(x+1))+'\\\\times \\\\displaystyle \\\\frac{'+(x+1)+'^3-'+(x+1)+'}{'+n+'('+m+'^3-'+m+')}$','$'+vties[y][x-1]+'$'],x,1..abs(rs[y])-1),y,0..4)", "description": "", "name": "tiesplus"}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r1)))", "description": "", "name": "r"}, "rnk": {"templateType": "anything", "group": "Ungrouped variables", "definition": "matrix(map(rk(r[x])[0..4],x,0..4))", "description": "", "name": "rnk"}, "rt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r)))", "description": "", "name": "rt"}, "messtab": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(tscorr=0, 'that there are no ties.','that there are ties as follows:')", "description": "", "name": "messtab"}, "srk": {"templateType": "anything", "group": "Ungrouped variables", "definition": "transpose((rnk))", "description": "", "name": "srk"}}, "ungrouped_variables": ["tieslist", "vties", "rt", "scorr", "rs", "sun", "sig", "tol", "disptab", "rnk", "tiesplus", "fr", "surk", "mess1", "messtab", "nties", "tscorr", "r1", "srk", "m", "n", "mu", "fr1", "r", "v", "dec"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"rep": {"type": "list", "language": "javascript", "definition": "/*the list a contains natural numbers up to a maximum value M. \n This function outputs an array where arr[j]/(j+1)=number of ties of size j+1*/\n var b=a.sort(function(c,d){return c-d});\n var M=b[a.length-1];\n var arr=[];\n for(var j=1;j<=M;j++){\nvar s=0;\nfor(var i=0;il[i]){s+=1;}\n else\nif(l[j]==l[i]){c+=1;}\n}\n out[j]=(2*s+c+1)/2;\n rep[j]=c;\n }\n return out.concat(rep);\n\n", "parameters": [["l", "list"]]}}, "variable_groups": [], "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][0]", "minValue": "srk[0][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][1]", "minValue": "srk[0][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][2]", "minValue": "srk[0][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][3]", "minValue": "srk[0][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[0][4]", "minValue": "srk[0][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[0]", "minValue": "surk[0]", "showCorrectAnswer": true, "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][0]", "minValue": "srk[1][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][1]", "minValue": "srk[1][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][2]", "minValue": "srk[1][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][3]", "minValue": "srk[1][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[1][4]", "minValue": "srk[1][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[1]", "minValue": "surk[1]", "showCorrectAnswer": true, "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][0]", "minValue": "srk[2][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][1]", "minValue": "srk[2][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][2]", "minValue": "srk[2][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][3]", "minValue": "srk[2][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[2][4]", "minValue": "srk[2][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[2]", "minValue": "surk[2]", "showCorrectAnswer": true, "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][0]", "minValue": "srk[3][0]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][1]", "minValue": "srk[3][1]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][2]", "minValue": "srk[3][2]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][3]", "minValue": "srk[3][3]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "srk[3][4]", "minValue": "srk[3][4]", "showCorrectAnswer": true, "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "surk[3]", "minValue": "surk[3]", "showCorrectAnswer": true, "marks": 0.5}], "type": "gapfill", "prompt": "\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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
SubjectABCDETotals
Suncream      
W$\\var{r1[0][0]}$$\\var{r1[0][1]}$$\\var{r1[0][2]}$$\\var{r1[0][3]}$$\\var{r1[0][4]}$ 
Rank[[0]][[1]][[2]][[3]][[4]]$R_1=\\;$[[5]]
X$\\var{r1[1][0]}$$\\var{r1[1][1]}$$\\var{r1[1][2]}$$\\var{r1[1][3]}$$\\var{r1[1][4]}$ 
Rank[[6]][[7]][[8]][[9]][[10]]$R_2=\\;$[[11]]
Y$\\var{r1[2][0]}$$\\var{r1[2][1]}$$\\var{r1[2][2]}$$\\var{r1[2][3]}$$\\var{r1[2][4]}$ 
Rank[[12]][[13]][[14]][[15]][[16]]$R_3=\\;$[[17]]
Z$\\var{r1[3][0]}$$\\var{r1[3][1]}$$\\var{r1[3][2]}$$\\var{r1[3][3]}$$\\var{r1[3][4]}$ 
Rank[[18]][[19]][[20]][[21]][[22]]$R_4=\\;$[[23]]
\n

Rank each column separately and enter the ranks in the table, using the method you used for the Kruskal-Wallis question. (Hence the sum of the ranks in each column should be 10). Also input the sums of the ranks $R_1,\\;R_2,\\;R_3$ and $R_4$ for each row.

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "fr1", "minValue": "fr1", "showCorrectAnswer": true, "marks": 2}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "1-tscorr", "minValue": "1-tscorr", "showCorrectAnswer": true, "marks": 2}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "fr+tol", "minValue": "fr-tol", "showCorrectAnswer": true, "marks": 1}], "type": "gapfill", "prompt": "

Next you  work out the uncorrected (for ties) Friedman statistic $\\chi_r^2$.

\n

Here:

\n

$t = \\;$ number of treatments i.e. suncreams $\\;=4$

\n

$b=\\;$ number of subjects $\\;=5$.

\n

$\\displaystyle \\chi_r^2= \\frac{12}{b\\times t \\times (t+1)}\\left[\\sum R_i^2 \\right]-\\left\\{3\\times b\\times (t+1)\\right\\}=\\;$[[0]] (Input to 2 decimal places).

\n

Now input the correction term due to the ties:

\n

$C=\\;$[[1]] (Input to 2 decimal places).

\n

Hence the corrected Friedman test statistic is:

\n

$\\chi_r^{2^*}=\\;$[[2]]  (Input to 2 decimal places).

\n

 

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

We have very strong evidence to  reject the null hypothesis at the $0.1\\%$ level and conclude that the suncreams differ in their effect.

", "

We have strong evidence to reject the null hypothesis at the $1\\%$ level and conclude that the suncreams differ in their effect.

", "

We have evidence to reject the null hypothesis at the $5\\%$ level and conclude that the suncreams differ in their effect.

", "

We only have weak evidence against the null hypothesis at the $10\\%$ level and so we retain the null hypothesis.

", "

We have no  evidence against the null hypothesis so we retain the null hypothesis that the suncreams have the same effect.

"], "matrix": "v", "prompt": "

Give the value of $\\chi_r^{2^*}$ you have found, and the $\\chi^2$ table data:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$6.251$$7.815$$11.345$$16.266$
\n

What is your decision?

\n

\n

 

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "maxMarks": 0, "type": "1_n_2", "minMarks": 0, "showCorrectAnswer": true, "displayColumns": 1, "marks": 0}], "statement": "

To test the effectiveness of sun-tan creams, five volunteers A, B, C, D, E each tried four creams W, X, Y, Z on various parts of their legs. They were then subjected to ultra-violet radiation and an estimate of the degree of burning was made (higher figures indicate greater burning). The results are given below with some totals:

\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
 WXYZ
A{r[0][0]}{r[0][1]}{r[0][2]}{r[0][3]}
B{r[1][0]}{r[1][1]}{r[1][2]}{r[1][3]}
C{r[2][0]}{r[2][1]}{r[2][2]}{r[2][3]}
D{r[3][0]}{r[3][1]}{r[3][2]}{r[3][3]}
E{r[4][0]}{r[4][1]}{r[4][2]}{r[4][3]}
\n

 

\n

Apply the Friedman test to this data in relation to the null hypothesis that there is no difference in the effectiveness of the suncreams.

", "tags": ["checked2015", "correction term", "Friedman statistic", "hypothesis testing", "PSY2010", "ranks", "statistics", "ties", "treatments"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

Friedman test, 5 subjects, 4 treatments.

"}, "advice": "

Step 1.

\n

First we present the data as in the next table, changing rows to columns, and work out the ranks of each of the columns. So all we are doing is ranking the four numbers in each column separately. We use the method of finding ranks as explained for the Kruskal-Wallis example. Then we sum over the ranks in each row.

\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\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
SubjectABCDETotals
Suncream      
W$\\var{r1[0][0]}$$\\var{r1[0][1]}$$\\var{r1[0][2]}$$\\var{r1[0][3]}$$\\var{r1[0][4]}$ 
Rank{srk[0][0]}{srk[0][1]}{srk[0][2]}{srk[0][3]}{srk[0][4]}$R_1=\\;${surk[0]}
X$\\var{r1[1][0]}$$\\var{r1[1][1]}$$\\var{r1[1][2]}$$\\var{r1[1][3]}$$\\var{r1[1][4]}$ 
Rank{srk[1][0]}{srk[1][1]}{srk[1][2]}{srk[1][3]}{srk[1][4]}$R_2=\\;${surk[1]}
Y$\\var{r1[2][0]}$$\\var{r1[2][1]}$$\\var{r1[2][2]}$$\\var{r1[2][3]}$$\\var{r1[2][4]}$ 
Rank{srk[2][0]}{srk[2][1]}{srk[2][2]}{srk[2][3]}{srk[2][4]}$R_3=\\;${surk[2]}
Z$\\var{r1[3][0]}$$\\var{r1[3][1]}$$\\var{r1[3][2]}$$\\var{r1[3][3]}$$\\var{r1[3][4]}$ 
Rank{srk[3][0]}{srk[3][1]}{srk[3][2]}{srk[3][3]}{srk[3][4]}$R_4=\\;${surk[3]}
 
Ties{nties[0]}{nties[1]}{nties[2]}{nties[3]}{nties[4]}$\\var{sum(nties)}$
\n

 

\n

 

\n

Step 2: Next we work out the uncorrected (for ties) Friedman statistic $\\chi_r^2$.

\n

Here:

\n

$t = \\;$ number of treatments i.e. suncreams $\\;=4$

\n

$b=\\;$ number of subjects $\\;=5$.

\n

\\[\\begin{eqnarray*}\\chi_r^2&=& \\frac{12}{b\\times t \\times (t+1)}\\left[\\sum R_i^2 \\right]-\\left\\{3\\times b\\times (t+1)\\right\\}\\\\&=&\\left\\{\\frac{12}{\\var{n}\\times\\var{m}\\times\\var{m+1}}\\left[\\var{surk[0]}^2+\\var{surk[1]}^2+\\var{surk[2]}^2+\\var{surk[3]}^2\\right]\\right\\}-\\left\\{3\\times\\var{n}\\times \\var{m+1}\\right\\}\\\\&=&\\var{fr}\\end{eqnarray*}\\]

\n

 Step 3: Next we calculate the Correction Factor $C$

\n

Only necessary if there are some ties, otherwise $C=1$.

\n

For each tie in a column with $g$ equal values we calculate $\\displaystyle \\frac{g^3-g}{b(t^3-t)}$.

\n

$T$ is the sum of all these values and then the Correction Factor $C= 1-T$. 

\n

So for this example we note  {messtab}

\n

{table(disptab,[])}

\n

Summing over the values {mess1} we find $T=\\var{tscorr} \\Rightarrow C=1- \\var{tscorr}=\\var{1-tscorr}$.

\n

Step 4.

\n

Next we calculate the corrected Friedman statistic allowing for ties.

\n

$ \\displaystyle \\chi_r^{2^*}=\\frac{\\chi_r^{2}}{C} = \\frac{\\var{fr1}}{\\var{1-tscorr}}=\\var{fr}$ to 2 decimal places.

\n

Step 5. Make a decision.

\n

Looking at the table in conjunction with the test statistic we have just worked out, {dec}

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$6.251$$7.815$$11.345$$16.266$
"}, {"name": "Apply Kruskal-Wallis test", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"s1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['$\\\\bf{Ordered\\\\;\\\\; times}$']+sort(biglist)", "description": "", "name": "s1"}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "ran": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rk(biglist)", "description": "", "name": "ran"}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..5#0.2)", "description": "", "name": "sig1"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n1+n2+n3", "description": "", "name": "n"}, "sr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(ran[x..x+6]),x,[0,6,12])", "description": "", "name": "sr"}, "sd1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r1),2)", "description": "", "name": "sd1"}, "corr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1-1/(n^3-n)*g", "description": "", "name": "corr"}, "m3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r3),2)", "description": "", "name": "m3"}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n2"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "rs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "rep(ran[18..36])", "description": "", "name": "rs"}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(22..28#0.5)", "description": "", "name": "mu2"}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..25#0.5)", "description": "", "name": "mu1"}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "description": "", "name": "sig2"}, "ties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(['Number of ties of size $'+x+1+'$ =', round(rs[x]/(x+1))],x,1..abs(rs)-1)", "description": "", "name": "ties"}, "kw": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(h/corr,2)", "description": "", "name": "kw"}, "dec": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(w[0]=1,'we very strongly reject the null hypothesis at the $0.1\\\\%$ level and conclude that reaction times differ depending upon alcohol uptake.',\n w[1]=1,'we strongly reject the null hypothesis at the $1\\\\%$ level and conclude that reaction times differ depending on alcohol uptake.',\n w[2]=1,'we have evidence against the null hypothesis at the $5\\\\%$ level and we reject it',\n w[3]=1, 'we only have weak evidence against the null hypothesis at the $10\\\\%$ level so we do not reject it.',\n'there is no evidence against the null hypothesis and so we accept it.' )", "description": "", "name": "dec"}, "g": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(ran[x]^2-1,x,18..35))", "description": "", "name": "g"}, "rkt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ran[0..18]", "description": "", "name": "rkt"}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r2),2)", "description": "", "name": "m2"}, "w": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(kw>=13.816,[1,0,0,0,0],kw >=9.210,[0,1,0,0,0],kw>=5.991,[0,0,1,0,0],kw>=4.605,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "w"}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n1"}, "sd3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r3),2)", "description": "", "name": "sd3"}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r1),2)", "description": "", "name": "m1"}, "r3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu3,sig3)),6)", "description": "", "name": "r3"}, "tiesplus": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(['Ties of size $'+(x+1)+'$','$'+round(rs[x]/(x+1))+'$', '$\\\\,\\\\,\\\\,\\\\,\\\\, \\\\displaystyle '+round(rs[x]/(x+1))+'\\\\times \\\\displaystyle \\\\frac{'+(x+1)+'^3-'+(x+1)+'}{'+n+'^3-'+n+'}$','$'+vties[x-1]+'$'],x,1..abs(rs)-1)+[['Total',' ',' ','$T='+sum(vties)+'$']]", "description": "", "name": "tiesplus"}, "n3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n3"}, "sig3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "description": "", "name": "sig3"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),6)", "description": "", "name": "r2"}, "s3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['$\\\\bf{Rank}$']+ sort(rkt)", "description": "", "name": "s3"}, "biglist": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1+r2+r3", "description": "", "name": "biglist"}, "mu3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(24..32#0.5)", "description": "", "name": "mu3"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),6)", "description": "", "name": "r1"}, "sd2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r2),2)", "description": "", "name": "sd2"}, "s2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['$\\\\bf{Index}$']+map(x,x,1..18)", "description": "", "name": "s2"}, "h": {"templateType": "anything", "group": "Ungrouped variables", "definition": "12/(n*(n+1))*sum(map(x^2/n1,x,sr))-3*(n+1)", "description": "", "name": "h"}, "vties": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(round(rs[x]/(x+1))*(((x+1)^3-(x+1))/(n^3-n)),x,1..abs(rs)-1)", "description": "", "name": "vties"}}, "ungrouped_variables": ["rkt", "sd1", "sd2", "sd3", "ran", "biglist", "vties", "mu3", "rs", "s3", "s2", "s1", "m1", "tol", "m2", "tiesplus", "m3", "sig1", "sig3", "sig2", "corr", "ties", "r1", "n3", "mu1", "g", "r2", "mu2", "h", "k", "r3", "n", "kw", "w", "sr", "n1", "n2", "dec"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}, "rep": {"type": "list", "language": "javascript", "definition": "\nvar b=a.sort(function(c,d){return c-d});\n var M=b[a.length-1];\n var arr=[];\n for(var j=1;j<=M;j++){\nvar s=0;\nfor(var i=0;il[i]){s+=1;}\n else\nif(l[j]==l[i]){c+=1;}\n}\n out[j]=(2*s+c+1)/2;\n rep[j]=c;\n }\n return out.concat(rep);\n\n", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[0]", "minValue": "ran[0]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[1]", "minValue": "ran[1]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[2]", "minValue": "ran[2]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[3]", "minValue": "ran[3]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[4]", "minValue": "ran[4]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[5]", "minValue": "ran[5]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "sr[0]", "minValue": "sr[0]", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[6]", "minValue": "ran[6]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[7]", "minValue": "ran[7]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[8]", "minValue": "ran[8]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[9]", "minValue": "ran[9]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[10]", "minValue": "ran[10]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[11]", "minValue": "ran[11]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "sr[1]", "minValue": "sr[1]", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[12]", "minValue": "ran[12]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[13]", "minValue": "ran[13]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[14]", "minValue": "ran[14]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[15]", "minValue": "ran[15]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[16]", "minValue": "ran[16]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ran[17]", "minValue": "ran[17]", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "sr[2]", "minValue": "sr[2]", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

Kruskal-Wallis Test

\n

First fill in this table with the appropriate values, all decimals to 1 decimal place. $R_1,\\;R_2,\\;R_3$  are the sums of the ranks in each row.

\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\n\n\n\n\n
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$ 
Rank[[0]][[1]][[2]][[3]][[4]][[5]]$R_1=\\;$[[6]]
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$ 
Rank[[7]][[8]][[9]][[10]][[11]][[12]]$R_2=\\;$[[13]]
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$ 
Rank[[14]][[15]][[16]][[17]][[18]][[19]]$R_3=\\;$[[20]]
\n

 

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "precround(H,3)+0.001", "minValue": "precround(H,3)-0.001", "correctAnswerFraction": false, "marks": 2, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "precround(corr,3)", "minValue": "precround(corr,3)", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "kw+0.01", "minValue": "kw-0.01", "correctAnswerFraction": false, "marks": 2, "showPrecisionHint": false}, {"displayType": "radiogroup", "choices": ["

We very strongly reject the null hypothesis at the $0.1\\%$ level and conclude that reaction times differ depending upon alcohol uptake.

", "

We strongly reject the null hypothesis at the $1\\%$ level and conclude that reaction times differ depending upon alcohol uptake.

", "

We have evidence against the null hypothesis at the $5\\%$ level and conclude that reaction times differ depending upon alcohol uptake.

", "

We only have weak evidence against the null hypothesis at the $10\\%$ level and so accept that reaction times do not depend upon alcohol uptake.

", "

We have no evidence against the null hypothesis and so accept that reaction times do not depend upon alcohol uptake.

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

Now calculate the Kruskal-Wallis  test statistic in the following steps as in your notes:

\n

$H=\\;$[[0]] (Assuming no ties).  Calculate to 3 decimal places.

\n

$C=\\;$[[1]] (Correction for ties). Calculate to 3 decimal places.

\n

Kruskal-Wallis statistic $H^*=\\;$ [[2]].   Calculate to 2 decimal places.

\n

 

\n

Give the value of $H^*$ you have found, determine the significance of your result by looking up the critical values in the $\\chi^2$ table.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$4.605$$5.991$$9.210$$13.816$
\n

Hence what can you say using the Kruskal-Wallis test about the null hypothesis that times to do the task do not depend upon the levels of alcohol?

\n

[[3]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "

The following data arose in a comparison of the effects of alcohol on the time taken to complete a task. There were three groups of subjects; Group A had no alcohol, Group B had two units over 1 hour and Group C had 4 units over 1 hour. The responses are the times (in seconds) taken to complete a word-matching task.

\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
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$
\n

\n Apply the Kruskal-Wallis test to this data on reaction times under alcohol in order to test the null hypothesis that the alcohol consumption does not affect the mean time taken to complete the task. \n \n

 

", "tags": ["checked2015", "correction for ties", "data analysis", "hypothesis testing", "Kruskal-Wallis", "one-way Anova", "one-way ANOVA", "PSY2010", "rank", "statistics", "stats", "ties"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

29/11/2012:

\n \t\t


Created question from one-way Anova question

\n \t\t

Added tags.

\n \t\t

Calculation not yet tested.

\n \t\t

Added description.

\n \t\t

Checked calculation.

\n \t\t

Kept Anova test in for comparison purposes.

\n \t\t

 

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Kruskal-Wallis test with ties.

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

In order to find the ranks we order, in increasing order,  all of the times for the tasks across all the three groups. We also work out the ranks for each time by including a row which simply numbers from $1$ to $\\var{n}$, this we call the index of the numbers and the last row then takes equal values in the list and gives the averages of their indices, so that they all get the same rank. So you simply add up their corresponding indices in that group and divide by the number of equal entries. So if a number is not repeated then its rank is its index. 

\n

For this example we have:

\n

{table([s1,s2,s3],[])}

\n

We see that there are ties as follows:

\n

{table(ties,[])}

\n

We use this information later to find the correction factor.

\n

Putting these ranks back into the original table gives, where $R_1,\\;R_2$ and $R_3$ are the sums of the ranks in each row:

\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\n\n\n\n\n
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$ 
Rank{rkt[0]}{rkt[1]}{rkt[2]}{rkt[3]}{rkt[4]}{rkt[5]}$R_1=\\;${sr[0]}
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$ 
Rank{rkt[6]}{rkt[7]}{rkt[8]}{rkt[9]}{rkt[10]}{rkt[11]}$R_2=\\;${sr[1]}
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$ 
Rank{rkt[12]}{rkt[13]}{rkt[14]}{rkt[15]}{rkt[16]}{rkt[17]}$R_3=\\;${sr[2]}
\n

We now have enough information to start the calculation of the Kruskal-Wallis statistic.

\n

We do this in three steps:

\n

1. Calculate the statistic $H$, which assumes there are no ties.

\n

2. Find the correction factor $C$ given by the ties in the data.

\n

3. This gives the statistic $H^*=H/C$ we want, and we make a decision based on the Kruskal-Wallis table.

\n

Step 1: Find $H$.

\n

\\[\\begin{eqnarray*}H &=& \\left[\\frac{12}{N \\times (N+1)} \\times \\left(\\sum \\frac{R_i^2}{n_i}\\right)\\right]-3(N+1)\\\\&=&\\left\\{\\frac{12}{\\var{n}\\times\\var{n+1}}\\times\\left(\\frac{\\var{sr[0]}^2}{6}+\\frac{\\var{sr[1]}^2}{6}+\\frac{\\var{sr[2]}^2}{6}\\right)\\right\\}-3\\times \\var{n+1}\\\\&=&\\var{h}\\\\&=&\\var{precround(H,3)}\\end{eqnarray*}\\] to 3 decimal places.

\n

Step 2: Find the Correction Factor $C$.

\n

For each tie with $g$ equal data values we calculate $\\displaystyle \\frac{g^3-g}{N^3-N}$ and add these together over all ties to get $T$.

\n

Then $C=1-T$.

\n

So for our data we have:

\n

{table(tiesplus,[' ','Number','Contribution','Value'])}

\n

Hence $C=1-T = 1-\\var{sum(vties)}=\\var{1-sum(vties)}=\\var{precround(corr,3)}$ to 3 decimal places.

\n

Step 3: Find the Kruskal-Wallis test statistic and make a decision.

\n

The statistic is given by $\\displaystyle H^*=\\frac{H}{C}=\\frac{\\var{precround(h,3)}}{\\var{precround(corr,3)}}=\\var{kw}$ to 2 decimal places.

\n

Looking at the $\\chi^2$ table our decision is that {dec}

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$4.605$$5.991$$9.210$$13.816$
\n

"}, {"name": "Multiple and partial correlation(old)", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"datax1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(datay)+vector(repeat(random(-4,-3,4,5,6),10)))", "description": "", "name": "datax1"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spyx1/sqrt(ssy*ssx1),2)", "description": "", "name": "r1"}, "spyx1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "syx1-t[0]*t[1]/10", "description": "", "name": "spyx1"}, "pcc": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((r2-r1*r12)/(sqrt((1-r1^2)*(1-r12^2))),3)", "description": "", "name": "pcc"}, "ssqy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datay)*vector(datay))[0]", "description": "", "name": "ssqy"}, "datax2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(datay)+vector(repeat(random(-4,-3,-2,-1,3,4,5),10)))", "description": "", "name": "datax2"}, "ssx2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ssqx2-t[2]^2/10", "description": "", "name": "ssx2"}, "sx1x2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datax1)*vector(datax2))[0]", "description": "", "name": "sx1x2"}, "ssy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ssqy-t[0]^2/10", "description": "", "name": "ssy"}, "spyx2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "syx2-t[0]*t[2]/10", "description": "", "name": "spyx2"}, "syx1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datax1)*vector(datay))[0]", "description": "", "name": "syx1"}, "r12": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spx1x2/sqrt(ssx2*ssx1),2)", "description": "", "name": "r12"}, "spx1x2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sx1x2-t[1]*t[2]/10", "description": "", "name": "spx1x2"}, "ssqx1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datax1)*vector(datax1))[0]", "description": "", "name": "ssqx1"}, "datay": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(5..20),10)", "description": "", "name": "datay"}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1*r12", "description": "", "name": "r"}, "ssx1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ssqx1-t[1]^2/10", "description": "", "name": "ssx1"}, "rsq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((r1^2+r2^2-(2*r1*r2*r12))/(1-r12^2),2)", "description": "", "name": "rsq"}, "syx2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datax2)*vector(datay))[0]", "description": "", "name": "syx2"}, "s": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ceil(20*r1*r2/(r1^2+r2^2))", "description": "", "name": "s"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spyx2/sqrt(ssy*ssx2),2)", "description": "", "name": "r2"}, "ssqx2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "(matrix(datax2)*vector(datax2))[0]", "description": "", "name": "ssqx2"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(datay),sum(datax1),sum(datax2)]", "description": "", "name": "t"}, "remv": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(100*pcc^2,2)", "description": "", "name": "remv"}}, "ungrouped_variables": ["spx1x2", "ssqx2", "ssqx1", "r12", "sx1x2", "pcc", "syx1", "syx2", "ssy", "spyx2", "spyx1", "ssqy", "datax2", "rsq", "ssx2", "r1", "r2", "ssx1", "datax1", "remv", "s", "r", "datay", "t"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "round(100*r1^2)", "minValue": "round(100*r1^2)", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "round(100*r2^2)", "minValue": "round(100*r2^2)", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "round(100*Rsq)", "minValue": "round(100*Rsq)", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

What proportion of the variability in $Y$ is explained by:

\n

(i) $X_1$ alone? $R^2=\\;$[[0]]%

\n

(ii) $X_2$ alone? $R^2=\\;$[[1]]%

\n

(iii) $X_1$ and $X_2$ together? $R^2=\\;$[[2]]%

\n

All percentages to the nearest whole number.

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "pcc+0.001", "minValue": "pcc-0.001", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "remv+0.01", "minValue": "remv-0.01", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

What is the partial correlation coefficient between $Y$ and $X_2$ after fitting $X_1$?

\n

Partial correlation coefficient = [[0]].

\n

Input your answer to 3 decimal places.

\n

How much of the remaining variability in $Y$ is explained by $X_2$ after fitting $X_1$?

\n

Input your answer here as a percentage to 2 decimal places: [[1]]%

", "showCorrectAnswer": true, "marks": 0}], "statement": "

In a multiple regression example, it is found that:

\n

1. The correlation coefficient of $Y$ with $X_1$ is $\\var{r1}$.

\n

2. The correlation coefficient of $Y$ with $X_2$ is $\\var{r2}$.

\n

3. The correlation coefficent of $X_1$ with $X_2$ is $\\var{r12}$.

\n

Answer the following questions:

", "tags": ["checked2015", "correlation coefficients", "fitting a regression", "multiple correlation", "multiple regression", "partial correlation coefficient", "proportion of variability", "unused", "variability"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

The correlation coefficients are generated by $Y$ a random sample of 10 numbers between 5 and 20, $X_1$ obtained from $Y$ by adding on some noise and similarly for $X_2$. The correlation coefficients are then worked out from these samples.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Multiple correlation question. Given the correlation coefficent of $Y$ with $X_1$ is $r_{01}$, the correlation coefficent of $Y$ with $X_2$ is $r_{02}$ and the correlation coefficent of $X_1$ with $X_2$ is $r_{12}$ then explain the proportion of variablity of $Y$. Also find the partial corr coeff between $Y$ and $X_2$ after fitting $X_1$ and find how much of the remaining variability in $Y$ is explained by $X_2$ after fitting $X_1$.

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": ""}, {"name": "Perform a one-way ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stovern-G^2/N,2)", "description": "", "name": "btss"}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "description": "", "name": "tol"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),6)", "description": "", "name": "r1"}, "dfbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "k-1", "description": "", "name": "dfbt"}, "pmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "description": "", "name": "pmsg"}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..5#0.2)", "description": "", "name": "sig1"}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2)),sum(map(x^2,x,r3))]", "description": "", "name": "ssq"}, "pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ftest(VR,2,15),3)", "description": "", "name": "pvalue"}, "mrs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(RSS/dfrs,2)", "description": "", "name": "mrs"}, "sd1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r1),2)", "description": "", "name": "sd1"}, "tss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ss-G^2/N,2)", "description": "", "name": "tss"}, "m3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r3),2)", "description": "", "name": "m3"}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "description": "", "name": "k"}, "cmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "description": "", "name": "cmsg"}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..25#0.5)", "description": "", "name": "mu1"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n1+n2+n3", "description": "", "name": "n"}, "stovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(tsqovern)", "description": "", "name": "stovern"}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "description": "", "name": "sig2"}, "v1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pvalue<=0.001,[1,0,0,0,0],pvalue<=0.01,[0,1,0,0,0],pvalue<=0.05,[0,0,1,0,0],pvalue<=0.1,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v1"}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(22..28#0.5)", "description": "", "name": "mu2"}, "n3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n3"}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n2"}, "vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(MBT/MRS,2)", "description": "", "name": "vr"}, "dfrs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "N-k", "description": "", "name": "dfrs"}, "rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ss-stovern,2)", "description": "", "name": "rss"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2),sum(r3)]", "description": "", "name": "t"}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "description": "", "name": "n1"}, "sd3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r3),2)", "description": "", "name": "sd3"}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r1),2)", "description": "", "name": "m1"}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(ssq)", "description": "", "name": "ss"}, "r3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu3,sig3)),6)", "description": "", "name": "r3"}, "sig3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "description": "", "name": "sig3"}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vr>=11.34,[1,0,0,0,0],vr>=6.36,[0,1,0,0,0],vr>=3.68,[0,0,1,0,0],vr>=2.7,[0,0,0,1,0],[0,0,0,0,1])", "description": "", "name": "v"}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r2),2)", "description": "", "name": "m2"}, "stderror": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(mrs)/sqrt(n1),2)", "description": "", "name": "stderror"}, "mbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(BTSS/dfbt,2)", "description": "", "name": "mbt"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),6)", "description": "", "name": "r2"}, "mu3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(24..32#0.5)", "description": "", "name": "mu3"}, "g": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(t)", "description": "", "name": "g"}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n1,t[1]^2/n2,t[2]^2/n3]", "description": "", "name": "tsqovern"}, "u": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "description": "", "name": "u"}, "sd2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r2),2)", "description": "", "name": "sd2"}}, "ungrouped_variables": ["sd1", "sd2", "sd3", "mrs", "r2", "vr", "mbt", "pmsg", "stderror", "dfrs", "m1", "m3", "m2", "btss", "u", "tss", "dfbt", "tol", "ssq", "sig1", "v1", "sig3", "sig2", "cmsg", "rss", "tsqovern", "mu1", "g", "mu3", "mu2", "ss", "k", "r3", "n", "r1", "stovern", "t", "v", "n1", "n2", "n3", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "m1", "maxValue": "m1", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "sd1", "maxValue": "sd1", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "t[0]", "maxValue": "t[0]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "ssq[0]", "maxValue": "ssq[0]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "m2", "maxValue": "m2", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "sd2", "maxValue": "sd2", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "t[1]", "maxValue": "t[1]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "ssq[1]", "maxValue": "ssq[1]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "m3", "maxValue": "m3", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "sd3", "maxValue": "sd3", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "t[2]", "maxValue": "t[2]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "ssq[2]", "maxValue": "ssq[2]", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "g", "maxValue": "g", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "ss", "maxValue": "ss", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}], "type": "gapfill", "prompt": "\n

First fill in this table with the appropriate values, all decimals to 2 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 \n
 $\\overline{x}_i$$s_i$$T_i$$\\sum x^2$$n_i$
Group A[[0]][[1]][[2]][[3]]6
Group B[[4]][[5]][[6]][[7]]6
Group C[[8]][[9]][[10]][[11]]6
   $G=\\;$[[12]]Sum of Squares=[[13]]$N=18$
\n

Note that in doing this you will have supplied the sample means and sample standard deviations for the three groups.

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "tss", "minValue": "tss", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "btss", "minValue": "btss", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "rss", "minValue": "rss", "correctAnswerFraction": false, "marks": 0.5, "showPrecisionHint": false}], "type": "gapfill", "prompt": "\n

Now find the following, all to 2 decimal places:

\n

$\\displaystyle TSS\\;=\\;$[[0]], $\\displaystyle BTSS\\;=\\;$[[1]], $\\displaystyle RSS\\;=\\;$[[2]]

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "dfbt", "maxValue": "dfbt", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "btss", "maxValue": "btss", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "mbt", "maxValue": "mbt", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "vr", "maxValue": "vr", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": true, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "dfrs", "maxValue": "dfrs", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "rss", "maxValue": "rss", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "mrs", "maxValue": "mrs", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "n-1", "maxValue": "n-1", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "tss", "maxValue": "tss", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 0.5}, {"precisionPartialCredit": 0, "allowFractions": false, "correctAnswerFraction": false, "minValue": "stderror-tol", "maxValue": "stderror+tol", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "showCorrectAnswer": true, "marks": 1}], "type": "gapfill", "prompt": "

Now complete the ANOVA table using the values to 2 decimal places obtained above:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
SourcedfSSMSVR
Between Treatments[[0]][[1]][[2]][[3]]
Residual[[4]][[5]][[6]]-
Total[[7]][[8]]--
\n

Also calculate the estimated standard error of the mean : [[9]]

\n

Note that VR is found by taking the ratio of two of the values in this table.

\n

Input all numbers to 2 decimal places.

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

$p$ less than $0.1\\%$

", "

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

", "

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

", "

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

", "

$p$ is greater than $10\\%$

"], "displayColumns": 1, "prompt": "\n

Give the value of $VR$ you have found, choose the range for the $p$ value by looking up the critical values of $F_{2,15}$ (one-sided).

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$2.70$$3.68$$6.36$$11.34$
\n ", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["

Very Strong Evidence

", "

Strong Evidence

", "

Evidence

", "

Weak Evidence

", "

No Evidence

"], "displayColumns": 0, "prompt": "

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that the mean times taken are the same for the three groups?

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

We reject the null hypothesis at the $0.1\\%$ level

", "

We reject the null hypothesis at the $1\\%$ level.

", "

We reject the null hypothesis at the $5\\%$ level.

", "

We do not reject the null hypothesis but consider further investigation.

", "

We do not reject the null hypothesis.

"], "displayColumns": 1, "prompt": "

Hence what is your decision based on the above ANOVA analysis?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}], "statement": "\n

The following data arose in a comparison of the effects of alcohol on the time taken to complete a task. There were three groups of subjects; Group A had no alcohol, Group B had two units over 1 hour and Group C had 4 units over 1 hour. The responses are the times (in seconds) taken to complete a word-matching task.

\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
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$
\n
    \n
  • Write down the sample mean and standard deviation for each group together with an estimate of the standard error of a mean, $\\displaystyle\\frac{s}{\\sqrt{n}}$, to 2 decimal places.
  • \n
  • Test the null hypothesis that the alcohol consumption does not affect the mean time taken to complete the task.
  • \n
\n

 

\n ", "tags": ["ANOVA", "average", "checked2015", "data analysis", "degrees of freedom", "F-test", "hypothesis testing", "mean", "mean ", "one-way Anova", "one-way ANOVA", "PSY2010", "standard deviation", "statistics", "stats", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

11/07/2012:

\n \t\t


Added tags.

\n \t\t

Calculation not yet tested.

\n \t\t

23/07/2012:

\n \t\t

Added description.

\n \t\t

Checked calculation.

\n \t\t

3/08/2012:

\n \t\t

Added tags.

\n \t\t

Question appears to be working correctly.

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

One-way ANOVA example

"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": ""}, {"name": "Find and use linear regression equation for a small sample", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"group": "Ungrouped variables", "templateType": "anything", "definition": "0.001", "name": "tol", "description": ""}, "r1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "repeat(round(normalsample(67,8)),10)", "name": "r1", "description": ""}, "spxy": {"group": "Ungrouped variables", "templateType": "anything", "definition": "sxy-t[0]*t[1]/n", "name": "spxy", "description": ""}, "a": {"group": "Ungrouped variables", "templateType": "anything", "definition": "precround(1/n*(t[1]-spxy/ss[0]*t[0]),3)", "name": "a", "description": ""}, "ssq": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "name": "ssq", "description": ""}, "sc": {"group": "Ungrouped variables", "templateType": "anything", "definition": "r1[ch]", "name": "sc", "description": ""}, "ch": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(0..9)", "name": "ch", "description": ""}, "b1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(0.25..0.45#0.05)", "name": "b1", "description": ""}, "t": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[sum(r1),sum(r2)]", "name": "t", "description": ""}, "a1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(10..20)", "name": "a1", "description": ""}, "sxy": {"group": "Ungrouped variables", "templateType": "anything", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "name": "sxy", "description": ""}, "ss": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "name": "ss", "description": ""}, "n": {"group": "Ungrouped variables", "templateType": "anything", "definition": "10", "name": "n", "description": ""}, "obj": {"group": "Ungrouped variables", "templateType": "anything", "definition": "['A','B','C','D','E','F','G','H','I','J']", "name": "obj", "description": ""}, "r2": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(round(a1+b1*x+random(-9..9)),x,r1)", "name": "r2", "description": ""}, "b": {"group": "Ungrouped variables", "templateType": "anything", "definition": "precround(spxy/ss[0],3)", "name": "b", "description": ""}, "ls": {"group": "Ungrouped variables", "templateType": "anything", "definition": "precround(a+b*sc,2)", "name": "ls", "description": ""}, "res": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(precround(r2[x]-(a+b*r1[x]),2),x,0..n-1)", "name": "res", "description": ""}, "tsqovern": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[t[0]^2/n,t[1]^2/n]", "name": "tsqovern", "description": ""}}, "ungrouped_variables": ["tsqovern", "a", "b", "obj", "r1", "r2", "ss", "res", "ssq", "n", "a1", "ch", "spxy", "ls", "tol", "t", "sc", "sxy", "b1"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "showQuestionGroupNames": false, "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "parts": [{"marks": 0, "scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "showCorrectAnswer": true, "minValue": "b-tol", "maxValue": "b+tol", "precision": "3", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerFraction": false, "marks": 1}, {"precisionPartialCredit": 0, "allowFractions": false, "showCorrectAnswer": true, "minValue": "a-tol", "maxValue": "a+tol", "precision": "3", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerFraction": false, "marks": 1}], "type": "gapfill", "showCorrectAnswer": true, "steps": [{"type": "information", "showCorrectAnswer": true, "prompt": "

To find $a$ and $b$ you first find  $\\displaystyle b = \\frac{SPXY}{SSX}$ where:

\n

$\\displaystyle SPXY=\\sum xy - \\frac{(\\sum x)\\times (\\sum y)}{10}$

\n

$\\displaystyle SSX=\\sum x^2 - \\frac{(\\sum x)^2}{10}$

\n

Then $\\displaystyle a = \\frac{1}{10}\\left[\\sum y-b \\sum x\\right]$

\n

Now go back and fill in the values for $a$ and $b$.

", "scripts": {}, "marks": 0}], "prompt": "

Calculate the equation of the best fitting regression line:

\n

\\[Y = a + b \\times X.\\] Find $a$ and $b$ to 5 decimal places, then input them below to 3 decimal places. You will use these approximate values in the rest of the question. 

\n

$b=\\;$[[0]],      $a=\\;$[[1]] (enter both to 3 decimal places).

\n

You are given the following information:

\n \n \n \n \n \n \n \n \n \n \n \n
First Test$(X)$$\\sum x=\\;\\var{t[0]}$$\\sum x^2=\\;\\var{ssq[0]}$
Later Score$(Y)$$\\sum y=\\;\\var{t[1]}$$\\sum y^2=\\;\\var{ssq[1]}$
\n

Also you are given $\\sum xy = \\var{sxy}$.

\n

Click on Show steps if you want more information on calculating $a$ and $b$. You will not lose any marks by doing so.

\n

 

", "stepsPenalty": 0}, {"precisionPartialCredit": 0, "allowFractions": false, "showCorrectAnswer": true, "minValue": "ls-0.01", "prompt": "

What is the predicted Later score for employee $\\var{obj[ch]}$?

\n

Use the values of $a$ and $b$ you input above.

\n

Enter the predicted Later score here: (to 2 decimal places)

", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerFraction": false, "marks": 1, "maxValue": "ls+0.01"}, {"marks": 0, "scripts": {}, "gaps": [{"precisionPartialCredit": 0, "allowFractions": false, "showCorrectAnswer": true, "minValue": "res[ch]-0.01", "maxValue": "res[ch]+0.01", "precision": "2", "type": "numberentry", "precisionType": "dp", "showPrecisionHint": false, "strictPrecision": false, "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "correctAnswerFraction": false, "marks": 1}], "type": "gapfill", "showCorrectAnswer": true, "steps": [{"type": "information", "showCorrectAnswer": true, "prompt": "

The residual value is given by:

\n

RESIDUAL = OBSERVED - FITTED.

\n

In this case the observed value for $\\var{obj[ch]}$ is $\\var{r2[ch]}$ and you get the fitted value by feeding the First test value  $\\var{r1[ch]}$ into the regression equation.

\n

 

", "scripts": {}, "marks": 0}], "prompt": "

Use the result above to calculate the residual value for employee $\\var{obj[ch]}$.

\n

Click on Show steps to see what is meant by the residual value if you have forgotten. You will not lose any marks by doing so.

\n

Residual value =  (to 2 decimal places).[[0]]

", "stepsPenalty": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "

To monitor its staff appraisal methods, a personnel department compares the results of the tests carried out on employees at their first appraisal with an assessment score of the same individuals two years later. The resulting data are as follows:

\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
Employee$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$$\\var{obj[8]}$$\\var{obj[9]}$
First Test $(X)$$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Later Score $(Y)$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
\n ", "tags": ["checked2015", "data analysis", "fitted value", "PSY2010", "regression", "residual value", "statistics"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t

30/09/2102:

\n \t\t

Introduced three functions:

\n \t\t

1. To produce the ranking of a list of 8 numbers.

\n \t\t

2. To produce a list of 8 numbers from a scale of 1..20 which are all distinct.

\n \t\t

3. To produce the maximum of the numbers in a list.

\n \t\t

4. Given an array such as in 2. to find another such array which has max diff between any two corresponding entries less than a given number. This is to ensure that the two array produced do not differ too much, as the point of the exercise is to show that there is a positive high correlation.

\n \t\t

 

\n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Find a regression equation.

"}, "advice": ""}, {"name": "Linear regression - find line of best fit given summary statistics, ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"group": "Ungrouped variables", "templateType": "anything", "definition": "0.001", "name": "tol", "description": ""}, "r1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "repeat(round(normalsample(67,8)),n)", "name": "r1", "description": ""}, "spxy": {"group": "Ungrouped variables", "templateType": "anything", "definition": "sxy-t[0]*t[1]/n", "name": "spxy", "description": ""}, "a": {"group": "Ungrouped variables", "templateType": "anything", "definition": "precround(1/n*(t[1]-spxy/ss[0]*t[0]),3)", "name": "a", "description": ""}, "ssq": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "name": "ssq", "description": ""}, "sc": {"group": "Ungrouped variables", "templateType": "anything", "definition": "r1[ch]", "name": "sc", "description": ""}, "ch": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(0..7)", "name": "ch", "description": ""}, "b1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(0.25..0.45#0.05)", "name": "b1", "description": ""}, "t": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[sum(r1),sum(r2)]", "name": "t", "description": ""}, "a1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(10..20)", "name": "a1", "description": ""}, "sxy": {"group": "Ungrouped variables", "templateType": "anything", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "name": "sxy", "description": ""}, "ss": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "name": "ss", "description": ""}, "n": {"group": "Ungrouped variables", "templateType": "anything", "definition": "8", "name": "n", "description": ""}, "obj": {"group": "Ungrouped variables", "templateType": "anything", "definition": "['A','B','C','D','E','F','G','H']", "name": "obj", "description": ""}, "r2": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(round(a1+b1*x+random(-9..9)),x,r1)", "name": "r2", "description": ""}, "b": {"group": "Ungrouped variables", "templateType": "anything", "definition": "precround(spxy/ss[0],3)", "name": "b", "description": ""}, "ls": {"group": "Ungrouped variables", "templateType": "anything", "definition": "precround(a+b*sc,2)", "name": "ls", "description": ""}, "res": {"group": "Ungrouped variables", "templateType": "anything", "definition": "map(precround(r2[x]-(a+b*r1[x]),2),x,0..n-1)", "name": "res", "description": ""}, "tsqovern": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[t[0]^2/n,t[1]^2/n]", "name": "tsqovern", "description": ""}}, "ungrouped_variables": ["tsqovern", "a", "b", "obj", "r1", "r2", "ss", "res", "ssq", "ls", "n", "a1", "ch", "spxy", "t", "tol", "sc", "sxy", "b1"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "showQuestionGroupNames": false, "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "parts": [{"marks": 0, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "showCorrectAnswer": true, "minValue": "b-tol", "maxValue": "b+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "showCorrectAnswer": true, "minValue": "a-tol", "maxValue": "a+tol", "marks": 1}], "type": "gapfill", "showCorrectAnswer": true, "steps": [{"type": "information", "showCorrectAnswer": true, "prompt": "

To find $\\beta_0$ and $\\beta_1$ you first find  $\\displaystyle \\beta_1 = \\frac{SPXY}{SSX}$ where:

\n

$\\displaystyle SPXY=\\sum xy - \\frac{(\\sum x)\\times (\\sum y)}{\\var{n}}$

\n

$\\displaystyle SSX=\\sum x^2 - \\frac{(\\sum x)^2}{\\var{n}}$

\n

Then $\\displaystyle \\beta_0= \\frac{1}{\\var{n}}\\left[\\sum y-\\beta_1 \\sum x\\right]$

\n

Now go back and fill in the values for $\\beta_0$ and $\\beta_1$.

\n

 

", "scripts": {}, "marks": 0}], "prompt": "

Calculate the equation of the best fitting regression line:

\n

\\[Y = \\beta_0 + \\beta_1  X.\\] Find $\\beta_0$ and $\\beta_1$ to 5 decimal places, then input them below to 3 decimal places. You will use these approximate values in the rest of the question. 

\n

$\\beta_1=\\;$[[0]],      $\\beta_0=\\;$[[1]] (both to 3 decimal places.)

\n

You are given the following information:

\n\n\n\n\n\n\n\n\n\n\n\n
First Test$(X)$$\\sum x=\\;\\var{t[0]}$$\\sum x^2=\\;\\var{ssq[0]}$
Later Score$(Y)$$\\sum y=\\;\\var{t[1]}$$\\sum y^2=\\;\\var{ssq[1]}$
\n

Also you are given $\\sum xy = \\var{sxy}$.

\n

Click on Show steps if you want more information on calculating $\\beta_0$ and $\\beta_1$. You will not lose any marks by doing so.

\n

 

", "stepsPenalty": 0}, {"showCorrectAnswer": true, "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "prompt": "

What is the predicted Later score for employee $\\var{obj[ch]}$ in the First test?

\n

Use the values of $\\beta_0$ and $\\beta_1$ you input above.

\n

Enter the predicted Later score here: (to 2 decimal places)

", "minValue": "ls-0.01", "correctAnswerFraction": false, "marks": 1, "maxValue": "ls+0.01"}, {"marks": 0, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "showCorrectAnswer": true, "minValue": "res[ch]-0.01", "maxValue": "res[ch]+0.01", "marks": 1}], "type": "gapfill", "showCorrectAnswer": true, "steps": [{"type": "information", "showCorrectAnswer": true, "prompt": "\n

The residual value is given by:

\n

RESIDUAL = OBSERVED - FITTED.

\n

In this case the observed value for $\\var{obj[ch]}$ is $\\var{r2[ch]}$ and you get the fitted value by feeding the First test value  $\\var{r1[ch]}$ into the regression equation.

\n

 

\n", "scripts": {}, "marks": 0}], "prompt": "

Use the result above to calculate the residual value for employee $\\var{obj[ch]}$.

\n

Click on Show steps to see what is meant by the residual value if you have forgotten. You will not lose any marks by doing so.

\n

Residual value =  (to 2 decimal places).[[0]]

", "stepsPenalty": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "\n

To monitor its staff appraisal methods, a personnel department compares the results of the tests carried out on employees at their first appraisal with an assessment score of the same individuals two years later. The resulting data are as follows:

\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
Employee$\\var{obj[0]}$$\\var{obj[1]}$$\\var{obj[2]}$$\\var{obj[3]}$$\\var{obj[4]}$$\\var{obj[5]}$$\\var{obj[6]}$$\\var{obj[7]}$
First Test $(X)$$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$
Later Score $(Y)$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$
\n\n", "tags": ["ACE2013", "checked2015", "cr1", "data analysis", "fitted value", "PSY2010", "regression", "residual value", "sc", "statistics"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

21/12/2012:

\n

Checked rounding, OK. Added tag cr1.

\n

Possible use of scenarios, so added tag sc.

\n

The array r2 generates the regression data which has an inbuilt noise via r1[x]+random(-9..9).

\n

 

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Find a regression equation.

"}, "advice": ""}, {"name": "Perform a two-factor ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((stovern*N-G^2)/N,2)", "name": "btss", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),10)", "name": "r1", "description": ""}, "m4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r4),2)", "name": "m4", "description": ""}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2)),sum(map(x^2,x,r3)),sum(map(x^2,x,r4))]", "name": "ssq", "description": ""}, "f1stovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(f1tsqovern)", "name": "f1stovern", "description": ""}, "f2l1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1+r3", "name": "f2l1", "description": ""}, "f1btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((f1stovern*40-g^2)/40,2)", "name": "f1btss", "description": ""}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..3#0.2)", "name": "sig2", "description": ""}, "w1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vvr[1]>=12.88,[1,0,0,0,0],vvr[1]>=7.41,[0,1,0,0,0],vvr[1]>=4.12,[0,0,1,0,0],vvr[1]>=2.86,[0,0,0,1,0],[0,0,0,0,1])", "name": "w1", "description": ""}, "w0": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vvr[0]>=12.88,[1,0,0,0,0],vvr[0]>=7.41,[0,1,0,0,0],vvr[0]>=4.12,[0,0,1,0,0],vvr[0]>=2.86,[0,0,0,1,0],[0,0,0,0,1])", "name": "w0", "description": ""}, "m3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r3),2)", "name": "m3", "description": ""}, "rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ss-stovern,2)", "name": "rss", "description": ""}, "f1ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(f1ssq)", "name": "f1ss", "description": ""}, "r4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu4,sig1)),10)", "name": "r4", "description": ""}, "f2ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(f2ssq)", "name": "f2ss", "description": ""}, "f1t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(f1L1),sum(f1L2)]", "name": "f1t", "description": ""}, "w2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vvr[2]>=12.88,[1,0,0,0,0],vvr[2]>=7.41,[0,1,0,0,0],vvr[2]>=4.12,[0,0,1,0,0],vvr[2]>=2.86,[0,0,0,1,0],[0,0,0,0,1])", "name": "w2", "description": ""}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r2),2)", "name": "m2", "description": ""}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),10)", "name": "r2", "description": ""}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(ssq)", "name": "ss", "description": ""}, "g": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(t)", "name": "g", "description": ""}, "f2btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((f2stovern*40-g^2)/40,2)", "name": "f2btss", "description": ""}, "f1ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,f1L1)),sum(map(x^2,x,f1L2))]", "name": "f1ssq", "description": ""}, "w": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[w0,w1,w2]", "name": "w", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "name": "tol", "description": ""}, "tss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((ss*N-G^2)/N,2)", "name": "tss", "description": ""}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..3#0.2)", "name": "sig1", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n1+n2+n3+n4", "name": "n", "description": ""}, "mrs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(RSS/36,2)", "name": "mrs", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2),sum(r3),sum(r4)]", "name": "t", "description": ""}, "ivr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(interactionss/mrs,2)", "name": "ivr", "description": ""}, "interactionss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "btss-f1btss-f2btss", "name": "interactionss", "description": ""}, "vvr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[f1vr,f2vr,ivr]", "name": "vvr", "description": ""}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n2", "description": ""}, "f1l1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1+r2", "name": "f1l1", "description": ""}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..25#0.5)", "name": "mu1", "description": ""}, "stovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(tsqovern)", "name": "stovern", "description": ""}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu1-random(3..5#0.2)", "name": "mu2", "description": ""}, "mu4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu3-random(1..2#0.1)", "name": "mu4", "description": ""}, "f2stovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum([f2t[0]^2/20,f2t[1]^2/20])", "name": "f2stovern", "description": ""}, "f1l2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r3+r4", "name": "f1l2", "description": ""}, "f1tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[f1t[0]^2/20,f1t[1]^2/20]", "name": "f1tsqovern", "description": ""}, "f1rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(f1ss-f1stovern,2)", "name": "f1rss", "description": ""}, "f2ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,f2L1)),sum(map(x^2,x,f2L2))]", "name": "f2ssq", "description": ""}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n1,t[1]^2/n2,t[2]^2/n3,t[3]^2/n4]", "name": "tsqovern", "description": ""}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n1", "description": ""}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r1),2)", "name": "m1", "description": ""}, "f2vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(f2btss/mrs,2)", "name": "f2vr", "description": ""}, "r3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu3,sig1)),10)", "name": "r3", "description": ""}, "n3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n3", "description": ""}, "f2t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(f2L1),sum(f2L2)]", "name": "f2t", "description": ""}, "n4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n4", "description": ""}, "f2l2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r2+r4", "name": "f2l2", "description": ""}, "mu3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(22..26#0.5)", "name": "mu3", "description": ""}, "f1vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(f1btss/mrs,2)", "name": "f1vr", "description": ""}}, "ungrouped_variables": ["ivr", "f1vr", "f2vr", "w2", "w1", "w0", "f1l2", "f1l1", "n", "mu3", "f1ssq", "f1btss", "m4", "m1", "m3", "m2", "btss", "f2btss", "rss", "tss", "f1t", "r4", "tol", "f2ssq", "ssq", "vvr", "sig1", "sig2", "f1ss", "w", "n2", "interactionss", "tsqovern", "mu4", "mu1", "g", "r2", "mu2", "ss", "f1tsqovern", "r3", "f2ss", "mrs", "f1rss", "f2l1", "f2l2", "r1", "stovern", "t", "f1stovern", "f2t", "n1", "f2stovern", "n3", "n4"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"dec": {"type": "string", "language": "jme", "definition": "switch(vr>=12.88, 'Very strongly reject the null hypothesis ($p\\\\le 0.001$)',vr>=7.41,'Strongly reject the null hypothesis ($0.001 \\\\lt p \\\\le 0.01$)',vr>=4.12, 'Reject the null hypothesis ($0.01 \\\\lt p \\\\le 0.05$)',vr>=2.86,'Accept the null hypothesis ($0.05 \\\\lt p \\\\le 0.1$)','Accept the null hypothesis($p\\\\gt 0.1$)') ", "parameters": [["vr", "number"]]}, "pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "1", "maxValue": "1", "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f1btss-tol", "maxValue": "f1btss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f1btss-tol", "maxValue": "f1btss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f1vr-tol", "maxValue": "f1vr+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "1", "maxValue": "1", "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f2btss-tol", "maxValue": "f2btss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f2btss-tol", "maxValue": "f2btss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "f2vr-tol", "maxValue": "f2vr+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "1", "maxValue": "1", "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "interactionss-tol", "maxValue": "interactionss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "interactionss-tol", "maxValue": "interactionss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "ivr-tol", "maxValue": "ivr+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "36", "maxValue": "36", "marks": 0.25}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "rss-tol", "maxValue": "rss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "mrs-tol", "maxValue": "mrs+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "39", "maxValue": "39", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "precround(f1btss+f2btss+interactionss+rss,2)-tol", "maxValue": "precround(f1btss+f2btss+interactionss+rss,2)+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m1", "maxValue": "m1", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m2", "maxValue": "m2", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m3", "maxValue": "m3", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m4", "maxValue": "m4", "marks": 0.5}], "type": "gapfill", "prompt": "

Now complete the following two factor ANOVA table from this data. Input the $SS,\\;MS$ and $VR$ data to 2 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
SourcedfSSMSVR
Personality[[0]][[1]][[2]][[3]]
Stimulus[[4]][[5]][[6]][[7]]
P-S interaction[[8]][[9]][[10]][[11]]
Residual[[12]][[13]][[14]]-
Total[[15]][[16]]--
\n

The Calculations.

\n

1. Residual Calculations. When you are calculating $TSS$ and $BTSS$ round them both to 2 decimal places, then calculate $RSS$ by taking away these rounded values. The $RMS$ value is then obtained by dividing this $RSS$ value by the residual degrees of freedom.

\n

2. For Personality, Stimulus and Interaction, calculate the estimations of their variances to 2 decimal places as well. These values go in the $MS$ column.

\n

3. The $VR$ values are obtained by dividing the first three values in the $MS$ column by the $RMS$ value. Enter the $VR$ values to 2 decimal places in the last column.

\n

 

\n

Also input the mean values of the factors at their various levels, input your answers to 2 decimal places:

\n

 

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
 $\\overline{x}_i$
Normal, Baseline[[17]]
Normal, Stress[[18]]
Antisocial, Baseline[[19]]
Antisocial, Stress[[20]]
", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"layout": {"expression": ""}, "choices": ["GSR: no dependence upon personality.", "GSR: no dependence upon stimulus.", "No interaction between the factors."], "matrix": "w", "type": "m_n_x", "maxAnswers": 0, "shuffleChoices": false, "marks": 0, "scripts": {}, "minMarks": 0, "minAnswers": 0, "maxMarks": 0, "shuffleAnswers": false, "showCorrectAnswer": true, "answers": ["Very strong rejection, $p \\le 0.001$.", "Strong rejection, $0.001\\lt p \\le 0.01$.", "Rejection, $0.01\\lt p \\le 0.05$.", "Accept, but investigate, $0.05\\lt p \\le 0.1$.", "Accept, $p \\gt 0.1$."]}], "type": "gapfill", "prompt": "

Using the following p-values for the $F_{1,36}$ statistic find the appropriate significance levels for the factors as given by their $VR$ value and then comment on the null hypotheses for each factor and the interaction.

\n

 

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$2.86$$4.12$$7.41$$12.88$
\n

 

\n

[[0]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "

 In a similar fashion to the calculation done in lectures, carry out a two factor ANOVA on the following set of data.

\n

Individuals who are identified as having an antisocial personality disorder may also have reduced physiological responses to anxiety-producing stimuli.

\n

One way of measuring this response is with ”galvanic skin response” (GSR), a measurable reduction in the electrical resistance on the skin. [This is the basis of how a lie detector works.]

\n

The following data represent the results of an experiment to compare the responses of normal and antisocial individuals in regular (baseline) and stress-provoking situations (low score reflects a more anxious individual):

\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
NormalBaseline$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Stress$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
AntisocialBaseline$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$$\\var{r3[6]}$$\\var{r3[7]}$$\\var{r3[8]}$$\\var{r3[9]}$
Stress$\\var{r4[0]}$$\\var{r4[1]}$$\\var{r4[2]}$$\\var{r4[3]}$$\\var{r4[4]}$$\\var{r4[5]}$$\\var{r4[6]}$$\\var{r4[7]}$$\\var{r4[8]}$$\\var{r4[9]}$
\n

 The null hypotheses we are testing are:

\n

1. The GSR does not depend upon the personality type.

\n

2. The GSR does not depend upon the stimulus.

\n

3. There is no interaction between personality and stimulus in determining the GSR.

\n

 

", "tags": ["ANOVA", "average", "checked2015", "data analysis", "degrees of freedom", "F-test", "factors", "hypothesis testing", "levels", "mean", "mean ", "p values", "PSY2010", "statistics", "stats", "two factor ANOVA", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "

26/11/2012

\n


Added tags and description.

\n

Changed calculations for BTSS for the factors and added the interaction analysis.

\n

Uses the inbuilt ftest function from the stats extension to find p values.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Two factor ANOVA example

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

We have two factors: Personality and Stimulus.

\n

Personality has two levels: Normal and Antisocial

\n

Stimulus has two levels: Baseline and Stress.

\n

First Step:

\n

First regard the different treatment combinations as a set of independent samples and analyse as for a one-way analysis with unrelated measurements. From this analysis, we obtain the Total Sum of Squares, the Between Treatments Sum of Squares ($BTSS$) and Residual Sum of Squares ($RSS$). Note that the degrees of freedom for this step are 36=40-4 as there are 4 treatments.

\n

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 \n \n
 $\\overline{x}_i$$T_i$$\\sum x^2$$n_i$
Normal, Baseline$\\var{m1}$$\\var{t[0]}$$\\var{ssq[0]}$10
Normal, Stress$\\var{m2}$$\\var{t[1]}$$\\var{ssq[1]}$10
Antisocial, Baseline$\\var{m3}$$\\var{t[2]}$$\\var{ssq[2]}$10
Antisocial, Stress$\\var{m4}$$\\var{t[3]}$$\\var{ssq[3]}$10
  $G=\\;\\var{g}$Sum of Squares=$\\var{ss}$$N=40$
\n

From this we obtain:

\n

\\[ BTSS =\\sum \\frac{T_i^2}{10}- \\frac{G^2}{40}=\\frac{\\var{t[0]}^2}{10}+\\frac{\\var{t[1]}^2}{10}+\\frac{\\var{t[2]}^2}{10}+\\frac{\\var{t[3]}^2}{10}-\\frac{\\var{g}^2}{40}=\\var{btss}\\]

\n

\\[TSS = \\sum \\sum x^2- \\frac{G^2}{40}=\\var{ss}- \\frac{\\var{g}^2}{40}=\\var{tss}\\] both to 2 decimal places.

\n

\\[RSS = TSS-BTSS=\\var{tss}-\\var{btss}=\\var{rss}\\]

\n

Second Step.

\n

Now ignore the Stimulus factor and calculate totals $T_i$ for each level of Personality. From these totals calculate a variance estimate for personality using the same method as before. The degrees of freedom will be one fewer than the levels of Stimulus and is therefore 1.

\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
Normal (Baseline and Stress)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
Antisocial (Baseline and Stress)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$$\\var{r3[6]}$$\\var{r3[7]}$$\\var{r3[8]}$$\\var{r3[9]}$$\\var{r3[0]}$$\\var{r4[1]}$$\\var{r4[2]}$$\\var{r4[3]}$$\\var{r4[4]}$$\\var{r4[5]}$$\\var{r4[6]}$$\\var{r4[7]}$$\\var{r4[8]}$$\\var{r4[9]}$
\n

You should have the following data from this 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
 $T_i$$\\sum x^2$$n_i$ (number of observations)
Normal, (Baseline and Stress)$\\var{f1t[0]}$$\\var{f1ssq[0]}$20
Antisocial, (Baseline and Stress)$\\var{f1t[1]}$$\\var{f1ssq[1]}$20
 $G=\\;\\var{g}$Sum of Squares=$\\var{f1ss}$$N=40$
\n

So we can calculate:

\n

\\[\\mbox{Variance estimate for personality} =\\sum \\frac{T_i^2}{20}- \\frac{G^2}{40}=\\frac{\\var{f1t[0]}^2}{20}+\\frac{\\var{f1t[1]}^2}{20}-\\frac{\\var{g}^2}{40}=\\var{f1btss}\\]

\n

Third Step.

\n

Repeat step 2 with the factors switched, i.e. use the totals $T_i$ for the Stimulus factor levels ignoring Personality.This gives a Between Treatments Sum of Squares. Again the degrees of freedom will be 2-1=1.

\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
Baseline (Normal and Antisocial)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$$\\var{r2[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$$\\var{r3[6]}$$\\var{r3[7]}$$\\var{r3[8]}$$\\var{r3[9]}$
Stress (Normal and Antisocial)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$$\\var{r4[0]}$$\\var{r4[1]}$$\\var{r4[2]}$$\\var{r4[3]}$$\\var{r4[4]}$$\\var{r4[5]}$$\\var{r4[6]}$$\\var{r4[7]}$$\\var{r4[8]}$$\\var{r4[9]}$
\n

You should have the following data from this 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
 $T_i$$\\sum x^2$$n_i$ (number of observations)
Baseline (Normal and Antisocial)$\\var{f2t[0]}$$\\var{f2ssq[0]}$20
Stress (Normal and Antisocial)$\\var{f2t[1]}$$\\var{f2ssq[1]}$20
 $G=\\;\\var{g}$Sum of Squares=$\\var{f2ss}$$N=40$
\n

So we can calculate:

\n

\\[ \\mbox{Variance estimate for stimulus} =\\sum \\frac{T_i^2}{20}- \\frac{G^2}{40}=\\frac{\\var{f2t[0]}^2}{20}+\\frac{\\var{f2t[1]}^2}{20}-\\frac{\\var{g}^2}{40}=\\var{f2btss}\\]

\n

Step 4.

\n

Now determine a Sum of Squares for Interaction by subtracting the sums of squares obtained for Personality (Step 2) and Stimulus (step 3) from the overall Between Treatments Sum of squares obtained in Step 1. The degrees of freedom is also obtained by subtraction and is 1.

\n

This gives: 

\n

\\[\\mbox{Variance estimate for the interaction}= \\var{btss}-\\var{f1btss}-\\var{f2btss} = \\var{interactionss}\\]

\n

The Anova Table.

\n

We now have all the terms required to construct the ANOVA table and hence test the null hypothesis relating to each factor and to the interaction. Note that the $VR$ values are obtained by dividing the $RMS$ value into the $MS$ values for the factors and the interaction.

\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
SourcedfSSMSVRDecision
Personality1$\\var{f1btss}$$\\var{f1btss}$$\\var{f1vr}${dec(f1vr)} that GSR is independent of personality.
Stimulus1$\\var{f2btss}$$\\var{f2btss}$$\\var{f2vr}${dec(f2vr)} that GSR is independent of the stimulus.
P-S interaction1 $\\var{interactionss}$  $\\var{interactionss}$ $\\var{ivr}$ {dec(ivr)} that personality and stimulus are independent in terms of GSR.
Residual36$\\var{rss}$$\\var{mrs}$- 
Total39$\\var{precround(f1btss+f2btss+interactionss+rss,2)}$-- 
"}, {"name": "Perform a paired sample t-test, ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ttest(0,d,2),3)", "name": "pvalue", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),12)", "name": "r1", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(tvalue>=t999,[1,0,0,0,0],if(tvalue>=t99,[0,1,0,0,0],if(tvalue>=t95,[0,0,1,0,0],if(tvalue>=t90,[0,0,0,1,0],[0,0,0,0,1]))))", "name": "v", "description": ""}, "pmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "name": "pmsg", "description": ""}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..3#0.2)", "name": "sig1", "description": ""}, "t90": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1.796", "name": "t90", "description": ""}, "tvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(abs(meandiff*sqrt(n)/stdiff),3)", "name": "tvalue", "description": ""}, "cmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "name": "cmsg", "description": ""}, "t99": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3.106", "name": "t99", "description": ""}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(18..25#0.5)", "name": "mu1", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "name": "t", "description": ""}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..4#0.2)", "name": "sig2", "description": ""}, "meandiff": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(d),3)", "name": "meandiff", "description": ""}, "t999": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4.437", "name": "t999", "description": ""}, "d": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(vector(r2)-vector(r1))", "name": "d", "description": ""}, "object": {"templateType": "anything", "group": "Ungrouped variables", "definition": "'Individual'", "name": "object", "description": ""}, "stdiff": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(d),3)", "name": "stdiff", "description": ""}, "t95": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2.201", "name": "t95", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "12", "name": "n", "description": ""}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),12)", "name": "r2", "description": ""}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu1+random(2..4#0.1)", "name": "mu2", "description": ""}, "cmsg1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['very strong','strong','slight','no','no']", "name": "cmsg1", "description": ""}, "msg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['is greater than $\\\\var{t999}$','lies between $\\\\var{t99}$ and $\\\\var{t999}$','lies between $\\\\var{t95}$ and $\\\\var{t99}$','lies between $\\\\var{t90}$ and $\\\\var{t95}$','is less than $\\\\var{t90}$']", "name": "msg", "description": ""}}, "ungrouped_variables": ["pmsg", "msg", "cmsg1", "t999", "meandiff", "object", "sig1", "tvalue", "stdiff", "sig2", "t99", "t95", "t90", "cmsg", "d", "mu1", "r1", "r2", "mu2", "n", "t", "v", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{meandiff}", "maxValue": "{meandiff}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{stdiff}", "maxValue": "{stdiff}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{tvalue}", "maxValue": "{tvalue}", "marks": 1}], "type": "gapfill", "prompt": "

Find the mean and standard deviations of the difference between left and right {attempt}s.

\n

Calculate differences for left {attempt} times – right {attempt} times. Make sure you take the differences this way round.

\n

Mean of difference = [[0]] (input  to 3 decimal places )

\n

Standard deviation of difference = [[1]] (input to 3 decimal places)

\n

Now find the t-test statistic $T$ using the values you have just calculated and  input the absolute value $|T|$ here: [[2]] (3 decimal places). 

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

$p$ less than $0.1 \\%$

", "

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

", "

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

", "

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

", "

$p$ is greater than $10\\%$

"], "displayColumns": 0, "prompt": "

Give the value of the t-statistic you have found, choose the range for the $p$ value by looking up the t-statistic tables:

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

Very Strong Evidence

", "

Strong Evidence

", "

Evidence

", "

Weak Evidence

", "

No Evidence

"], "displayColumns": 0, "prompt": "

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the average times for the left and right hands?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}], "statement": "

The following data was obtained from $12$ individuals. The observations consist of the time taken to complete a dexterity task using their left and right hands.

\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
{object}ABCDEFGHIJKL
Right$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$$\\var{r1[10]}$$\\var{r1[11]}$
Left$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$$\\var{r2[10]}$$\\var{r2[11]}$
\n

Carry out by hand a paired t-test to test whether there is evidence of a difference in the average times for the left and right hands.

", "tags": ["ACE2013", "average", "checked2015", "data analysis", "differences", "elementary statistics", "hypothesis testing", "mean", "mean ", "mean of differences", "paired t-test", "PSY2010", "standard deviation", "standard deviation of differences", "statistics", "stats", "t-test", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t \t\t

11/07/2012:

\n \t\t \t\t


Added tags.

\n \t\t \t\t

Calculation not yet tested.

\n \t\t \t\t

23/07/2012:

\n \t\t \t\t

Added description.

\n \t\t \t\t

Checked calculation.

\n \t\t \t\t

Changed display slightly in Advice.

\n \t\t \t\t

3/08/2012:

\n \t\t \t\t

Added tags.

\n \t\t \t\t

Question appears to be working correctly.

\n \t\t \n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Paired t-test to see if there is a difference between times take in a task.

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

The table of differences is given by:

\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
{object}ABCDEFGHIJKL
Right$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$$\\var{r1[10]}$$\\var{r1[11]}$
Left$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$$\\var{r2[10]}$$\\var{r2[11]}$
Differences$\\var{d[0]}$$\\var{d[1]}$$\\var{d[2]}$$\\var{d[3]}$$\\var{d[4]}$$\\var{d[5]}$$\\var{d[6]}$$\\var{d[7]}$$\\var{d[8]}$$\\var{d[9]}$$\\var{d[10]}$$\\var{d[11]}$
\n

We test the following hypothesis:

\n

$H_0:\\;\\mu_d=0$ versus $H_1:\\;\\mu_d\\neq 0$

\n

$n=\\var{n}$ and the mean of the differences is $\\overline{d}=\\var{meandiff}$.

\n

The variance $V$ of the differences is calculated to be $\\var{pstdev(d)^2}$

Hence we have the standard deviation $s_d= \\sqrt{V}=\\var{stdiff}$ to 3 decimal places.

\n

The paired t-statistic is given by:

\n

\\[\\begin{eqnarray*} T&=&\\frac{\\overline{d}-\\mu_d}{\\frac{s_d}{\\sqrt{n}}}\\\\&=&\\frac{\\var{meandiff}-0}{\\frac{\\var{stdiff}}{\\sqrt{\\var{n}}}}\\\\&=&\\var{tvalue}\\end{eqnarray*}\\]

\n

(Using the null hypothesis that the means are the same i.e. $\\mu_d=0$.)

\n

Hence our test statistic  $|T|=\\var{tvalue}$.

\n

Looking up this value on the T-distribution table for $t_{11}$

\n

\\[\\begin{array}{r|rrrrr}&0.20&0.10&0.05&0.01&0.001\\\\\\hline11&1.363&1.796&2.201&3.106&4.437\\end{array}\\]

\n

We see that the t-statistic {msg[t]} and the table tells us that the $p$ value {pmsg[t]}.

\n

Hence we conclude that we {cmsg[t]} the null hypothesis. There is {cmsg1[t]} evidence of a difference between the average scores of the two groups.

\n

 

"}, {"name": "Perform an independent two sample t-test", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.001", "name": "tol", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),10)", "name": "r1", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(atvalue>=t999,[1,0,0,0,0],if(atvalue>=t99,[0,1,0,0,0],if(atvalue>=t95,[0,0,1,0,0],if(atvalue>=t90,[0,0,0,1,0],[0,0,0,0,1]))))", "name": "v", "description": ""}, "pmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "name": "pmsg", "description": ""}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(8..10#0.2)", "name": "sig1", "description": ""}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n1", "description": ""}, "pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "ttest(atvalue,19,2)", "name": "pvalue", "description": ""}, "t90": {"templateType": "anything", "group": "Ungrouped variables", "definition": "1.734", "name": "t90", "description": ""}, "atvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "abs(tvalue)", "name": "atvalue", "description": ""}, "cmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "name": "cmsg", "description": ""}, "t99": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2.878", "name": "t99", "description": ""}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(55..75#0.5)", "name": "mu1", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "name": "t", "description": ""}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(8..10#0.2)", "name": "sig2", "description": ""}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "10", "name": "n2", "description": ""}, "t999": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3.922", "name": "t999", "description": ""}, "cmsg1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['very strong','strong','slight','no','no']", "name": "cmsg1", "description": ""}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mean(r1)", "name": "m1", "description": ""}, "t95": {"templateType": "anything", "group": "Ungrouped variables", "definition": "2.101", "name": "t95", "description": ""}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mean(r2)", "name": "m2", "description": ""}, "s": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(((n1-1)*sd1^2+(n2-1)*sd2^2)/(n1+n2-2)),3)", "name": "s", "description": ""}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),10)", "name": "r2", "description": ""}, "sd1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r1),3)", "name": "sd1", "description": ""}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(65..75#0.5)", "name": "mu2", "description": ""}, "tvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround((m1-m2)*sqrt(n1*n2)/(s*sqrt(n1+n2)),3)", "name": "tvalue", "description": ""}, "msg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['is greater than $\\\\var{t999}$','lies between $\\\\var{t99}$ and $\\\\var{t999}$','lies between $\\\\var{t95}$ and $\\\\var{t99}$','lies between $\\\\var{t90}$ and $\\\\var{t95}$','is less than $\\\\var{t90}$']", "name": "msg", "description": ""}, "sd2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r2),3)", "name": "sd2", "description": ""}}, "ungrouped_variables": ["sd1", "sd2", "m1", "tol", "m2", "msg", "cmsg1", "t999", "atvalue", "sig1", "tvalue", "sig2", "t99", "t95", "t90", "cmsg", "mu1", "r1", "r2", "mu2", "pmsg", "s", "t", "v", "n1", "n2", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "showQuestionGroupNames": false, "parts": [{"marks": 0, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{m1}", "maxValue": "{m1}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{sd1}", "maxValue": "{sd1}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{m2}", "maxValue": "{m2}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{sd2}", "maxValue": "{sd2}", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "{abs(tvalue)-tol}", "maxValue": "{abs(tvalue)+tol}", "marks": 1}], "type": "gapfill", "showCorrectAnswer": true, "steps": [{"type": "information", "showCorrectAnswer": true, "prompt": "

The two-sample t-statistic for two independent sets of data where one set has $n_1$ datapoints and the other set $n_2$ datapoints is calculated as follows:

\n

\\[T=\\frac{(\\overline{x}_1-\\overline{x}_2)-(\\mu_1-\\mu_2)}{s\\times\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}}\\;\\;\\;\\]

\n

where $\\overline{x}_1,\\;\\overline{x}_2$ are the sample means and 

\n

\\[s^2=\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}\\]

\n

where $s_1,\\;s_2$ are the sample standard deviations.

\n

Use the values you calculated to 3 decimal places in order to find $T$.

", "marks": 0, "scripts": {}}], "prompt": "

Find the mean and standard deviations of the scores of the two groups:

\n

Mean scores of Group 1= [[0]] (input to 3 decimal places)

\n

Standard deviation of scores for Group 1 = [[1]] (input to 3 decimal places)

\n

Mean scores of Group 2= [[2]] (input to 3 decimal places)

\n

Standard deviation of scores for Group 2 = [[3]] (input to 3 decimal places)

\n

Now find the two sample t-test statistic $T$ using the values you have just calculated to 3 decimal places and input $|T|$ here: [[4]] (3 decimal places)

", "stepsPenalty": 0}, {"displayType": "radiogroup", "choices": ["

$p$ less than $0.1\\%$

", "

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

", "

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

", "

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

", "

$p$ is greater than $10\\%$

"], "displayColumns": 0, "prompt": "

Give the value $|T|$ of the t-statistic you have found, choose the range for the $p$ value by looking up the t tables:

\n

 

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

Very Strong Evidence

", "

Strong Evidence

", "

Evidence

", "

Weak Evidence

", "

No Evidence

"], "displayColumns": 0, "prompt": "

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the average times for the left and right hands?

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

We reject the null hypothesis at the $0.1\\%$ level

", "

We reject the null hypothesis at the $1\\%$ level.

", "

We reject the null hypothesis at the $5\\%$ level.

", "

We do not reject the null hypothesis but consider further investigation.

", "

We do not reject the null hypothesis.

"], "displayColumns": 0, "prompt": "

Hence what is your decision based on the above analysis?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}], "statement": "

An educational psychologist claimed that the order in which questions were asked affected the student’s ability to answer them correctly and hence their total score. In order to test this, $20$ students were randomly divided into two groups of $10$. The first group were given questions in increasing order of difficulty and the second group in decreasing order of difficulty. The ordered test scores obtained were:

\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
Group 1$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Group 2$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
\n

Carry out by hand a two-sample t-test to test if there is evidence of a difference in the average test scores for the two sets of students.

", "tags": ["average", "checked2015", "data analysis", "differences", "elementary statistics", "hypothesis testing", "mean", "mean ", "PSY2010", "standard deviation", "statistics", "stats", "t-test", "two sample t-test", "variance"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t \t\t

11/07/2012:

\n \t\t \t\t


Added tags.

\n \t\t \t\t

Calculation not yet tested.

\n \t\t \t\t

23/07/2012:

\n \t\t \t\t

Added description.

\n \t\t \t\t

Checked calculation.

\n \t\t \t\t

Changed display slightly in Advice.

\n \t\t \t\t

3/08/2012:

\n \t\t \t\t

Added tags.

\n \t\t \t\t

Question appears to be working correctly.

\n \t\t \n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

Two sample t-test to see if there is a difference between scores on questions between two groups when the questions are asked in a different order.

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

We test the following hypothesis,

\n

$H_0:\\; \\mu_1=\\mu_2$ versus $H_1:\\; \\mu_1 \\neq \\mu_2$

\n

We find that the mean score of Group 1 is $\\overline{x}_1=\\var{m1}$ with standard deviation $s_1=\\var{sd1}$ and the mean score of Group 2 is $\\overline{x}_2=\\var{m2}$ with standard deviation $s_2=\\var{sd2}$.

\n

All calculated to 3 decimal places.

\n

Using the formula for the two-sample t-statistic as  shown above with $n_1=n_2=10$:

\n

The estimate of the pooled variance is calculated to be:

\n

\\[s^2=\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}= \\frac{\\var{n1-1}\\times \\var{sd1}^2+\\var{n2-1}\\times \\var{sd2}^2}{\\var{n1+n2-2}}=\\var{s^2}.\\] 

\n

Hence $s= \\sqrt{\\var{s^2}}=\\var{s}$ to 3 decimal places.

\n

We find that the t-statistic has value:

\n

\\[\\begin{eqnarray*}T&=& \\frac{(\\overline{x}_1-\\overline{x}_2)-(\\mu_1-\\mu_2)}{s\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}}\\\\&=&\\frac{(\\var{m1}-\\var{m2})-(0)}{\\var{s}\\sqrt{\\frac{1}{\\var{n1}}+\\frac{1}{\\var{n2}}}}\\\\&=&\\var{tvalue}\\end{eqnarray*}\\] to 3 decimal places.

\n

Our test statistic is $|T|=\\var{abs(tvalue)}$.

\n

Given that we have $n_1+n_2-2=18$ degrees of freedom, we look up this value on the T-distribution table for $t_{18}$

\n

\\[\\begin{array}{r|rrrrr}&0.20&0.10&0.05&0.01&0.001\\\\\\hline18&1.330&1.734&2.101&2.878&3.922\\end{array}\\]

\n

We see that the t-statistic {msg[t]} and the table tells us that the $p$ value {pmsg[t]}.

\n

Hence we conclude that we {cmsg[t]} the null hypothesis. There is {cmsg1[t]} evidence of a difference between the average scores of the two groups.

\n

 

"}, {"name": "Perform a two-way ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sum(map(x^2,x,cols))/n-tot^2/(m*n),2)", "name": "btss", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "name": "tol", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(repeat(round(normalsample(mu[x],sig)),5),x,0..m-1)", "name": "r1", "description": ""}, "dfbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m-1", "name": "dfbt", "description": ""}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(sum(map(x^2,x,r[y])),y,0..n-1))", "name": "ssq", "description": ""}, "sig": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..7#0.2)", "name": "sig", "description": ""}, "t90": {"templateType": "anything", "group": "Ungrouped variables", "definition": "13.36", "name": "t90", "description": ""}, "tss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ssq-tot^2/(m*n),2)", "name": "tss", "description": ""}, "mu": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[random(30..40),random(35..40),random(25..35),random(40..45),random(20..40)]", "name": "mu", "description": ""}, "rs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(rss/dfr,2)", "name": "rs", "description": ""}, "t99": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20.09", "name": "t99", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vr>=10.8,[1,0,0,0,0],vr>=5.95,[0,1,0,0,0],vr>=3.49,[0,0,1,0,0],vr>=2.61,[0,0,0,1,0],[0,0,0,0,1])", "name": "v", "description": ""}, "msbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(btss/(m-1),2)", "name": "msbt", "description": ""}, "v1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pvalue<=0.001,[1,0,0,0,0],pvalue<=0.01,[0,1,0,0,0],pvalue<=0.05,[0,0,1,0,0],pvalue<=0.1,[0,0,0,1,0],[0,0,0,0,1])", "name": "v1", "description": ""}, "bbss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sum(map(x^2,x,t))/m-tot^2/20,2)", "name": "bbss", "description": ""}, "vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(msbt/rs,2)", "name": "vr", "description": ""}, "cols": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(rt[x]),x,0..m-1)", "name": "cols", "description": ""}, "pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ftest(VR,3,12),3)", "name": "pvalue", "description": ""}, "dfr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m*n-m-n+1", "name": "dfr", "description": ""}, "rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tss-btss-bbss", "name": "rss", "description": ""}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4", "name": "m", "description": ""}, "msbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(bbss/(n-1),2)", "name": "msbb", "description": ""}, "dfbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n-1", "name": "dfbb", "description": ""}, "vrbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(msbb/rs,2)", "name": "vrbb", "description": ""}, "t95": {"templateType": "anything", "group": "Ungrouped variables", "definition": "15.51", "name": "t95", "description": ""}, "tot": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(cols)", "name": "tot", "description": ""}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r1)))", "name": "r", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "5", "name": "n", "description": ""}, "stderror": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(rs/n),2)", "name": "stderror", "description": ""}, "rt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r)))", "name": "rt", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(r[x]),x,0..n-1)", "name": "t", "description": ""}}, "ungrouped_variables": ["stderror", "bbss", "cols", "vrbb", "vr", "rt", "rs", "msbb", "tot", "dfr", "sig", "tol", "btss", "tss", "dfbt", "msbt", "ssq", "v1", "dfbb", "t99", "t95", "t90", "rss", "r1", "m", "n", "mu", "r", "t", "v", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "tss-tol", "maxValue": "tss+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "btss-tol", "maxValue": "btss+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "bbss-tol", "maxValue": "bbss+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "rss-tol", "maxValue": "rss+tol", "marks": 1}], "type": "gapfill", "prompt": "

Treatment totals are:

\n

$T_1=\\var{cols[0]},\\;T_2=\\var{cols[1]},\\;T_3=\\var{cols[2]},\\;T_4=\\var{cols[3]}$

\n

Subject totals are:

\n

$B_1=\\var{t[0]},\\;B_2=\\var{t[1]},\\;B_3=\\var{t[2]},\\;B_4=\\var{t[3]},\\;B_5=\\var{t[4]}$

\n

$\\sum \\sum x^2 = \\var{ssq}$ and $G= \\var{tot}$

\n

Now using the above find the following, all to 2 decimal places:

\n

$\\displaystyle TSS\\;=\\;$[[0]], $\\displaystyle BTSS\\;=\\;$[[1]]

\n

$\\displaystyle BBSS \\;=\\;$[[2]], $\\displaystyle RSS\\;=\\;$[[3]]

\n

(Find $RSS$ using the values to 2 decimal places for $TSS,\\;BTSS,\\;BBSS$.)

", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m-1", "maxValue": "m-1", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "btss-tol", "maxValue": "btss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "msbt-tol", "maxValue": "msbt+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "vr-0.01", "maxValue": "vr+0.01", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "n-1", "maxValue": "n-1", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "bbss-tol", "maxValue": "bbss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "msbb-0.01", "maxValue": "msbb+0.01", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "vrbb-0.01", "maxValue": "vrbb+0.01", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "dfr", "maxValue": "dfr", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "rss-tol", "maxValue": "rss+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "rs-0.01", "maxValue": "rs+0.01", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m*n-1", "maxValue": "m*n-1", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "tss-tol", "maxValue": "tss+tol", "marks": 0.5}], "type": "gapfill", "prompt": "

Now complete the ANOVA table using the values obtained to 2 decimal places above:

\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
SourcedfSSMSVR
Between Treatments[[0]][[1]][[2]][[3]]
Between Blocks[[4]][[5]][[6]][[7]]
Residual[[8]][[9]][[10]]-
Total[[11]][[12]]--
\n

Input all numbers to 2 decimal places.

\n

 Note that VR is found by taking the ratio of two of the values in this table.

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

$p$ less than $0.1\\%$

", "

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

", "

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

", "

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

", "

$p$ is greater than $10\\%$

"], "displayColumns": 1, "prompt": "

Give the value of $VR$ you have found, choose the range for the $p$ value by looking up the critical values of $F_{3,12}$ (one-sided).

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$2.61$$3.49$$5.95$$10.8$
", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["

Very Strong Evidence

", "

Strong Evidence

", "

Evidence

", "

Weak Evidence

", "

No Evidence

"], "displayColumns": 0, "prompt": "

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the treatments offered by the sun-creams?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["We reject the null hypothesis at the $0.1\\%$ level", "We reject the null hypothesis at the $1\\%$ level.", "We reject the null hypothesis at the $5\\%$ level.", "We do not reject the null hypothesis but more investigation is needed.", "We do not reject the null hypothesis."], "displayColumns": 1, "prompt": "

Hence what is your decision based on the above ANOVA analysis?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "mean(r1[0])-tol", "maxValue": "mean(r1[0])+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "mean(r1[1])-tol", "maxValue": "mean(r1[1])+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "mean(r1[2])-tol", "maxValue": "mean(r1[2])+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "mean(r1[3])-tol", "maxValue": "mean(r1[3])+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "stderror-tol", "maxValue": "stderror+tol", "marks": 1}], "type": "gapfill", "prompt": "

Enter the sample means for the sun-creams:

\n

W: [[0]], X:[[1]], Y:[[2]], Z:[[3]]

\n

Also enter an estimate of the standard error of the mean: [[4]]

\n

(Use the value to 2 decimal places you obtained above for $RMS$ to calculate the standard error of the mean).

", "showCorrectAnswer": true, "marks": 0}], "statement": "

To test the effectiveness of sun-tan creams, five volunteers A, B, C, D, E each tried four creams W, X, Y, Z on various parts of their legs. They were then subjected to ultra-violet radiation and an estimate of the degree of burning was made (higher figures indicate greater burning). The results are given below with some totals:

\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 \n \n \n \n \n \n \n
 WXYZTotals
A{r[0][0]}{r[0][1]}{r[0][2]}{r[0][3]}{t[0]}
B{r[1][0]}{r[1][1]}{r[1][2]}{r[1][3]}{t[1]}
C{r[2][0]}{r[2][1]}{r[2][2]}{r[2][3]}{t[2]}
D{r[3][0]}{r[3][1]}{r[3][2]}{r[3][3]}{t[3]}
E{r[4][0]}{r[4][1]}{r[4][2]}{r[4][3]}{t[4]}
Totals{cols[0]}{cols[1]}{cols[2]}{cols[3]}{tot}
\n

You are given that $\\sum \\sum x^2=\\var{ssq}$ is the uncorrected sum of squares of the observations and you are asked to:

\n
    \n
  • Complete the two-way analysis of variance and test the null-hypothesis that the creams are equally effective.
  • \n
\n

 

\n
    \n
  • Write down the sample mean for each sun-cream together with an estimate of the standard error of the mean, $\\frac{s}{\\sqrt{n}}$.
  • \n
", "tags": ["ANOVA", "checked2015", "hypothesis testing", "PSY2010", "statistics", "two-way ANOVA"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

Two-way ANOVA example, 5 subjects, 4 treatments.

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

 

\n

 

"}, {"name": "LSD and Tukey yardsticks, and one-way ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ftest(VR,2,15),3)", "name": "pvalue", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),6)", "name": "r1", "description": ""}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2)),sum(map(x^2,x,r3))]", "name": "ssq", "description": ""}, "btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(stovern-G^2/N,2)", "name": "btss", "description": ""}, "sd1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r1),2)", "name": "sd1", "description": ""}, "tss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ss-G^2/N,2)", "name": "tss", "description": ""}, "k": {"templateType": "anything", "group": "Ungrouped variables", "definition": "3", "name": "k", "description": ""}, "dfbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "k-1", "name": "dfbt", "description": ""}, "sig2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "name": "sig2", "description": ""}, "v1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pvalue<=0.001,[1,0,0,0,0],pvalue<=0.01,[0,1,0,0,0],pvalue<=0.05,[0,0,1,0,0],pvalue<=0.1,[0,0,0,1,0],[0,0,0,0,1])", "name": "v1", "description": ""}, "vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(MBT/MRS,2)", "name": "vr", "description": ""}, "w1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(m1-m2)>=tukey,[1,0,0],abs(m1-m2)>=lsd,[0,1,0],[0,0,1])", "name": "w1", "description": ""}, "rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ss-stovern,2)", "name": "rss", "description": ""}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "name": "n1", "description": ""}, "sd3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r3),2)", "name": "sd3", "description": ""}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(ssq)", "name": "ss", "description": ""}, "w2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(m3-m2)>=tukey,[1,0,0],abs(m3-m2)>=lsd,[0,1,0],[0,0,1])", "name": "w2", "description": ""}, "sig3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sig1", "name": "sig3", "description": ""}, "mbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(BTSS/dfbt,2)", "name": "mbt", "description": ""}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),6)", "name": "r2", "description": ""}, "mu2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu1+random(3..6)", "name": "mu2", "description": ""}, "g": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(t)", "name": "g", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2),sum(r3)]", "name": "t", "description": ""}, "sd2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(pstdev(r2),2)", "name": "sd2", "description": ""}, "w": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[w1,w2,w3]", "name": "w", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "name": "tol", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vr>=11.34,[1,0,0,0,0],vr>=6.36,[0,1,0,0,0],vr>=3.68,[0,0,1,0,0],vr>=2.7,[0,0,0,1,0],[0,0,0,0,1])", "name": "v", "description": ""}, "pmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "name": "pmsg", "description": ""}, "sig1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..4#0.2)", "name": "sig1", "description": ""}, "sqrms": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(mrs),2)", "name": "sqrms", "description": ""}, "mrs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(RSS/dfrs,2)", "name": "mrs", "description": ""}, "u": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "name": "u", "description": ""}, "m3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r3),2)", "name": "m3", "description": ""}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "name": "n2", "description": ""}, "cmsg": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "name": "cmsg", "description": ""}, "mu1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..25#0.5)", "name": "mu1", "description": ""}, "stovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(tsqovern)", "name": "stovern", "description": ""}, "lsd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(2.131*sqrms*sqrt(2/n1),2)", "name": "lsd", "description": ""}, "dfrs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "N-k", "name": "dfrs", "description": ""}, "yn": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(yeaornay(x),x,w[z]),z,0..2)", "name": "yn", "description": ""}, "tukey": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(3.67*sqrms*1/sqrt(n1),2)", "name": "tukey", "description": ""}, "w3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(m3-m1)>=tukey,[1,0,0],abs(m3-m1)>=lsd,[0,1,0],[0,0,1])", "name": "w3", "description": ""}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r1),2)", "name": "m1", "description": ""}, "r3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu3,sig3)),6)", "name": "r3", "description": ""}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mean(r2),2)", "name": "m2", "description": ""}, "n3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "6", "name": "n3", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n1+n2+n3", "name": "n", "description": ""}, "stderror": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(mrs/sqrt(n1),2)", "name": "stderror", "description": ""}, "mu3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mu2+random(4..6)", "name": "mu3", "description": ""}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n1,t[1]^2/n2,t[2]^2/n3]", "name": "tsqovern", "description": ""}}, "ungrouped_variables": ["lsd", "tukey", "sd1", "sd2", "sd3", "vr", "w3", "w2", "w1", "mbt", "n", "pmsg", "mu3", "stderror", "sqrms", "dfrs", "m1", "m3", "m2", "btss", "stovern", "tss", "dfbt", "tol", "yn", "ssq", "sig1", "v1", "sig3", "sig2", "cmsg", "rss", "tsqovern", "mu1", "g", "r2", "mu2", "ss", "k", "r3", "mrs", "r1", "u", "t", "w", "v", "n1", "n2", "n3", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"pstdev": {"type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}, "yeaornay": {"type": "string", "language": "jme", "definition": "if(n=1,'Yes','No')", "parameters": [["n", "number"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "sqrms-tol", "maxValue": "sqrms+tol", "marks": 1}], "type": "gapfill", "prompt": "\n

You are given the following ANOVA table for this data:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
SourcedfSSMSVR
Between Treatments$\\var{dfbt}$$\\var{btss}$$\\var{mbt}$$\\var{vr}$
Residual$\\var{dfrs}$$\\var{rss}$$\\var{mrs}$-
Total$\\var{n-1}$$\\var{tss}$--
\n

 

\n

 Input $\\sqrt{RMS}$ here: [[0]] to 2 decimal places.

\n

 

\n

This will be used to calculate the LSD and Tukey yardstick values later.

\n \n ", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["Very strong", "Strong", "Moderate", "Weak", "None"], "displayColumns": 0, "prompt": "\n

Using ANOVA

\n

Using the $VR$ value given in the table and one-way ANOVA, what is the strength of evidence against the null hypothesis that the mean times taken are the same for the three groups?

\n ", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["We reject the null hypothesis at the $0.1\\%$ level", "We reject the null hypothesis at the $1\\%$ level.", "We reject the null hypothesis at the $5\\%$ level.", "We do not reject the null hypothesis but consider further investigation.", "We do not reject the null hypothesis."], "displayColumns": 1, "prompt": "

Hence what is your decision based on the above ANOVA analysis?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m1", "maxValue": "m1", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m2", "maxValue": "m2", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "m3", "maxValue": "m3", "marks": 1}], "type": "gapfill", "prompt": "\n

Using the Yardsticks

\n

Fill in this table with the appropriate values for the mean values of the groups, all decimals to 2 decimal places:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 $\\overline{x}_i$
Group A[[0]]
Group B[[1]]
Group C[[2]]
\n

 

\n ", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "lsd-tol", "maxValue": "lsd+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "tukey-tol", "maxValue": "tukey+tol", "marks": 1}, {"layout": {"expression": ""}, "choices": ["Groups $A$ and $B$", "Groups $B$ and $C$", "Groups $A$ and $C$"], "matrix": "w", "type": "m_n_x", "maxAnswers": 0, "shuffleChoices": false, "marks": 0, "scripts": {}, "minMarks": 0, "minAnswers": 0, "maxMarks": 0, "shuffleAnswers": false, "showCorrectAnswer": true, "answers": ["Definite Significant Difference", "Possible Significant Difference", "No Significant Difference"]}], "type": "gapfill", "prompt": "

Now find the LSD and Tukey yardsticks from the above data. Use the value to 2 decimal places you found for $\\sqrt{RMS}$:

\n

   LSD= [[0]]

\n

Tukey= [[1]]

\n

 Using these yardsticks fill in the following table indicating if there is a possible or definite significant difference between the pairs of groups mean times in undertaking the tasks:

\n

[[2]]

", "showCorrectAnswer": true, "marks": 0}], "statement": "\n

The following data arose in a comparison of the effects of alcohol on the time taken to complete a task. There were three groups of subjects; Group A had no alcohol, Group B had two units over 1 hour and Group C had 4 units over 1 hour. The responses are the times (in seconds) taken to complete a word-matching task.

\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
Group A (0 units)$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$
Group B (2 units)$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$
Group C (4 units)$\\var{r3[0]}$$\\var{r3[1]}$$\\var{r3[2]}$$\\var{r3[3]}$$\\var{r3[4]}$$\\var{r3[5]}$
\n

 

\n \n ", "tags": ["ANOVA", "average", "checked2015", "data analysis", "definite significant difference", "degrees of freedom", "F-test", "hypothesis testing", "Least significant difference", "lsd", "LSD", "mean ", "possible significant difference", "PSY2010", "standard deviation", "statistics", "stats", "Tukey", "tukey ", "variance", "yardsticks", "Yardsticks"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "\n \t\t \t\t

15/11/2012:

\n \t\t \t\t


This question cones from editing a one-way Anova example

\n \t\t \t\t

Added tags and description

\n \t\t \t\t

 

\n \t\t \n \t\t", "licence": "Creative Commons Attribution 4.0 International", "description": "

LSD and Tukey yardsticks on three treatments. Also one-way Anova test on same set of data.

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

Using the Yardsticks

\n

The mean values for each group are:

\n

  

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 $\\overline{x}_i$
Group A$\\var{m1}$
Group B$\\var{m2}$
Group C$\\var{m3}$  
\n

The differences between the mean values for the groups are:

\n

Between $A$ and $B=\\;|\\var{m1}-\\var{m2}|=\\var{abs(m1-m2)}$

\n

Between $B$ and $C=\\;|\\var{m2}-\\var{m3}|=\\var{abs(m2-m3)}$

\n

Between $A$ and $C=\\;|\\var{m1}-\\var{m3}|=\\var{abs(m1-m3)}$

\n

We compare these differences with the LSD and Tukey yardsticks:

\n

LSD yardstick = $2.131\\times\\var{sqrms}\\times\\sqrt{2/\\var{n1}}=\\var{lsd}$ to 2 decimal places, where $\\var{sqrms}$ is the value of $\\sqrt{RMS}$ found above.

\n

Tukey yardstick = $3.67\\times\\var{sqrms}\\times\\sqrt{1/\\var{n1}}=\\var{tukey}$ to 2 decimal places.

\n

If the difference of the means:

\n
    \n
  • is greater than the Tukey yardstick we say that there is evidence of a definite significant difference.
  • \n
\n

 

\n
    \n
  • less than the Tukey yardstick but greater than the LSD yardstick we say that there is evidence of a possible significant difference.
  • \n
\n

 

\n
    \n
  • is less than the LSD yardstick then we say that there is no  evidence of a significant difference.
  • \n
\n

 

\n

Hence we have the following for the groups:

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Pairs of GroupsDefinite Significant DifferencePossible Significant DifferenceNo Significant Difference
Means of Groups A and B{yn[0][0]}{yn[0][1]}{yn[0][2]}
Means of Groups B and C{yn[1][0]}{yn[1][1]}{yn[1][2]}
Means of Groups A and C{yn[2][0]}{yn[2][1]}{yn[2][2]}
"}, {"name": "LSD and Tukey yardsticks, and two-way ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"btss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sum(map(x^2,x,cols))/n-tot^2/(m*n),2)", "name": "btss", "description": ""}, "sig": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..7#0.2)", "name": "sig", "description": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(repeat(round(normalsample(mu[x],sig)),5),x,0..m-1)", "name": "r1", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(vr>=10.8,[1,0,0,0,0],vr>=5.95,[0,1,0,0,0],vr>=3.49,[0,0,1,0,0],vr>=2.61,[0,0,0,1,0],[0,0,0,0,1])", "name": "v", "description": ""}, "v1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(pvalue<=0.001,[1,0,0,0,0],pvalue<=0.01,[0,1,0,0,0],pvalue<=0.05,[0,0,1,0,0],pvalue<=0.1,[0,0,0,1,0],[0,0,0,0,1])", "name": "v1", "description": ""}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(sum(map(x^2,x,r[y])),y,0..n-1))", "name": "ssq", "description": ""}, "vrbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(msbb/rs,2)", "name": "vrbb", "description": ""}, "t90": {"templateType": "anything", "group": "Ungrouped variables", "definition": "13.36", "name": "t90", "description": ""}, "tss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ssq-tot^2/(m*n),2)", "name": "tss", "description": ""}, "mu": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[random(30..40),random(35..40),random(25..35),random(40..45),random(20..40)]", "name": "mu", "description": ""}, "rs": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(rss/dfr,2)", "name": "rs", "description": ""}, "w6": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[2]-me[3])>=tukey,[1,0,0],abs(me[2]-me[3])>=lsd,[0,1,0],[0,0,1])", "name": "w6", "description": ""}, "dfbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m-1", "name": "dfbt", "description": ""}, "msbt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(btss/(m-1),2)", "name": "msbt", "description": ""}, "w4": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[1]-me[2])>=tukey,[1,0,0],abs(me[1]-me[2])>=lsd,[0,1,0],[0,0,1])", "name": "w4", "description": ""}, "bbss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sum(map(x^2,x,t))/m-tot^2/20,2)", "name": "bbss", "description": ""}, "lsd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(2.179*sqrms*sqrt(2/5),2)", "name": "lsd", "description": ""}, "w5": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[1]-me[3])>=tukey,[1,0,0],abs(me[1]-me[3])>=lsd,[0,1,0],[0,0,1])", "name": "w5", "description": ""}, "vr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(msbt/rs,2)", "name": "vr", "description": ""}, "cols": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(rt[x]),x,0..m-1)", "name": "cols", "description": ""}, "w1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[0]-me[1])>=tukey,[1,0,0],abs(me[0]-me[1])>=lsd,[0,1,0],[0,0,1])", "name": "w1", "description": ""}, "pvalue": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ftest(VR,3,12),3)", "name": "pvalue", "description": ""}, "tot": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(cols)", "name": "tot", "description": ""}, "dfr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m*n-m-n+1", "name": "dfr", "description": ""}, "tukey": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(4.2*sqrms*sqrt(1/5),2)", "name": "tukey", "description": ""}, "w": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[w1,w2,w3,w4,w5,w6]", "name": "w", "description": ""}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "4", "name": "m", "description": ""}, "msbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(bbss/(n-1),2)", "name": "msbb", "description": ""}, "dfbb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "n-1", "name": "dfbb", "description": ""}, "w3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[0]-me[3])>=tukey,[1,0,0],abs(me[0]-me[3])>=lsd,[0,1,0],[0,0,1])", "name": "w3", "description": ""}, "sqrms": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(rs),2)", "name": "sqrms", "description": ""}, "t99": {"templateType": "anything", "group": "Ungrouped variables", "definition": "20.09", "name": "t99", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "name": "tol", "description": ""}, "t95": {"templateType": "anything", "group": "Ungrouped variables", "definition": "15.51", "name": "t95", "description": ""}, "w2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(abs(me[0]-me[2])>=tukey,[1,0,0],abs(me[0]-me[2])>=lsd,[0,1,0],[0,0,1])", "name": "w2", "description": ""}, "yn": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(map(yeaornay(x),x,w[z]),z,0..5)", "name": "yn", "description": ""}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r1)))", "name": "r", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "5", "name": "n", "description": ""}, "me": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(mean(r1[x]),x,0..3)", "name": "me", "description": ""}, "stderror": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sqrt(rs/n),2)", "name": "stderror", "description": ""}, "rt": {"templateType": "anything", "group": "Ungrouped variables", "definition": "list(transpose(matrix(r)))", "name": "rt", "description": ""}, "rss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "tss-btss-bbss", "name": "rss", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(sum(r[x]),x,0..n-1)", "name": "t", "description": ""}}, "ungrouped_variables": ["lsd", "tukey", "stderror", "bbss", "cols", "vrbb", "w6", "vr", "w4", "w3", "w2", "w1", "dfr", "rt", "rs", "t90", "tot", "sqrms", "sig", "tol", "btss", "tss", "dfbt", "yn", "msbt", "ssq", "v1", "dfbb", "t99", "t95", "msbb", "rss", "me", "r1", "m", "w5", "n", "mu", "r", "t", "w", "v", "pvalue"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"yeaornay": {"type": "string", "language": "jme", "definition": "if(n=1, \"Yes\", \"No\")", "parameters": [["n", "number"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "sqrms-tol", "maxValue": "sqrms+tol", "marks": 1}], "type": "gapfill", "prompt": "

Here is the ANOVA table corresponding to this data:

\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
SourcedfSSMSVR
Between Treatments$\\var{m-1}$$\\var{btss}$$\\var{msbt}$$\\var{vr}$
Between Blocks$\\var{n-1}$$\\var{bbss}$$\\var{msbb}$$\\var{vrbb}$
Residual$\\var{dfr}$$\\var{rss}$$\\var{rs}$-
Total$\\var{m*n-1}$$\\var{tss}$--
\n

Input $\\sqrt{RMS}$ here: [[0]] to 2 decimal places.

\n

This will be used later to calculate the yardsticks.

", "showCorrectAnswer": true, "marks": 0}, {"displayType": "radiogroup", "choices": ["

$p$ less than $0.1\\%$

", "

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

", "

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

", "

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

", "

$p$ is greater than $10\\%$

"], "displayColumns": 1, "prompt": "

Given the value of $VR$ in the table above, find the range for the $p$ value by looking up the critical values of $F_{3,12}$ (one-sided).

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$2.61$$3.49$$5.95$$10.8$
", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["Very strong", "Strong", "Moderate", "Weak", "None"], "displayColumns": 0, "prompt": "

Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the treatments offered by the sun-creams?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"displayType": "radiogroup", "choices": ["We reject the null hypothesis at the $0.1\\%$ level", "We reject the null hypothesis at the $1\\%$ level.", "We reject the null hypothesis at the $5\\%$ level.", "We do not reject the null hypothesis but more investigation is needed.", "We do not reject the null hypothesis."], "displayColumns": 1, "prompt": "

Hence what is your decision based on the above ANOVA analysis?

", "distractors": ["", "", "", "", ""], "shuffleChoices": false, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": "v", "marks": 0}, {"scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "me[0]-tol", "maxValue": "me[0]+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "me[1]-tol", "maxValue": "me[1]+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "me[2]-tol", "maxValue": "me[2]+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "me[3]-tol", "maxValue": "me[3]+tol", "marks": 0.5}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "lsd-tol", "maxValue": "lsd+tol", "marks": 1}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "tukey-tol", "maxValue": "tukey+tol", "marks": 1}], "type": "gapfill", "prompt": "

Using the yardsticks

\n

Enter the sample means for the sun-creams:

\n

W: [[0]], X:[[1]], Y:[[2]], Z:[[3]] (to 2 decimal places).

\n

Calclate the LSD and Tukey yardsticks using the value for $\\sqrt{RMS}$ to 2 decimal places obtained above.

\n

 

\n

LSD yardstick value =    [[4]] (to 2 decimal places).

\n

 

\n

Tukey yardstick value = [[5]] (to 2 decimal places).

\n

 

", "showCorrectAnswer": true, "marks": 0}, {"layout": {"expression": ""}, "choices": ["$W$ and $X$", "$W$ and $Y$", "$W$ and $Z$", "$X$ and $Y$", "$X$ and $Z$", "$Y$ and $Z$"], "matrix": "w", "prompt": "

Using these yardsticks fill in the following table indicating if there is a possible or definite significant difference between the sample means of pairs of sun-creams.

\n

 

", "type": "m_n_x", "maxAnswers": 0, "shuffleChoices": false, "marks": 0, "scripts": {}, "maxMarks": 0, "minAnswers": 0, "minMarks": 0, "shuffleAnswers": false, "showCorrectAnswer": true, "answers": ["Definite Significant Difference", "Possible Significant Difference", "No Significant Difference"]}], "statement": "

To test the effectiveness of sun-tan creams, five volunteers A, B, C, D, E each tried four creams W, X, Y, Z on various parts of their legs. They were then subjected to ultra-violet radiation and an estimate of the degree of burning was made (higher figures indicate greater burning). The results are given below with some totals:

\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 \n \n \n \n \n \n \n
 WXYZTotals
A{r[0][0]}{r[0][1]}{r[0][2]}{r[0][3]}{t[0]}
B{r[1][0]}{r[1][1]}{r[1][2]}{r[1][3]}{t[1]}
C{r[2][0]}{r[2][1]}{r[2][2]}{r[2][3]}{t[2]}
D{r[3][0]}{r[3][1]}{r[3][2]}{r[3][3]}{t[3]}
E{r[4][0]}{r[4][1]}{r[4][2]}{r[4][3]}{t[4]}
Totals{cols[0]}{cols[1]}{cols[2]}{cols[3]}{tot}
\n

 

\n
    \n
  • Test the null-hypothesis using two-way ANOVA that the creams are equally effective.
  • \n
\n

 

\n
    \n
  • Write down the sample mean for each sun-cream together with the LSD and Tukey yardsticks so that you can see if there is any significant difference between the sample means given by these yardsticks..
  • \n
", "tags": ["ANOVA", "checked2015", "hypothesis testing", "lsd", "LSD", "PSY2010", "sample means", "significant difference", "statistics", "Tukey", "tukey ", "two-way ANOVA", "yardsticks", "Yardsticks"], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

LSD and Tukey yardsticks on five treatments. Also two-way Anova test on same set of data.

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

 Using the Yardsticks

\n

The mean values for each sun-cream are:

\n

  

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 $\\overline{x}_i$
W$\\var{me[0]}$
X$\\var{me[1]}$
Y$\\var{me[2]}$
Z$\\var{me[3]}$
\n

The differences between the mean values for the sun-creams are:

\n

Between $W$ and $X=\\;|\\var{me[0]}-\\var{me[1]}|=\\var{abs(me[0]-me[1])}$

\n

Between $W$ and $Y=\\;|\\var{me[0]}-\\var{me[2]}|=\\var{abs(me[0]-me[2])}$

\n

Between $W$ and $Z=\\;|\\var{me[0]}-\\var{me[3]}|=\\var{abs(me[0]-me[3])}$

\n

Between $X$ and $Y=\\;|\\var{me[1]}-\\var{me[2]}|=\\var{abs(me[1]-me[2])}$

\n

Between $X$ and $Z=\\;|\\var{me[1]}-\\var{me[3]}|=\\var{abs(me[1]-me[3])}$

\n

Between $Y$ and $Z=\\;|\\var{me[2]}-\\var{me[3]}|=\\var{abs(me[2]-me[3])}$

\n

We compare these differences with the LSD and Tukey yardsticks:

\n

LSD yardstick = $2.179\\times\\var{sqrms}\\times\\sqrt{2/\\var{n}}=\\var{lsd}$ to 2 decimal places, where $\\var{sqrms}$ is the value of $\\sqrt{RMS}$ found above.

\n

Tukey yardstick = $4.2\\times\\var{sqrms}\\times\\sqrt{1/\\var{n}}=\\var{tukey}$ to 2 decimal places.

\n

If the difference of the means:

\n
    \n
  • is greater than the Tukey yardstick we say that there is evidence of a definite significant difference.
  • \n
\n

 

\n
    \n
  • less than the Tukey yardstick but greater than the LSD yardstick we say that there is evidence of a possible significant difference.
  • \n
\n

 

\n
    \n
  • is less than the LSD yardstick then we say that there is no  evidence of a significant difference.
  • \n
\n

 

\n

Hence we have the following for the sun-creams:

\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
Pairs of Sun-creamsDefinite Significant DifferencePossible Significant DifferenceNo Significant Difference
Means of W and X{yn[0][0]}{yn[0][1]}{yn[0][2]}
Means of W and Y{yn[1][0]}{yn[1][1]}{yn[1][2]}
Means of W and Z{yn[2][0]}{yn[2][1]}{yn[2][2]}
Means of X and Y{yn[3][0]}{yn[3][1]}{yn[3][2]}
Means of X and Z{yn[4][0]}{yn[4][1]}{yn[4][2]}
Means of Y and Z{yn[5][0]}{yn[5][1]}{yn[5][2]}
"}], "name": "", "pickQuestions": 0}], "name": "Statistics for experimental psychology", "showQuestionGroupNames": false, "type": "question", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "Questions used in a university course titled \"Statistics for experimental psychology\""}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "extensions": ["stats"], "custom_part_types": [], "resources": []}