// Numbas version: finer_feedback_settings {"name": "Michael's copy of Derek's copy of Calculate Pearson correlation coefficient", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "tags": [], "variables": {"r1": {"templateType": "anything", "group": "Ungrouped variables", "name": "r1", "definition": "darr(n,m,[random(1..20)])", "description": ""}, "sxy": {"templateType": "anything", "group": "Ungrouped variables", "name": "sxy", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "description": ""}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "name": "tsqovern", "definition": "[t[0]^2/n,t[1]^2/n]", "description": ""}, "corrcoef": {"templateType": "anything", "group": "Ungrouped variables", "name": "corrcoef", "definition": "precround(spxy/sqrt(ss[0]*ss[1]),3)", "description": ""}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "name": "ssq", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "description": ""}, "vs": {"templateType": "anything", "group": "Ungrouped variables", "name": "vs", "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": ""}, "ssd": {"templateType": "anything", "group": "Ungrouped variables", "name": "ssd", "definition": "sum(map(x^2,x,d))", "description": ""}, "rr2": {"templateType": "anything", "group": "Ungrouped variables", "name": "rr2", "definition": "rk(r2)", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "name": "t", "definition": "[sum(r1),sum(r2)]", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "name": "n", "definition": "10", "description": ""}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "name": "ss", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "description": ""}, "k": {"templateType": "anything", "group": "Ungrouped variables", "name": "k", "definition": "3", "description": ""}, "v": {"templateType": "anything", "group": "Ungrouped variables", "name": "v", "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": ""}, "d": {"templateType": "anything", "group": "Ungrouped variables", "name": "d", "definition": "list(vector(rr1)-vector(rr2))", "description": ""}, "aspcoef": {"templateType": "anything", "group": "Ungrouped variables", "name": "aspcoef", "definition": "abs(spcoef)", "description": ""}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "name": "r2", "definition": "tesarr(r1,darr(n,m,[random(1..m)]),11,m)", "description": ""}, "spcoef": {"templateType": "anything", "group": "Ungrouped variables", "name": "spcoef", "definition": "precround(1-6*ssd/(n*(n^2-1)),3)", "description": ""}, "spxy": {"templateType": "anything", "group": "Ungrouped variables", "name": "spxy", "definition": "sxy-t[0]*t[1]/n", "description": ""}, "obj": {"templateType": "anything", "group": "Ungrouped variables", "name": "obj", "definition": "['A','B','C','D','E','F','G','H','I','J']", "description": ""}, "m": {"templateType": "anything", "group": "Ungrouped variables", "name": "m", "definition": "20", "description": ""}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "name": "tol", "definition": "0.001", "description": ""}, "rr1": {"templateType": "anything", "group": "Ungrouped variables", "name": "rr1", "definition": "rk(r1)", "description": ""}}, "ungrouped_variables": ["aspcoef", "spcoef", "vs", "sxy", "spxy", "tol", "ssq", "corrcoef", "ssd", "rr2", "rr1", "r1", "tsqovern", "obj", "d", "r2", "ss", "k", "m", "n", "t", "v"], "statement": "

Please print and refer to the coding sheet if you wish.

\n\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\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.

", "extensions": ["stats"], "advice": "

The answers to all parts are given on revealing.

", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "preamble": {"js": "", "css": ""}, "functions": {"pstdev": {"language": "jme", "parameters": [["l", "list"]], "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "type": "number"}, "darr": {"language": "jme", "parameters": [["n", "number"], ["m", "number"], ["a", "list"]], "definition": "if(n=1,a,darr(n-1,m,[random(1..m except a)]+a))", "type": "list"}, "tesarr": {"language": "jme", "parameters": [["a", "list"], ["b", "list"], ["d", "number"], ["m", "number"]], "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;\n ", "type": "list"}, "marr": {"language": "jme", "parameters": [["a", "list"]], "definition": "if(length(a)=2,max(a[0],a[1]),max(a[0],marr(a[1..length(a)])))", "type": "number"}}, "parts": [{"gaps": [{"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "t[0]", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "t[0]", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.5, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "ssq[0]", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "ssq[0]", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.5, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "t[1]", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "t[1]", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.5, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "ssq[1]", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "ssq[1]", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.5, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "sxy", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "sxy", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.5, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "ss[0]", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "ss[0]", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.5, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "ss[1]", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "ss[1]", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.5, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "spxy", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "spxy", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.5, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "corrcoef+tol", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "corrcoef-tol", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 1, "customMarkingAlgorithm": "", "type": "numberentry"}], "extendBaseMarkingAlgorithm": true, "prompt": "\n \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

 

\n ", "scripts": {}, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false, "customMarkingAlgorithm": "", "type": "gapfill"}, {"gaps": [{"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "0.549", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "0.549", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.25, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "0.632", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "0.632", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.25, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "0.765", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "0.765", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.25, "customMarkingAlgorithm": "", "type": "numberentry"}, {"allowFractions": false, "correctAnswerStyle": "plain", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "scripts": {}, "maxValue": "0.847", "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "minValue": "0.847", "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 0.25, "customMarkingAlgorithm": "", "type": "numberentry"}, {"minMarks": 0, "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."], "scripts": {}, "shuffleChoices": false, "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "variableReplacements": [], "showCorrectAnswer": true, "displayColumns": 1, "maxMarks": 0, "marks": 0, "matrix": "v", "customMarkingAlgorithm": "", "type": "1_n_2"}], "extendBaseMarkingAlgorithm": true, "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 ", "scripts": {}, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "unitTests": [], "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false, "customMarkingAlgorithm": "", "type": "gapfill"}], "name": "Michael's copy of Derek's copy of Calculate Pearson correlation coefficient", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

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

"}, "type": "question", "contributors": [{"name": "Michael Proudman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/269/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Derek Hunt", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2889/"}]}]}], "contributors": [{"name": "Michael Proudman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/269/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Derek Hunt", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2889/"}]}