// Numbas version: finer_feedback_settings {"duration": 900, "navigation": {"startpassword": "", "allowregen": true, "preventleave": true, "showresultspage": "oncompletion", "reverse": true, "onleave": {"message": "", "action": "none"}, "allowsteps": true, "browse": true, "showfrontpage": true}, "name": "First test", "showQuestionGroupNames": false, "metadata": {"licence": "None specified", "description": ""}, "timing": {"timedwarning": {"message": "", "action": "none"}, "allowPause": true, "timeout": {"message": "", "action": "none"}}, "showstudentname": true, "feedback": {"intro": "", "showactualmark": true, "showanswerstate": true, "feedbackmessages": [], "advicethreshold": 0, "allowrevealanswer": true, "showtotalmark": true, "enterreviewmodeimmediately": true, "showexpectedanswerswhen": "inreview", "showpartfeedbackmessageswhen": "always", "showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showadvicewhen": "never"}, "percentPass": "0", "question_groups": [{"pickingStrategy": "all-ordered", "pickQuestions": 1, "name": "Group", "questions": [{"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}$
\nThen $\\displaystyle a = \\frac{1}{10}\\left[\\sum y-b \\sum x\\right]$
\nNow 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).
\nYou are given the following information:
\nFirst Test$(X)$ | \n$\\sum x=\\;\\var{t[0]}$ | \n$\\sum x^2=\\;\\var{ssq[0]}$ | \n
---|---|---|
Later Score$(Y)$ | \n$\\sum y=\\;\\var{t[1]}$ | \n$\\sum y^2=\\;\\var{ssq[1]}$ | \n
Also you are given $\\sum xy = \\var{sxy}$.
\nClick 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]}$?
Use the values of $a$ and $b$ you input above.
\nEnter 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:
\nRESIDUAL = OBSERVED - FITTED.
\nIn 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]}$.
\nClick 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.
\nResidual 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:
\nEmployee | $\\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)$ | \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
Later Score $(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
30/09/2102:
\n \t\tIntroduced three functions:
\n \t\t1. To produce the ranking of a list of 8 numbers.
\n \t\t2. To produce a list of 8 numbers from a scale of 1..20 which are all distinct.
\n \t\t3. To produce the maximum of the numbers in a list.
\n \t\t4. 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": "Find regression equation and correlation coefficient, ", "extensions": ["stats", "jsxgraph"], "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": "[random(0..6),random(1..7),random(4..10),random(7..13),random(12..18),random(4..20),random(16..22),random(19..25),random(17..23),random(13..19),random(8..14),random(3..9)]", "description": "", "name": "r1"}, "spxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sxy-t[0]*t[1]/n", "description": "", "name": "spxy"}, "a": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(1/n*(t[1]-spxy/ss[0]*t[0]),3)", "description": "", "name": "a"}, "tcorr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "spxy/sqrt(ss[0]*ss[1])", "description": "", "name": "tcorr"}, "ssq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2))]", "description": "", "name": "ssq"}, "prediction": {"templateType": "anything", "group": "Ungrouped variables", "definition": "round(a+b*thisval)", "description": "", "name": "prediction"}, "t": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[sum(r1),sum(r2)]", "description": "", "name": "t"}, "a1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(10..20)", "description": "", "name": "a1"}, "sumr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sum(map(res[x]^2,x,0..n-1)),3)", "description": "", "name": "sumr"}, "tol1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0.01", "description": "", "name": "tol1"}, "beverage": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(\"home-brewed beer\",\"home-brewed lager\",\"specially-brewed beer\",\"super-strength lager\",\"cold-filtered lager\",\"ice-filtered cider\",\"cherry cider\")", "description": "", "name": "beverage"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "12", "description": "", "name": "n"}, "ss": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[ssq[0]-t[0]^2/n,ssq[1]-t[1]^2/n]", "description": "", "name": "ss"}, "corr": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(tcorr,2)", "description": "", "name": "corr"}, "b": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spxy/ss[0],3)", "description": "", "name": "b"}, "pub": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(\"Black Bull Inn\",\"County Inn\",\"Dog and Duck Pub\",\"Slug and Lettuce Pub\", \"Cross Keys Pub\",\"Newcastle Arms Pub\",\"Red Lion Pub\")", "description": "", "name": "pub"}, "res": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(precround(r2[x]-(a+b*r1[x]),2),x,0..n-1)", "description": "", "name": "res"}, "ch": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0..11)", "description": "", "name": "ch"}, "sc": {"templateType": "anything", "group": "Ungrouped variables", "definition": "r1[ch]", "description": "", "name": "sc"}, "b1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0.25..0.45#0.05)", "description": "", "name": "b1"}, "sxy": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sum(map(r1[x]*r2[x],x,0..n-1))", "description": "", "name": "sxy"}, "thisval": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(15..22)", "description": "", "name": "thisval"}, "obj": {"templateType": "anything", "group": "Ungrouped variables", "definition": "['Jan','Feb','March','April','May','June','July','August','Sept','Oct','Nov','Dec']", "description": "", "name": "obj"}, "owner": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(\"Kevin\",\"Mary\",\"Bill\",\"Doreen\",\"Peter\",\"Helen\",\"Michael\",\"Samantha\")", "description": "", "name": "owner"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "map(round(a1+b1*x+random(-9..9)),x,r1)", "description": "", "name": "r2"}, "ls": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(a+b*sc,2)", "description": "", "name": "ls"}, "tsqovern": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[t[0]^2/n,t[1]^2/n]", "description": "", "name": "tsqovern"}, "rsquared": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(spxy^2/(ss[0]*ss[1]),3)", "description": "", "name": "rsquared"}}, "ungrouped_variables": ["ch", "prediction", "b1", "owner", "sxy", "res", "spxy", "ls", "tol", "tcorr", "a", "ssq", "sumr", "pub", "a1", "thisval", "corr", "tsqovern", "b", "obj", "r1", "r2", "ss", "tol1", "n", "beverage", "t", "sc", "rsquared"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {"regressline": {"type": "html", "language": "javascript", "definition": "\n var div = Numbas.extensions.jsxgraph.makeBoard('600px','600px',\n{boundingBox:[-5,maxy,maxx,-5],\n axis:true,\n showNavigation:false,\n grid:false});\n var board = div.board; \nvar l1=board.create('text',[maxx/2,-2,'Temperature']);\nvar l2=board.create('text',[-2,maxy/2,'Sales']);\nvar names = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];\nfor (j=0;j<12;j++){ board.create('point',[r1[j],r2[j]],{fixed:true, style:3,name:'\\\\\\\\['+names[j]+'\\\\\\\\]'})};\nvar a1 = board.create('point',[minx+5,miny+5],{color:'blue'});\nvar b1 = board.create('point',[minx+7,miny+5],{color:'blue'});\nfunction updr(a,b){\n var s=0;\n for(var i=0;i<12;i++){\ns=s+Math.pow(r2[i]-a*r1[i]-b,2);}\ns=Numbas.math.niceNumber(Numbas.math.precround(s,2));\n$('#rsquared').text(s);}\n var li=board.create('line',[a1,b1], {straightFirst:false, straightLast:false});\n var a=0;\n var b=0;\n function dr(p){\n p.on('drag',function(){\n a = Numbas.math.niceNumber((b1.Y()-a1.Y())/(b1.X()-a1.X()));\n b = Numbas.math.niceNumber((a1.Y()*b1.X()-a1.X()*b1.Y())/(b1.X()-a1.X()));\n Numbas.exam.currentQuestion.parts[1].gaps[0].display.studentAnswer(a);\n Numbas.exam.currentQuestion.parts[1].gaps[1].display.studentAnswer(b);\n updr(a,b);\n })};\n dr(a1);\n dr(b1);\n \nreturn div;\n\n \n", "parameters": [["r1", "list"], ["r2", "list"], ["minx", "number"], ["maxx", "number"], ["miny", "number"], ["maxy", "number"]]}, "regfun": {"type": "html", "language": "javascript", "definition": "\n var div = Numbas.extensions.jsxgraph.makeBoard('600px','600px',\n{boundingBox:[-5,maxy,maxx,-5],\n axis:true,\n showNavigation:false,\n grid:true});\n var board = div.board; \nvar l1=board.create('text',[maxx/2,-2,'Temperature']);\nvar l2=board.create('text',[-2,maxy/2,'Sales']);\n var names = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];\n for (j=0;j<12;j++){ board.create('point',[r1[j],r2[j]],{fixed:true, style:3, strokecolor:\"#0000a0\", name:'\\\\\\\\['+names[j]+'\\\\\\\\]'})};\nvar regressionPolynomial = JXG.Math.Numerics.regressionPolynomial(1, r1, r2);\nvar reg = board.create('functiongraph',[regressionPolynomial],{strokeColor:'blue',name:'Regression Line.',withLabel:true}); \n //for(var i=0;i<12;i++){board.create(\"segment\",[[r1[i],r2[i]],[r1[i],regressionPolynomial(r1[i])]])};\nvar regExpression = regressionPolynomial.getTerm();\nvar regTeX = Numbas.jme.display.exprToLaTeX(regExpression,[],scope);\n\n//var t = board.create('text',[1,5,\n//function(){ return \"\\\\[r(Y) = \" + regExpression +'\\\\]';}\n//],\n//{strokeColor:'black',fontSize:18}); \n\nreturn div;\n \n", "parameters": [["r1", "list"], ["r2", "list"], ["maxx", "number"], ["maxy", "number"], ["rsquared", "number"], ["sumr", "number"]]}}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "corr+tol1", "minValue": "corr-tol1", "correctAnswerFraction": false, "marks": 4, "showPrecisionHint": false}], "type": "gapfill", "prompt": "Calculate the sample correlation coefficient $r$ for these data:
\n$r=\\;$[[0]] (enter to 2 decimal places).
", "showCorrectAnswer": true, "marks": 0}, {"stepsPenalty": 0, "scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "b+tol", "minValue": "b-tol", "correctAnswerFraction": false, "marks": 2, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "a+tol", "minValue": "a-tol", "correctAnswerFraction": false, "marks": 2, "showPrecisionHint": false}], "type": "gapfill", "prompt": "Calculate the equation of the best fitting regression line.
\n\\[Y = \\alpha + \\beta X.\\] Find $\\alpha$ and $\\beta$ 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=\\;$[[0]], $\\alpha=\\;$[[1]] (enter both to 3 decimal places).
\n\nClick on Show steps if you want more information on calculating $\\alpha$ and $\\beta$. You will not lose any marks by doing so.
\n", "steps": [{"type": "information", "prompt": "
To find $\\alpha$ and $\\beta$ you first find $\\displaystyle \\beta = \\frac{S_{XY}}{S_{XX}}$ where:
\n$\\displaystyle S_{XY}=\\sum xy - n\\overline{x}\\overline{y}$
\n$\\displaystyle S_{XX}=\\sum x^2 - n\\overline{x}^2$
\nThen $\\displaystyle \\alpha = \\overline{y}-\\beta \\overline{x}$
\nNow go back and fill in the values for $\\alpha$ and $\\beta$.
", "showCorrectAnswer": true, "scripts": {}, "marks": 0}], "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "prediction+1", "minValue": "prediction-1", "correctAnswerFraction": false, "marks": 2, "showPrecisionHint": false}], "type": "gapfill", "prompt": "Next month, the average temperature in {owner}'s town is forecast to be $\\var{thisval}^{\\small o}$C. Use the regression equation in the second part to predict sales of the {beverage} in that month.
\nWhat is the predicted value of sales (in hundreds of pounds) ?
\nUse the values of $\\alpha$ and $\\beta$ you input above to 3 decimal places.
\nEnter the predicted sales here: [[0]] (hundreds of pounds to the nearest whole number).
\n", "showCorrectAnswer": true, "marks": 0}], "statement": "{owner} owns the {pub}. {owner} believes that sales of {beverage} in the pub are linked to the average monthly temperature, with higher sales being recorded in months with higher temperatures. To investigate, {owner} records the average monthly temperature in the local town over a period of one year ($X$ degrees Celsius), along with total monthly sales of {beverage} ($Y$ hundred pounds). The results are shown in the table below:
\nMonth | $\\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]}$ | $\\var{obj[10]}$ | $\\var{obj[11]}$ |
---|---|---|---|---|---|---|---|---|---|---|---|---|
$X$ (temperature) | \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$\\var{r1[10]}$ | \n$\\var{r1[11]}$ | \n
$Y$ (sales, £100s) | \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$\\var{r2[10]}$ | \n$\\var{r2[11]}$ | \n
You are given the following information:
\n$X$ | \n$\\sum x=\\;\\var{t[0]}$ | \n$\\sum x^2=\\;\\var{ssq[0]}$ | \n
---|---|---|
$Y$ | \n$\\sum y=\\;\\var{t[1]}$ | \n$\\sum y^2=\\;\\var{ssq[1]}$ | \n
Also you are given $\\sum xy = \\var{sxy}$.
", "tags": ["ACC1012", "checked2015", "correlation", "data analysis", "fitted value", "linear regression", "MAS1043", "regression", "statistics"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "04/02/2014:
\nNo advice as yet. Adapted from iassess question for ACE.
\n18/02/2014:
\nSlight changes in notation from Regression 3. No SSE
", "licence": "Creative Commons Attribution 4.0 International", "description": "Find a regression equation given 12 months data on temperature and sales of a drink.
"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "For part a) you calculate $r$ using:
\n\\[r=\\frac{S_{XY}}{\\sqrt{S_{XX} \\times S_{YY}}}\\] where :
\n$\\displaystyle S_{XY}=\\sum xy - n\\overline{x}\\overline{y}$
\n$\\displaystyle S_{XX}=\\sum x^2 - n\\overline{x}^2$
\n$\\displaystyle S_{YY}=\\sum y^2 - n\\overline{y}^2$
\nFor part b): The regression line has equation:
\n$\\simplify[all,!collectNumbers]{Y={a}+{b}X}$ and this is displayed below:
\n\n{regfun(r1,r2,max(r1)+10,max(r2)+10,rsquared,sumr)}
\nFor part c):
\nPredicted sales whem $X=\\var{thisval}^{\\small o}$C:
\n\\[\\begin{align} Y&=\\simplify[all,!collectNumbers]{{a}+{b}* {thisval}}\\\\
&=\\var{{a+b*thisval}}\\\\
&=\\var{prediction}
\\end{align}\\] to nearest whole number of hundreds of pounds.
$X_1$
", "$X_2$
", "$X_3$
"], "displayColumns": 0, "distractors": ["", "", ""], "shuffleChoices": true, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "showCorrectAnswer": true, "matrix": [0, 0, 1], "marks": 0}], "type": "gapfill", "prompt": "Which of these variables is an indicator variable?
\n[[0]]
", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ansa+tol", "minValue": "ansa-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ansb+tol", "minValue": "ansb-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ansc+tol", "minValue": "ansc-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ansd+tol", "minValue": "ansd-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ansa+tol", "minValue": "ansa-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ansc+tol", "minValue": "ansc-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ansd+tol", "minValue": "ansd-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "si+tol", "minValue": "si-tol", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "Based on a recent survey of some of the restaurants in the North-East, the following (edited) Minitab output was obtained:
\nRegression Analysis: $y$ versus $x_1,\\;x_2,\\;x_3$
\nThe regression equation is: y = ********
\n\n\n Predictor \n | \n Coef \n | \n SE Coef \n | \n T \n | \n P \n |
---|---|---|---|---|
\n Constant \n | \n\n $A$ \n | \n\n {sea} \n | \n\n 3.887 \n | \n\n 0.002$ \n | \n
\n $x_1$ \n | \n\n {cb} \n | \n\n $B$ \n | \n\n -2.64 \n | \n\n 0.021 \n | \n
\n $x_2$ \n | \n\n $C$ \n | \n\n {se} \n | \n\n 3.82 \n | \n\n 0.002 \n | \n
\n $x_3$ \n | \n\n $D$ \n | \n\n {sed} \n | \n\n 2.53 \n | \n\n 0.024 \n | \n
s={sval} R-sq= 92.1% R-Sq(adj)=93.9%
\n(i) Find the values of $A,\\;B,\\;C$ and $D$ to 3 decimal places.
\n$A=\\;$[[0]], $B=\\;$[[1]]
\n$C=\\;$[[2]], $D=\\;$[[3]]
\n(ii) Write down the full fitted regression equation:
\n\\[Y = \\beta_0+ \\beta_1 X_1 + \\beta_2 X_2 + \\beta_3X_3 + \\epsilon,\\;\\;\\epsilon \\sim N(0,\\sigma^2)\\]
\n$Y=\\;$[[4]]-$\\var{abs(cb)}X_1$+[[5]]$X_2$+[[6]]$X_3+\\epsilon$
\nNote that you are given the coefficient of $X_1$ from the Minitab table.
\nAlso find $\\sigma^2=\\;$[[7]] to 3 decimal places where $\\epsilon \\sim N(0,\\sigma^2)$
", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "pred+0.1", "minValue": "pred-0.1", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "Predict sales for a restaurant with {thatmany} competitors, a population of {thismany} within 1 kilometre and that {hascond}.
\nEnter the predicted value to one decimal place:
\n$Y=\\;$[[0]]
", "showCorrectAnswer": true, "marks": 0}, {"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "maxValue": "ind-1", "minValue": "ind-1", "correctAnswerFraction": false, "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "prompt": "It is thought that a fourth variable - customer satisfaction based on a recent survey - could also be a predictor of sales.
\nEach of the restaurants was given an overall satisfaction rating by choosing one of the following in the survey:
\n{sv[0]} {sv[1]} {sv[2]} {sv[3]} {sv[4]} {sv[5]}
\nHow many indicator variables would need to be used here?: [[0]]
", "showCorrectAnswer": true, "marks": 0}], "statement": "The management at {thisrest} propose the following model to predict sales Y at their {place} branch.
\n\\[Y = \\beta_0+ \\beta_1 X_1 + \\beta_2 X_2 + \\beta_3X_3 + \\epsilon\\]
\nwhere
\n$X_1=\\;$number of competitors within one kilometre.
\n$X_2=\\;$population within one kilometre (in 1000s).
\n$X_3=\\;$ 1 if {cond}, 0 otherwise.
", "tags": ["ACE2013", "checked2015", "indicator variables", "minitab output", "multiple regression", "regression", "regression equation", "statistics"], "rulesets": {}, "preamble": {"css": ".minitab {\nfont-family: 'Courier', monospace;\n}", "js": ""}, "type": "question", "metadata": {"notes": "09/02/2014:
\nFirst draft. Based on an i-assess question for ACE.
", "licence": "Creative Commons Attribution 4.0 International", "description": "Asking users to interpret a minitab output to give the coefficients of a multiple regression together with a prediction based on the subsequent equation.
"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "a) $X_3$ is the indicator variable.
\nb)
\n\n(i) The values of A, B, C and D are given by:
\nA = 3.887 x SE Coef (A) = 3.887 x {sea} = {ansa} to 3 decimal places.
\nB = Coef (B)/-2.64 = {cb}/-2.64 = {ansb} to 3 decimal places.
\nC = 3.82 x SE Coef (C) = 3.82 x {se} = {ansc} to 3 decimal places.
\nD = 2.53 x SE Coef (D) = 2.53 x {sed} = {ansd} to 3 decimal places.
\nii) The fitted regression equation is:
\n\\[Y=\\var{ansa}-\\var{abs(cb)}X_1+\\var{ansc}X_2+\\var{ansd}X_3+\\epsilon\\] with $\\sigma^2=\\var{sval}^2=\\var{si}$ all to 3 decimal places.
\nc)
\n\nUsing the above fitted model where $X_1=\\var{thatmany}$ and $X_2= \\frac{\\var{thismany}}{1000}=\\var{thismany/1000}$ and since $X_3=\\var{q}$ as the restaurant {hascond} we find :
\n\\[Y=\\var{ansa}-\\var{abs(cb)}\\times \\var{thatmany}+\\var{ansc}\\times \\var{thismany/1000}+\\var{ansd}\\times \\var{q}=\\var{pred}\\] to one decimal place.
\nd)
\nThere are {ind} categories in the survey and so the number of indicator variables is {ind}-1={ind-1}.
"}, {"name": "Multiple linear regression - decide which variable to exclude", "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/"}, {"name": "Lauren Frances Desoysa", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2490/"}], "type": "question", "rulesets": {}, "metadata": {"notes": "09/02/2014:
\nFirst draft finished.
", "licence": "Creative Commons Attribution 4.0 International", "description": "A multiple linear regression model of the form:
\n\\[Y=\\beta_0+\\beta_1X_1+ \\beta_2X_2+\\beta_3X_3+\\beta_4X_4+\\epsilon \\]
\nis fitted to some data in Minitab which generates a table showing estimates of the parameters with associated $p$-values. Determine which variable to exclude first.
"}, "statement": "A multiple linear regression model of the form:
\n\\[Y=\\beta_0+\\beta_1X_1+ \\beta_2X_2+\\beta_3X_3+\\beta_4X_4+\\epsilon \\]
\nis fitted to some data in Minitab. The following table shows estimates of the parameters with associated $p$-values.
\nYou would choose to exclude the predictor variable which had the largest p-value.
\nIn this example we see that $X_{\\var{v}}$ has the largest $p$-value $\\var{m}$ and and we would exclude it as $\\var{m}>0.05$.
\n", "functions": {"findinlist": {"language": "javascript", "type": "number", "definition": "var r=0;\nfor(j=0;j < l.length;j++)\n {if(l[j]==m){r=j;}\n }\nreturn r;", "parameters": [["l", "list"], ["m", "number"]]}}, "showQuestionGroupNames": false, "variable_groups": [], "preamble": {"css": "/* left-align variables */\n#table td:first-child, #table th:first-child {\n text-align: center;\n}", "js": ""}, "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"p4": {"templateType": "anything", "name": "p4", "definition": "random(0.005..0.2#0.001 except [p0,p1,p2,p3])", "description": "", "group": "Ungrouped variables"}, "data": {"templateType": "anything", "name": "data", "definition": "[[\"$\\\\beta_0$\",random(8..20#0.001),p0],[\"$\\\\beta_1$\",random(-8..-1#0.001),p1],\n [\"$\\\\beta_2$\",random(4..9#0.001),p2],[\"$\\\\beta_3$\",random(2..10#0.001),p3],\n [\"$\\\\beta_4$\",random(1..15#0.001),p4]]", "description": "", "group": "Ungrouped variables"}, "p3": {"templateType": "anything", "name": "p3", "definition": "random(0.005..0.2#0.001 except [p0,p1,p2])", "description": "", "group": "Ungrouped variables"}, "m": {"templateType": "anything", "name": "m", "definition": "max(p)", "description": "", "group": "Ungrouped variables"}, "v": {"templateType": "anything", "name": "v", "definition": "findinlist(p,m)+1", "description": "", "group": "Ungrouped variables"}, "p2": {"templateType": "anything", "name": "p2", "definition": "random(0.01..0.6#0.001 except [p0,p1])", "description": "", "group": "Ungrouped variables"}, "mm": {"templateType": "anything", "name": "mm", "definition": "map(if(p[j]=m,1,0),j,0..3)", "description": "", "group": "Ungrouped variables"}, "p1": {"templateType": "anything", "name": "p1", "definition": "random(0.005..0.3#0.001 except p0)", "description": "", "group": "Ungrouped variables"}, "p0": {"templateType": "anything", "name": "p0", "definition": "random(0.005..0.03#0.001)", "description": "", "group": "Ungrouped variables"}, "p": {"templateType": "anything", "name": "p", "definition": "[p1,p2,p3,p4]", "description": "", "group": "Ungrouped variables"}}, "ungrouped_variables": ["p2", "p3", "p0", "p1", "p4", "mm", "m", "p", "v", "data"], "tags": ["ACE2013", "checked2015"], "parts": [{"showCorrectAnswer": true, "type": "1_n_2", "maxMarks": 0, "displayColumns": 0, "displayType": "radiogroup", "scripts": {}, "matrix": "mm", "prompt": "Which predictor variable would you exclude from the model before re-fitting in Minitab?
", "distractors": ["", "", "", ""], "marks": 0, "minMarks": 0, "shuffleChoices": false, "choices": ["$X_1$
", "$X_2$
", "$X_3$
", "$X_4$
"]}]}]}], "type": "exam", "contributors": [{"name": "Mike Smet", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3991/"}], "extensions": ["jsxgraph", "stats"], "custom_part_types": [], "resources": []}