
% This is a simple LaTex sample document that gives a submission format
%   for IEEE PAMI-TC conference submissions.  Use at your own risk.

% Make two column format for LaTex 2e.
\documentclass[10pt,twocolumn]{article} %,twocolumn
\usepackage[dvips]{graphicx,graphics}
\usepackage{times,amsmath,amsfonts}

% Use following instead for LaTex 2.09 (may need some other mods as well).
% \documentstyle[times,twocolumn]{article}

% Set dimensions of columns, gap between columns, and paragraph indent
\setlength{\textheight}{9.9in} \setlength{\textwidth}{6.9in}
%\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{0in}
\setlength{\headheight}{0in} \setlength{\headsep}{-1in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.2in}  % Centers text.
\setlength{\evensidemargin}{-.2in}

% Add the period after section numbers.  Adjust spacing.
\newcommand{\Section}[1]{\vspace{-8pt}\section{\hskip -1em.~~#1}\vspace{-3pt}}
\newcommand{\SubSection}[1]{\vspace{-3pt}\subsection{\hskip -1em.~~#1}
        \vspace{-3pt}}
\newcommand{\bqn}{\begin{eqnarray}}
\newcommand{\eqn}{\end{eqnarray}}
\newcommand{\diff}[1] {\frac{\partial}{\partial #1}}
\newcommand{\jacob}[3]{\frac{\partial^2 #3}{\partial #1 \partial #2}}
\newcommand{\der}[2]{\frac{\partial #2}{\partial #1}}
\begin{document}

% Don't want date printed
%\date{January 23, 2003}

% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 312: Lecture 19\\
Linear Regression}

% For single author (just remove % characters)
\author{Moo K. Chung\\
mchung@stat.wisc.edu}
\date{Nov 30, 2004}
% For two authors (default example)
\maketitle \thispagestyle{empty} \subsection*{Concepts}
\begin{enumerate}
\item Let $x$ be the speed of a car and $y$ be the distance the car traveled
in an hour hour. Then we have model
$$y = \beta_0 + \beta_1 x.$$
Suppose we have $n$ paired measurements $(x_i,y_i), i=1,\cdots,n$.
Since all measurement are supposed to be noisy, we introduce a noise
term $\epsilon$ in the above equation. Our modified stochastic model
is $$y = \beta_0 + \beta_1 x + \epsilon,$$ where $\epsilon \sim
N(0,\sigma^2)$. Since $\epsilon$ is a random variable, we use $Y$
instead of $y$ for convenience: $$Y = \beta_0 + \beta_1 x +
\epsilon.$$ Note that $\mathbb{E}Y = \beta_0 + \beta_1 x$ and
$\mathbb{V} Y = \sigma^2$.


\item Equivalently we can write the above linear model for each
paired measurement $(x_i,y_j)$:
$$Y_j = \beta_0 + \beta_1x_j + \epsilon_j,$$
where $y_j$ is the observed value of random variable $Y_j$ and
$\epsilon_j \sim \epsilon$. Note that $\mathbb{E}Y_j = \beta_0 +
\beta_1 x_j$. Let $\hat \beta_0, \hat \beta_1$ be estimators of
$\beta_0, \beta_1$. Then the {\em predicted values} or fitted values
are given by $$\hat y_j =\hat \beta_0 + \hat \beta_1 x_j.$$ The
differences between the observations $y_j$ and the predicted values
$\hat y_j$ are called the {\em residuals} (errors), i.e. $$r_j = y_j
- \hat y_j = y_j - \hat \beta_0 - \hat \beta_1 x_j.$$

\item {\em Least squares estimation}. The least squares estimation is a method
of estimating parameters $\beta_0$ and $\beta_1$ by minimizing the
{\em sum of the squared errors} (SSE):
$$SSE = \sum_{j=1}^n r_j^2 = \sum_{j=1}^n (y_j - \hat y_j)^2 =
\sum_{j=1}^n (y_j - \hat \beta_0 - \hat \beta_1 x_j)^2.$$ Then the
{\em regression line} is given by $y = \hat \beta_0 + \hat \beta_1
x$. By differentiating SSE with respect to $\beta_0$ and $\beta_1$,
we get {\em normal equations}:
$$\beta_0 +  \overline x \beta_1 =\overline y$$
$$ \overline x \beta_0 + \overline{x^2} \beta_1 = \overline{xy}$$
Solving these equations, we get $$\hat \beta_1 =
\frac{S_{xy}}{S_{xx}}$$$$\hat \beta_0 = \overline y - \overline x
\frac{S_{xy}}{S_{xx}},$$ where the sample covariance $S_{xy} =
n(\overline{xy} -\bar{x}\bar{y})$.

\end{enumerate}
\begin{figure}
\centering
\renewcommand{\baselinestretch}{1}
\includegraphics[scale=0.8]{lecture19.ps}
%\caption{The regression line for example 1.}
\end{figure}
{\em Example.} 10 students took two midterm exams.\\
Student\hspace{0.35cm}  $\|$  01  02  03  04 05 06 07 08 09 10\\
Midterm 1$\|$ 80 75 60 90 99 60 55 85 65 70\\
Midterm 2$\|$ 70 60 70 72 95 66 60 80 70 60\\
Let's find the least squares regression line.
\begin{verbatim}
> x<-c(80, 75, 60, 90, 99, 60, 55,
85, 65, 70)
> y<-c(70, 60, 70, 72, 95, 66, 60,
80, 70, 60)
> plot(x,y)
> rarara <-lm(y~x)
> rarara
Call: lm(formula = y ~ x)
Coefficients: (Intercept)      x
              29.4827       0.5523
> abline(rarara)
\end{verbatim}

%Exercise 12.15.

\end{document}
