
---
title: 'Stat 519 Homework #2 - Multivariate Normal Distribution, Principal Components Analysis'
author: "Stephen Lee" ## change to your name here !
date: '`r format(Sys.Date(), "%B %d, %Y")`'
output:
  pdf_document: default
  html_document: default
  word_document: default
fig_height: 3
fig_width: 6 
  
  
---

## Please remember 'Correctness' worth 70 points and 'Style' worth 30 points.
## Maximun total number of pages = 30

-----------

#QUESTION 1 [10 points]

## a) Show that $sin^2\theta + cos^2\theta = 1$, for any $\theta$

## b) Show that 
$$
\mathbf{X} = \left(
\begin{array}
{cc}
cos\theta & -sin\theta  \\
sin\theta & cos\theta  
\end{array}
\right)
$$ 

##is an orthogonal matrix.

## c) What is the geometric interpretation of the matrix transformation by $\mathbf{X}$ and by the inverse of $\mathbf{X}$?




\newpage


#QUESTION 2 [40 points]

## a) Give a numerical example of a bivariate normal pdf, centered at the origin, with $\Sigma$ such that the contours are spheres. Plots the contours.
## b) Give a numerical example of a bivariate normal pdf, centered at the origin, with $\Sigma$ such that the contours are upright ellipses with axes parallel to the x and y axes, and with variances 1 and 2, respectively along the x and y axes. Plots the contours.
## c) Give a numerical example of a bivariate normal pdf, centered at the origin, with $\Sigma$ such that the contours are tilted ellipses with its major axes inclined at 60\% to the x axis, using the spectral decomposition that $\Sigma = U \Lambda U'$. Plots the contours.
## d) Give a numerical example of a trivariate normal pdf, centered at the origin, with $\Sigma$ such that the contours are upright ellipses with axes parallel to the x, y, and z axes, and with variances 1, 2, and 3, respectively along the x, y and z axes. 
## e) Show that 
$$
\left(
\begin{array}
{rrr}
0   &-.80 &-.60 \\
.80 &-.36 &.48 \\
.60 &.48  &-.64 
\end{array}
\right)
$$ 

## is an orthognal matrix.

## f) Use the results in parts d) and e) to produce a trivariate normal pdf, centered at the origin, with $\Sigma$ such that the contours are tilted ellipsoids. Write down this 3d pdf.

## g) Write down the resulting bivariate pdf of projecting the 3d normal onto the 2d x-y plane.
## h) Write down the resulting univariate pdf of projecting the 3d normal onto the x axis.
## i) Find the direction of the line such that the projection of the 3d normal onto this line would have the maximum variance.
## j) What is the value of this maximum variance from the previous part?

\newpage

#QUESTION 3 [10 points]

## Do Ex 3.3 on p.102-103 of Everitt and Hothorn.


\newpage

#QUESTION 4 [20 points]

## Analyze the R-built-in dataset ```iris``` using principal components analyses and discuss your findings. In particular:
## a) How many principal components should be chosen and why?
## b) How would you interpret the components?
## c) Produce a biplot and describe any interesting findings.
## d) Which variable is most different from the other 3 variables, why?

\newpage

#QUESTION 5 [20 points]

## Condier the ```RECORDS``` dataset:
```{r}
RECORDS =read.csv('http://www.webpages.uidaho.edu/~stevel/519/Data/RECORDS.csv')
```
## This includes athletic records for 55 countries in each of 8 track and field events: 100m (in seconds), 200m (s), 400m (s), 800m (min), 1,500m (min), 5,000m (min), 10,000m (min), and marathon (min). Analyze these data using principal components analyses and discuss your findings. In particular:
## a) How many principal components should be chosen and why?
## b) How would you interpret the components?
## c) Produce a biplot and describe any outliers you see.
## d) What are the best 3 countries based on your results and findings, why?


\newpage
# THE END
