\setcounter{ExampleCounter}{1}
\paragraph{Example:} Home Prices

\begin{center}
\begin{tabular}{c | c}
\textbf{Size (sq. ft.)} & \textbf{Selling Price (\$1000s)}\\
\hline
& \\
2521 & 400\\
2555 & 426\\
2735 & 428\\
2846 & 435\\
3028 & 469\\
3049 & 475\\
3198 & 488\\
3198 & 455\\
\end{tabular}
\end{center}

\[r=0.9006\]

Ok, so there's a linear relationship between these variables, but what is it, actually?  Finding the linear relationship
\vspace{0.5in}

 is the problem of 
\vspace{0.2in}

Note that $\hat{y}$ represents the predicted value for a given $x$ value, and difference between the predicted value and actual value is called the 
\vspace{1.5in}

\begin{center}
\begin{tabular}{c c}
\begin{tikzpicture}
\begin{axis}[
    xmin=2450, xmax=3300,
    ymin=390, ymax=500,
    axis lines=center,
    axis on top=false,
    domain=0:1,
    x=0.0065cm,
    y=0.025cm,
    xtick={2500,2550,...,3300},
    xticklabels={2500,,2600,,2700,,2800,,2900,,3000,,3100,,3200,,3300},
    ytick={390,400,...,500},
    yticklabels={390,400,...,500},
    axis lines=middle,
    axis line style={->},
    x label style={at={(axis description cs:0.5,-0.1)},anchor=north},
    y label style={at={(axis description cs:-0.11,.5)},rotate=90,anchor=south},
    %xlabel={Size (sq. ft.)},
    %ylabel={Price (\$1000s)},
    grid=none
    ]
	\addplot [blue,only marks,mark size=2] table {
	2521 400
	2555 426
	2735 428
	2846 435
	3028 469
	3049 475
	3198 488
	3198 455
	};
	\addplot [blue, thick, domain=2500:3500, samples=10] {0.02*x+400};
	\draw [red] (axis cs:2521,400) -- (axis cs:2521,450.42);
	\draw [red] (axis cs:2555,426) -- (axis cs:2555,451.1);
	\draw [red] (axis cs:2735,428) -- (axis cs:2735,454.7);
	\draw [red] (axis cs:2846,435) -- (axis cs:2846,456.92);
	\draw [red] (axis cs:3028,469) -- (axis cs:3028,460.56);
	\draw [red] (axis cs:3049,475) -- (axis cs:3049,460.98);
	\draw [red] (axis cs:3198,488) -- (axis cs:3198,463.96);
	\draw [red] (axis cs:3198,455) -- (axis cs:3198,463.96);
\end{axis}
\end{tikzpicture}
&
\begin{tikzpicture}
\begin{axis}[
    xmin=2450, xmax=3300,
    ymin=390, ymax=500,
    axis lines=center,
    axis on top=false,
    domain=0:1,
    x=0.0065cm,
    y=0.025cm,
    xtick={2500,2550,...,3300},
    xticklabels={2500,,2600,,2700,,2800,,2900,,3000,,3100,,3200,,3300},
    ytick={390,400,...,500},
    yticklabels={390,400,...,500},
    axis lines=middle,
    axis line style={->},
    x label style={at={(axis description cs:0.5,-0.1)},anchor=north},
    y label style={at={(axis description cs:-0.11,.5)},rotate=90,anchor=south},
    %xlabel={Size (sq. ft.)},
    %ylabel={Price (\$1000s)},
    grid=none
    ]
	\addplot [blue,only marks,mark size=2] table {
	2521 400
	2555 426
	2735 428
	2846 435
	3028 469
	3049 475
	3198 488
	3198 455
	};
	\addplot [blue, thick, domain=2500:3500, samples=10] {0.0992*x+160.19};
	\draw [red] (axis cs:2521,400) -- (axis cs:2521,410.2732);
	\draw [red] (axis cs:2555,426) -- (axis cs:2555,413.646);
	\draw [red] (axis cs:2735,428) -- (axis cs:2735,431.502);
	\draw [red] (axis cs:2846,435) -- (axis cs:2846,442.5132);
	\draw [red] (axis cs:3028,469) -- (axis cs:3028,460.5676);
	\draw [red] (axis cs:3049,475) -- (axis cs:3049,462.6508);
	\draw [red] (axis cs:3198,488) -- (axis cs:3198,477.4316);
	\draw [red] (axis cs:3198,455) -- (axis cs:3198,477.4316);
