// Numbas version: finer_feedback_settings {"name": "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": [{"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.

", "functions": {"pstdev": {"parameters": [["l", "list"]], "type": "number", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "language": "jme"}, "marr": {"parameters": [["a", "list"]], "type": "number", "definition": "if(length(a)=2,max(a[0],a[1]),max(a[0],marr(a[1..length(a)])))", "language": "jme"}, "darr": {"parameters": [["n", "number"], ["m", "number"], ["a", "list"]], "type": "list", "definition": "if(n=1,a,darr(n-1,m,[random(1..m except a)]+a))", "language": "jme"}, "tesarr": {"parameters": [["a", "list"], ["b", "list"], ["d", "number"], ["m", "number"]], "type": "list", "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 ", "language": "javascript"}}, "ungrouped_variables": ["aspcoef", "spcoef", "vs", "sxy", "spxy", "tol", "ssq", "corrcoef", "ssd", "rr2", "rr1", "r1", "tsqovern", "obj", "d", "r2", "ss", "k", "m", "n", "t", "v"], "variablesTest": {"condition": "", "maxRuns": 100}, "name": "Derek's copy of Calculate Pearson correlation coefficient", "variables": {"obj": {"templateType": "anything", "group": "Ungrouped variables", "name": "obj", "definition": "['A','B','C','D','E','F','G','H','I','J']", "description": ""}, "sxy": {"templateType": "anything", "group": "Ungrouped variables", "name": "sxy", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "description": ""}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "name": "ss", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "description": ""}, "m": {"templateType": "anything", "group": "Ungrouped variables", "name": "m", "definition": "20", "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": ""}, "k": {"templateType": "anything", "group": "Ungrouped variables", "name": "k", "definition": "3", "description": ""}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "name": "tsqovern", "definition": "[t[0]^2/n,t[1]^2/n]", "description": ""}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "name": "r2", "definition": "tesarr(r1,darr(n,m,[random(1..m)]),11,m)", "description": ""}, "corrcoef": {"templateType": "anything", "group": "Ungrouped variables", "name": "corrcoef", "definition": "precround(spxy/sqrt(ss[0]*ss[1]),3)", "description": ""}, "rr2": {"templateType": "anything", "group": "Ungrouped variables", "name": "rr2", "definition": "rk(r2)", "description": ""}, "ssd": {"templateType": "anything", "group": "Ungrouped variables", "name": "ssd", "definition": "sum(map(x^2,x,d))", "description": ""}, "t": {"templateType": "anything", "group": "Ungrouped variables", "name": "t", "definition": "[sum(r1),sum(r2)]", "description": ""}, "spcoef": {"templateType": "anything", "group": "Ungrouped variables", "name": "spcoef", "definition": "precround(1-6*ssd/(n*(n^2-1)),3)", "description": ""}, "aspcoef": {"templateType": "anything", "group": "Ungrouped variables", "name": "aspcoef", "definition": "abs(spcoef)", "description": ""}, "n": {"templateType": "anything", "group": "Ungrouped variables", "name": "n", "definition": "10", "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": ""}, "spxy": {"templateType": "anything", "group": "Ungrouped variables", "name": "spxy", "definition": "sxy-t[0]*t[1]/n", "description": ""}, "d": {"templateType": "anything", "group": "Ungrouped variables", "name": "d", "definition": "list(vector(rr1)-vector(rr2))", "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": ""}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "name": "r1", "definition": "darr(n,m,[random(1..20)])", "description": ""}}, "tags": [], "variable_groups": [], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "extensions": ["stats"], "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

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

"}, "parts": [{"customMarkingAlgorithm": "", "showCorrectAnswer": true, "type": "gapfill", "variableReplacements": [], "gaps": [{"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "t[0]", "scripts": {}, "marks": 0.5, "extendBaseMarkingAlgorithm": true, "maxValue": "t[0]", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "ssq[0]", "scripts": {}, "marks": 0.5, "extendBaseMarkingAlgorithm": true, "maxValue": "ssq[0]", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "t[1]", "scripts": {}, "marks": 0.5, "extendBaseMarkingAlgorithm": true, "maxValue": "t[1]", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "ssq[1]", "scripts": {}, "marks": 0.5, "extendBaseMarkingAlgorithm": true, "maxValue": "ssq[1]", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "sxy", "scripts": {}, "marks": 0.5, "extendBaseMarkingAlgorithm": true, "maxValue": "sxy", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "ss[0]", "scripts": {}, "marks": 0.5, "extendBaseMarkingAlgorithm": true, "maxValue": "ss[0]", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "ss[1]", "scripts": {}, "marks": 0.5, "extendBaseMarkingAlgorithm": true, "maxValue": "ss[1]", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "spxy", "scripts": {}, "marks": 0.5, "extendBaseMarkingAlgorithm": true, "maxValue": "spxy", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "corrcoef-tol", "scripts": {}, "marks": 1, "extendBaseMarkingAlgorithm": true, "maxValue": "corrcoef+tol", "unitTests": []}], "variableReplacementStrategy": "originalfirst", "sortAnswers": false, "showFeedbackIcon": 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": {}, "marks": 0, "extendBaseMarkingAlgorithm": true, "unitTests": []}, {"customMarkingAlgorithm": "", "showCorrectAnswer": true, "type": "gapfill", "variableReplacements": [], "gaps": [{"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "0.549", "scripts": {}, "marks": 0.25, "extendBaseMarkingAlgorithm": true, "maxValue": "0.549", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "0.632", "scripts": {}, "marks": 0.25, "extendBaseMarkingAlgorithm": true, "maxValue": "0.632", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "0.765", "scripts": {}, "marks": 0.25, "extendBaseMarkingAlgorithm": true, "maxValue": "0.765", "unitTests": []}, {"customMarkingAlgorithm": "", "mustBeReducedPC": 0, "showCorrectAnswer": true, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showFeedbackIcon": true, "minValue": "0.847", "scripts": {}, "marks": 0.25, "extendBaseMarkingAlgorithm": true, "maxValue": "0.847", "unitTests": []}, {"customMarkingAlgorithm": "", "showCorrectAnswer": true, "type": "1_n_2", "matrix": "v", "maxMarks": 0, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "displayType": "radiogroup", "showFeedbackIcon": true, "scripts": {}, "marks": 0, "displayColumns": 1, "extendBaseMarkingAlgorithm": true, "shuffleChoices": false, "minMarks": 0, "unitTests": [], "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."]}], "variableReplacementStrategy": "originalfirst", "sortAnswers": false, "showFeedbackIcon": 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": {}, "marks": 0, "extendBaseMarkingAlgorithm": true, "unitTests": []}], "preamble": {"css": "", "js": ""}, "advice": "

The answers to all parts are given on revealing.

", "type": "question", "contributors": [{"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": "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/"}]}