// 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.
\nCouple | \n$\\var{obj[0]}$ | \n$\\var{obj[1]}$ | \n$\\var{obj[2]}$ | \n$\\var{obj[3]}$ | \n$\\var{obj[4]}$ | \n$\\var{obj[5]}$ | \n$\\var{obj[6]}$ | \n$\\var{obj[7]}$ | \n$\\var{obj[8]}$ | \n$\\var{obj[9]}$ | \n
---|---|---|---|---|---|---|---|---|---|---|
Wife $(X)$ | \n$\\var{r1[0]}$ | \n$\\var{r1[1]}$ | \n$\\var{r1[2]}$ | \n$\\var{r1[3]}$ | \n$\\var{r1[4]}$ | \n$\\var{r1[5]}$ | \n$\\var{r1[6]}$ | \n$\\var{r1[7]}$ | \n$\\var{r1[8]}$ | \n$\\var{r1[9]}$ | \n
Husband $(Y)$ | \n$\\var{r2[0]}$ | \n$\\var{r2[1]}$ | \n$\\var{r2[2]}$ | \n$\\var{r2[3]}$ | \n$\\var{r2[4]}$ | \n$\\var{r2[5]}$ | \n$\\var{r2[6]}$ | \n$\\var{r2[7]}$ | \n$\\var{r2[8]}$ | \n$\\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.
\nThe 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))))Wife $(X)$ | \n$\\sum x=\\;$[[0]] | \n$\\sum x^2=\\;$[[1]] | \n
---|---|---|
Husband $(Y)$ | \n$\\sum y=\\;$[[2]] | \n$\\sum y^2=\\;$[[3]] | \n
Also find $\\sum xy=\\;$[[4]] and then:
\n$\\displaystyle SSX = \\;$[[5]]
\n$\\displaystyle SSY = \\;$[[6]]
\n$\\displaystyle SPXY = \\;$[[7]]
\nHence 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$10\\%$ | \n$5\\%$ | \n$1\\%$ | \n$0.2\\%$ | \n
[[0]] | \n[[1]] | \n[[2]] | \n[[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/"}]}