\documentclass[12pt,letterpaper]{article}

\addtolength{\oddsidemargin}{-.75in}
\addtolength{\evensidemargin}{-.75in}
\addtolength{\textwidth}{1.5in} \addtolength{\topmargin}{-0.75in}
\addtolength{\textheight}{1.2in}

\hbadness=10000 \tolerance=10000


\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{latexsym}
%\usepackage{epsfig}
\usepackage{graphicx}
\usepackage{color}
\usepackage{array}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{subfigure}
\usepackage{wrapfig}
\usepackage{slashbox}
\usepackage{delarray}
\usepackage{alltt}
\usepackage{pifont}
%\usepackage{bbding}


\newcommand{\smallsp}{\hspace{0.1in}}
\newcommand{\medsp}{\hspace{0.25in}}
\newcommand{\bigsp}{\hspace{0.5in}}
\newcommand{\mr}{\mathrm}
\newcommand{\convprob}{\ensuremath{\stackrel{P}{\longrightarrow}}}
\newcommand{\convae}{\ensuremath{\stackrel{a.e.}{\longrightarrow}}}
\newcommand{\convas}{\ensuremath{\stackrel{a.s.}{\longrightarrow}}}
\newcommand{\convd}{\ensuremath{\stackrel{\mathcal{D}}{\longrightarrow}}}
\newcommand{\appdist}{\ensuremath{\stackrel{approx.}{\sim}}}
\newcommand{\define}{\ensuremath{\stackrel{Def}{=}}}
\newcommand{\iid}{\ensuremath{\stackrel{iid}{\sim}}}
\newcommand{\ind}{\ensuremath{\stackrel{ind}{\sim}}}
\newcommand{\bs}{\backslash}
\newcommand{\Dhat}{\ensuremath{\hat{D}}}
\newcommand{\phat}{\ensuremath{\hat{p}}}
\newcommand{\pihat}{\ensuremath{\hat{\pi}}}
\newcommand{\Rhat}{\ensuremath{\hat{R}}}
\newcommand{\thetahat}{\ensuremath{\hat{\theta}}}
\newcommand{\betahat}{\ensuremath{\hat{\beta}}}
\newcommand{\varhat}{\ensuremath{\widehat{\Var}}}
\newcommand{\ptilde}{\ensuremath{\tilde{p}}}
\newcommand{\Ptilde}{\ensuremath{\tilde{P}}}
\newcommand{\ytilde}{\ensuremath{\tilde{y}}}
\newcommand{\xtilde}{\ensuremath{\tilde{x}}}
\newcommand{\Xtilde}{\ensuremath{\tilde{X}}}
\newcommand{\yrep}{\ensuremath{y^{rep}}}
\newcommand{\phiold}{\ensuremath{\phi^{\mathrm{old}}}}
\newcommand{\phinew}{\ensuremath{\phi^{\mathrm{new}}}}
\newcommand{\yhat}{\ensuremath{\hat{y}}}
\newcommand{\Yhat}{\ensuremath{\hat{Y}}}
\newcommand{\xbar}{\ensuremath{\bar{x}}}
\newcommand{\Xbar}{\ensuremath{\bar{X}}}
\newcommand{\ybar}{\ensuremath{\bar{y}}}
\newcommand{\Ybar}{\ensuremath{\bar{Y}}}
\newcommand{\Var}{\ensuremath{\mathrm{Var}}}
\newcommand{\Cov}{\ensuremath{\mathrm{Cov}}}
\newcommand{\Corr}{\ensuremath{\mathrm{Corr}}}
\newcommand{\Mode}{\ensuremath{\mathrm{Mode}}}
\newcommand{\Med}{\ensuremath{\mathrm{Med}}}
\newcommand{\SD}{\ensuremath{\mathrm{SD}}}
\newcommand{\tr}{\ensuremath{\mathrm{tr}}}
\newcommand{\logit}{\ensuremath{\mathrm{logit}}}
\newcommand{\zscore}{\ensuremath{z}-score}
\newcommand{\pvalue}{\ensuremath{p}-value}
\newcommand{\rank}{\ensuremath{\mathrm{rank}}}
\newcommand{\diag}{\ensuremath{\mathrm{diag}}}
\newcommand{\invchisq}{\ensuremath{\mathrm{Inv-}\chi^2}}
\newcommand{\invwish}{\ensuremath{\mathrm{Inv-}\mathrm{Wishart}}}
\newcommand{\wish}{\ensuremath{\mathrm{Wishart}}}
\newcommand{\ninvchisq}{\ensuremath{\mathrm{N-}\mathrm{Inv-}\chi^2}}
\newcommand{\invgamma}{\ensuremath{\mathrm{Inv-}\mathrm{Gamma}}}
\newcommand{\Rn}[1]{\ensuremath{\mathbb{R}^#1}}
\newcommand{\silly}[2]{\ensuremath{f(#1 + 2, #2 - 2)}}
\newcommand{\boldw}{{\mathbf{w}}}
\newcommand{\boldW}{{\mathbf{W}}}
\newcommand{\boldv}{{\mathbf{v}}}
\newcommand{\boldV}{{\mathbf{V}}}
\newcommand{\bolds}{{\mathbf{s}}}
\newcommand{\boldy}{{\mathbf{y}}}
\newcommand{\boldx}{{\mathbf{x}}}
\newcommand{\boldY}{{\mathbf{Y}}}
\newcommand{\boldX}{{\mathbf{X}}}
\newcommand{\boldZ}{{\mathbf{Z}}}
\newcommand{\boldc}{{\mathbf{c}}}
\newcommand{\boldd}{{\mathbf{d}}}
\newcommand{\bolde}{{\mathbf{e}}}
\newcommand{\boldC}{{\mathbf{C}}}
\newcommand{\boldD}{{\mathbf{D}}}
\newcommand{\boldE}{{\mathbf{E}}}
\newcommand{\boldm}{{\mathbf{m}}}
\newcommand{\boldp}{{\mathbf{p}}}
\newcommand{\boldq}{{\mathbf{q}}}
\newcommand{\boldr}{{\mathbf{r}}}
\newcommand{\boldP}{{\mathbf{P}}}
\newcommand{\boldQ}{{\mathbf{Q}}}
\newcommand{\boldR}{{\mathbf{R}}}
\newcommand{\boldO}{{\mathbf{0}}}
\newcommand{\boldK}{{\mathbf{K}}}
\newcommand{\boldA}{{\mathbf{A}}}
\newcommand{\bolda}{{\mathbf{a}}}
\newcommand{\boldb}{{\mathbf{b}}}
\newcommand{\boldcA}{{\boldsymbol{\mathcal A}}}
\newcommand{\boldcW}{{\boldsymbol{\mathcal W}}}
\newcommand{\boldcX}{{\boldsymbol{\mathcal X}}}
\newcommand{\boldcZ}{{\boldsymbol{\mathcal Z}}}
\newcommand{\bolddelta}{{\boldsymbol{\delta}}}
\newcommand{\boldepsilon}{{\boldsymbol{\epsilon}}}
\newcommand{\boldmu}{{\boldsymbol{\mu}}}
\newcommand{\boldnu}{{\boldsymbol{\nu}}}
\newcommand{\boldpi}{{\boldsymbol{\pi}}}
\newcommand{\boldSigma}{{\boldsymbol{\Sigma}}}
\newcommand{\scriptX}{{\mathcal{X}}}
\newcommand{\scriptY}{{\mathcal{Y}}}
\newcommand{\neff}{{\ensuremath{n_{\mathrm{eff}}}}}
\newcommand{\matlab}{\textbf{MATLAB}}
\newcommand{\R}{\textbf{R}}
\newcommand{\sas}{\textbf{SAS}}
\newcommand{\spss}{\textbf{SPSS}}
\newcommand{\stata}{\textbf{Stata}}
\newcommand{\systat}{\textbf{Systat}}
\newcommand{\minitab}{\textbf{Minitab}}
\newcommand{\WinBugs}{\textbf{WinBUGS}}
\newcommand{\winbugs}{\textbf{WinBUGS}}
\newcommand{\openbugs}{\textbf{OpenBUGS}}
\newcommand{\bugsr}{\textbf{bugs.R}}
\newcommand{\brugs}{\textbf{BRugs}}
\newcommand{\splus}{\textbf{S-Plus}}
\newcommand{\s}{\textbf{S}}
\newcommand{\url}[1]{$<${\tt #1}$>$}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\tab}{$\backslash$t}



\begin{document}

\noindent{\bf Statistics 135 -- Assignment 1}

\noindent Due: Wednesday, October 5, 2005

\vspace{0.25 in}

Please submit your solutions in a word processed format (I don't
care which one you use).  Also as part of your solutions, please
give the commands used to generate the output.  I'm curious to the
approaches you take as some of the questions have multiple valid
ways of getting the answers.  For example, I can think of two ways
of generating the set of summary statistics desired in one of the
early questions.  Also in your figures, where appropriate, please
give informative axis label, figure titles, etc.

\begin{enumerate}

\item Download the data iris.dat from the course web site (either from
the Datasets page or the Assignments page) and read the file into
\R\ using the \code{read.table} command into a data frame named
\code{Iris}. This data set is the famous Fisher Iris data.  It
contains 4 variables (Sepal Length, Sepal Sepal Width, Petal Length,
and Petal Width) on 50 flowers from each of 3 species (Setosa,
Versicolor, and Virginica) of iris.  All size measurements are given
in centimeters. For a more complete description of the dataset,
check the description file which is also available at the same
locations as the dataset.

\item Calculate the standard summary statistics (mean, standard deviation,
median, 1st and 3rd quartiles, min, and max) for the four variables
for the combined data set and for each species separately.

\item Create a new data frame with the measurements given in inches
instead of centimeters (use the conversion 1 inch = 2.54 cm).  Show the
first 5 rows of the two data frames.

\item Draw histograms of the four numeric variables.  Please combine the
four histograms into a single figure (using
\code{par(mfrow=c(2,2))}). When creating figure, make sure it is
clear which variable is being plotted in each histogram with an
informative label.

\item For the two Petal variables, draw side by side boxplots for
each species.  Please combine these two plots into a single figure.

\item Create a scatterplot of Sepal Width (x axis) vs Sepal Length (y
axis), superimposing the least square regression line on the plot.
In addition, redo this scatterplot, but with different plotting
symbols for each species.  For this second plot, add the least
squares regression lines for each of species.  Use different line
types for the different species.  Use the legend command to indicate
which symbol and line correspond to the different species.


\item It is possible to show that one way to generate an exponential
random variable (RV) with mean $\mu$ is to generate a Uniform(0,1) RV,
$U$ and make the transformation $V = -\mu \log U$.

\begin{enumerate}

\item Generate 100 uniform random variables and store them in a
vector {\tt u}. ({\tt u <- runif(100)}).  Produce a histogram of the
vector {\tt u}.

\item Generate 100 exponential random variable with mean 2 using the
\R\ function \code{rexp} and store them in a vector \code{v}.  Check
the help page to see how \R\ parameterizes the exponential
distribution.

\item Using the 100 uniforms generated in part (a), generate 100
exponentials with mean 2 and store them in a vector {\tt w}. Examine
whether the vectors {\tt v} and {\tt w} appear to really have the
same distribution by examining summaries and graphs of the data. One
useful graphic for this examination is a QQ plot (see help for
\code{qqplot} function).

\end{enumerate}

\end{enumerate}

\end{document}
