% 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[11pt]{article} %
\usepackage[dvips]{graphicx,graphics,color}
\usepackage{times,amsmath,amsfonts}

\setlength{\textheight}{10in} \setlength{\textwidth}{6.875in}
\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{-0.5in}
\setlength{\headheight}{0in} \setlength{\headsep}{0in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.2in}  % Centers text.
\setlength{\evensidemargin}{-.2in}

% Add the period after section numbers.  Adjust spacing.

\newcommand{\bqn}{\begin{eqnarray}}
\newcommand{\eqn}{\end{eqnarray}}
\newcommand{\bq}{\begin{eqnarray*}}
\newcommand{\eq}{\end{eqnarray*}}
\begin{document}


% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 324: Lecture 19\\
Linear Regression}

% For single author (just remove % characters)
\author{Moo K. Chung\\
mchung@stat.wisc.edu}
\date{April 14, 2005}
\maketitle \thispagestyle{empty}


\begin{enumerate}


\begin{enumrate}

\item   {\em Example 1.} 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\\
We are interested in investigating the relationship between two exam
scores.
\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)
\end{verbatim}

\begin{figure}[h]
\centering
\renewcommand{\baselinestretch}{1}
\includegraphics[scale=0.8]{324.19.01.ps}
\caption{The regression line for Example 1.}
\end{figure}

\item Given paired data
$(x_1,y_1)$, $\cdots$, $(x_n,y_n)$, we model $Y_j = \beta_0 +
\beta_1x_j + \epsilon$ where $\epsilon$ is  random noise with
$\mathbb{E} \epsilon = 0$ and ${\bf Var}\epsilon = \sigma^2$. We do
not need to assume any distribution on $\epsilon$ other than its
mean is zero. Note that $\mathbb{E}Y_j = \beta_0 + \beta_1 x_j$ and
$\mathbb{V} Y_j = \sigma^2$.


\item {\em Least squares estimation}. We estimate
$\beta_0$ and $\beta_1$ by minimizing the sum of the squared errors:
$$
\sum_{j=1}^n (y_j - \beta_0 - \beta_1 x_j)^2.$$

By differentiating t 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{\overline
{xy} - \bar x \bar y}{\overline {x^2} - (\bar x)^2}=
\frac{S_{xy}}{S_{xx}},$$ where  $S_{xy} = n(\overline{xy}
-\bar{x}\bar{y})$ and
$$\hat \beta_0 = \overline y - \overline x
\frac{S_{xy}}{S_{xx}}.$$

\begin{verbatim}
> a <-lm(y~x)
> a
Call: lm(formula = y ~ x) Coefficients: (Intercept)      x
                                         29.4827       0.5523
> abline(a)
\end{verbatim}

\item The {\em predicted values} or fitted values $\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.$$ The sum of squared residuals
(SSE) is defined as
$$SSE = \sum_{j=1}^n (y_j - \hat \beta_0 - \hat \beta_1 x_j)^2=
\sum_{j=1}^n y_j^2 -\hat \beta_0 \sum_{j=1}^n y_j - \beta_1
\sum_{j=1}^n x_j y_j =S_{yy}- \hat \beta_1 S_{xy} = S_{yy} -
S_{xy}^2/S_{xx}.$$ SSE measures the amount of variability that the
linear model can not explain.

The total sum of squares (SST) is defined as
$$SST =\sum_{j=1}^n (y_j - \bar y)^2 = S_{yy}.$$
SST measures the total amount of variation in observed $y$ values.
Hence $\frac{SSE}{SST}$ measures the proportion of total variation
that can not be explained by the linear regression. It can be shown
that $0 \leq \frac{SSE}{SST} \leq 1$.\\
{\em Proof.} $$\min_{\beta_0,\beta_1}
\sum_{j=1}^n(y_j-\beta_0-\beta_1 x_j)^2 \leq \min_{\beta_0}
\sum_{j=1}^n(y_j-\beta_0)^2 \leq  \sum_{j=1}^n(y_j-\bar y)^2.$$

{\em Coefficient of determination} measures the proportion of the
total variations in $y$ that can be explained by the linear model
and it is defined as
$$r^2 = 1 - \frac{SSE}{SST}$$
Since $SST = S_{yy}$ and $SSE = S_{yy}-S_{xy}^2/S_{xx}$, we can see
that $r^2 = S_{xy}^2/(S_{xx}S_{yy}).$ $r$ is called the {\em sample
correlation coefficient}.


\end{enumerate}
{\bf Assigned problems.} Exercise 12.12., 12.16., 12.26. Exercise
under assumption of equal variance. HW 6 due April 28th. Solve the
assigned problems in Lecture 19-22.
\end{document}
