Linear Regression - Predction

257 Views Asked by At

With this question I can input data and I can find the linear regression line - but I am totally failing to get the last part - predicting how many hats will be sold in $2017$. How do you do it. Thanks for your help.

At a shop, these numbers of hats have been sold the last eight years.

2

There are 2 best solutions below

0
On

A good way to do this is through Excel. We have your data:

$$\begin{array}{c|c} \text{Year} & \text{Hats}\\ \hline 2008 & 875\\ 2009 & 923\\ 2010 & 913\\ 2011 & 958\\ 2012 & 1023\\ 2013 & 978\\ 2014 & 1015\\ 2015 & 1110\\ \end{array}$$

We can plot this data and retreive a linear function:

$$y = 29.655x - 58678$$

We can either use the 'FORECAST' function or manually enter 2017 into the $x$ value. Therefore,

$$\begin{array}{c|c} \text{Year} & \text{Hats}\\ \hline 2008 & 875\\ 2009 & 923\\ 2010 & 913\\ 2011 & 958\\ 2012 & 1023\\ 2013 & 978\\ 2014 & 1015\\ 2015 & 1110\\ 2016 & 1106\\ 2017 & 1136\\ \end{array}$$

Hat Sales Graph

0
On

We can solve this using the method of least squares:

$$\overline X = \frac{\sum_{n=1}^{8}x_i}{8} = 2011.5\\\overline Y = \frac{\sum_{n=1}^{8}y_i}{8} = 974.375$$

The equation of the line of best fit is $y= mx + b$ where $$m = \frac{\sum_{n=1}^{8}(x_i-\overline X)(y_i-\overline Y)}{\sum_{n=1}^{8}(x_i-\overline X)^2}\approx 28.1622024$$

and $$b = \overline Y - m \overline X \approx -55673.8951$$

So the estimate for $x=2017$ is $1129.2671 \approx 1129$