// 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}$

\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": "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

\n

Click 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$

\n

Then $\\displaystyle \\alpha = \\overline{y}-\\beta \\overline{x}$

\n

Now 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.

\n

What is the predicted value of sales (in hundreds of pounds) ?

\n

Use the values of $\\alpha$ and $\\beta$ you input above to 3 decimal places.

\n

Enter 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: 

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Month$\\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)$\\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]}$
$Y$ (sales, £100s)$\\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

You are given the following information:

\n\n\n\n\n\n\n\n\n\n\n\n
$X$ $\\sum x=\\;\\var{t[0]}$$\\sum x^2=\\;\\var{ssq[0]}$
$Y$$\\sum y=\\;\\var{t[1]}$$\\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:

\n

No advice as yet. Adapted from iassess question for ACE.

\n

18/02/2014:

\n

Slight 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$

\n

For 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)}

\n

For part c):

\n

Predicted 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.

"}, {"name": "Interpret Minitab output of multiple regression", "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.001", "description": "", "name": "tol"}, "pred": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(ansa +cb*thatmany+ansc*thismany/1000+ansd*q,1)", "description": "", "name": "pred"}, "thismany": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(5000..12000#1000)", "description": "", "name": "thismany"}, "thatmany": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..8)", "description": "", "name": "thatmany"}, "thisrest": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(\"McDonald's\",\"Pizza Hut\",\"Kentucky Fried Chicken\",\"The Log Fire Pizza Co.\",\"The China Cook\",\"Aneesa's Indian Buffet\",\"Pacino's Italian Restaurant\")", "description": "", "name": "thisrest"}, "sv": {"templateType": "anything", "group": "Ungrouped variables", "definition": "[if(ind=6,\"Rubbish\",\" \"),\"Below Average\",\"Average\",\"Above Average\",\n if(ind=3,\" \",\"Good\"),if(ind>4,\"Fantastic\",\" \")]", "description": "", "name": "sv"}, "hascond": {"templateType": "anything", "group": "Ungrouped variables", "definition": "switch(q=1,cond,\n p=0,\"has not got a drive-thru window\",\n p=1,\"is not open late (after 11pm)\",\n p=2,\"is not located on a public transport route\",\n \"is not located in a town centre\")", "description": "", "name": "hascond"}, "se": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0.03..0.15#0.0001)", "description": "", "name": "se"}, "si": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(sval^2,3)", "description": "", "name": "si"}, "place": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(\"South Shields\", \"North Shields\",\"Newcastle\",\"Sunderland\",\"Alnwick\",\"Durham\",\"Metro Centre\")", "description": "", "name": "place"}, "p": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0,1,2,3)", "description": "", "name": "p"}, "ansd": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(2.53*sed,3)", "description": "", "name": "ansd"}, "q": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0,1)", "description": "", "name": "q"}, "sea": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3..5.5#0.001)", "description": "", "name": "sea"}, "ansa": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(3.887*sea,3)", "description": "", "name": "ansa"}, "sed": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..2.20#0.001)", "description": "", "name": "sed"}, "cb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(-0.5..-0.1#0.0001)", "description": "", "name": "cb"}, "cond": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(p=0,\"has got a drive-thru window\" ,if(p=1,\"is open late (after 11pm)\",if(p=2,\"is located on a public transport route\",\"is located in a town centre\")))", "description": "", "name": "cond"}, "ansc": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(3.82*se,3)", "description": "", "name": "ansc"}, "ansb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(abs(cb)/2.64,3)", "description": "", "name": "ansb"}, "ind": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3,4,5,6)", "description": "", "name": "ind"}, "sval": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(0.2..0.9#0.000001)", "description": "", "name": "sval"}}, "ungrouped_variables": ["cb", "sed", "cond", "sea", "ind", "pred", "sval", "tol", "thisrest", "thismany", "ansa", "ansb", "ansc", "ansd", "thatmany", "sv", "hascond", "q", "p", "si", "place", "se"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"displayType": "radiogroup", "choices": ["

$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:

\n

Regression Analysis: $y$ versus $x_1,\\;x_2,\\;x_3$

\n

The regression equation is: y = ********

\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n

Predictor

\n
\n

Coef

\n
\n

SE Coef

\n
\n

T

\n
\n

P

\n
\n

Constant

\n
\n

$A$

\n
\n

{sea}

\n
\n

3.887

\n
\n

0.002$

\n
\n

$x_1$

\n
\n

{cb}

\n
\n

$B$

\n
\n

-2.64

\n
\n

0.021

\n
\n

$x_2$

\n
\n

$C$

\n
\n

{se}

\n
\n

3.82

\n
\n

0.002

\n
\n

$x_3$

\n
\n

$D$

\n
\n

{sed}

\n
\n

2.53

\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$

\n

Note that you are given  the coefficient of $X_1$ from the Minitab table.

\n

Also 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}.

\n

Enter 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.

\n

Each 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]}

\n

How 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\\]

\n

where 

\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:

\n

First 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.

\n

b)

\n

\n

(i) The values of A, B, C and D are given by:

\n

A = 3.887 x SE Coef (A) = 3.887 x {sea} = {ansa} to 3 decimal places.

\n

B = Coef (B)/-2.64 = {cb}/-2.64 = {ansb} to 3 decimal places.

\n

C = 3.82 x SE Coef (C) = 3.82 x {se} = {ansc} to 3 decimal places.

\n

D = 2.53 x SE Coef (D) = 2.53 x {sed} = {ansd} to 3 decimal places.

\n

ii) 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.

\n

c)

\n

\n

Using 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.

\n

d)

\n

There 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:

\n

First 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 \\]

\n

is 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 \\]

\n

is fitted to some data in Minitab. The following table shows estimates of the parameters with associated $p$-values.

\n
{table(data,[\"Parameter\",\"Estimate\",\"p-Value\"])}
", "question_groups": [{"pickingStrategy": "all-ordered", "name": "", "questions": [], "pickQuestions": 0}], "advice": "

You would choose to exclude the predictor variable which had the largest p-value.

\n

In 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": []}