\end{axis}
\end{tikzpicture}
\end{tabular}
\end{center}
\vfill
\pagebreak

The goal of constructing the regression equation is to \textbf{minimize the squared residuals}.  This line of best fit is called the \textbf{least-squares regression line}.

\begin{formula}{Equation of the Least-Squares Regression Line}
Given ordered pairs ($x$,$y$) with sample means $\overline{x}$ and $\overline{y}$, sample standard deviations $s_x$ and $s_y$, and correlation coefficient $r$, the equation of the least-squares regression line for predicting $y$ from $x$ is 
\vspace{0.5in}

where the slope and intercept are given by
\begin{itemize}
\item \textbf{Slope:} 
\vspace{1in}

\item \textbf{Intercept:} 
\vspace{1in}
\end{itemize}
\end{formula}

\begin{itemize}
\item \textbf{Explanatory variable:} 
\vspace{0.75in}

\item \textbf{Outcome or response variable:} 
\vspace{0.75in}
\end{itemize}
\vfill
\pagebreak

\begin{example}{Regression Line}
Compute the least-squares regression line for the house price data.\\

\vspace*{5.5in}

\begin{center}
\begin{tikzpicture}
\begin{axis}[
    xmin=2450, xmax=3300,
    ymin=390, ymax=500,
    axis lines=center,
    axis on top=false,
    domain=0:1,
    x=0.01cm,
    y=0.038cm,
    xtick={2500,2550,...,3300},
    xticklabels={2500,,2600,,2700,,2800,,2900,,3000,,3100,,3200,,3300},
    ytick={390,400,...,500},
    yticklabels={390,400,...,500},
    axis lines=middle,
    axis line style={->},
    x label style={at={(axis description cs:0.5,-0.1)},anchor=north},
    y label style={at={(axis description cs:-0.11,.5)},rotate=90,anchor=south},
    %xlabel={Size (sq. ft.)},
    %ylabel={Price (\$1000s)},
    grid=none
    ]
	\addplot [blue,only marks,mark size=2] table {
	2521 400
	2555 426
	2735 428
	2846 435
	3028 469
	3049 475
	3198 488
	3198 455
	};
	\addplot [blue, thick, domain=2500:3500, samples=10] {0.0992*x+160.19};
\end{axis}
\end{tikzpicture}
\end{center}
\end{example}
\vfill
\pagebreak

\subsection{Using Your Calculator}
Your calculator can also find the least-squares regression line.  To do so, enter the data into \texttt{L1} and \texttt{L2}.

Then press the \includegraphics[height=0.3in]{CalcStatButton} button and scroll over to the \texttt{CALC} menu.  The fourth option is \texttt{4:LinReg(ax+b)}.  If you select this option, you should see a menu like the following:
\begin{center}
\includegraphics[width=3in]{CalcLinReg}
\end{center}

If you select \texttt{Calculate}, you'll see something like this:
\begin{center}
\includegraphics[width=3in]{CalcLinReg2}
\end{center}

\paragraph{Note:} If you don't see the $r$ value, press \includegraphics[height=0.3in]{CalcCatalog} to access the catalog, then scroll down to \texttt{DiagnosticOn}.  Press enter twice to turn it on, and then repeat the steps above to find the regression line.
\vfill
\pagebreak

\begin{example}{Regression Line}
A random sample of 11 statistics students produced the following data, where $x$ is the third exam score out of 80, and $y$ is the final exam score out of 200.
\begin{center}
\begin{tabular}{c c}
$x$ & $y$\\
\hline
\\
65 & 175\\
67 & 133\\
71 & 185\\
71 & 163\\
66 & 126\\
75 & 198\\
67 & 153\\
70 & 163\\
71 & 159\\
69 & 151\\
69 & 159
\end{tabular}
\end{center}

Find the equation of the least-squares regression line.\\

\vspace*{3in}
\end{example}

\vfill
\pagebreak
