%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ------------------------------------------------------------------------
% Project PARTI Stat 6401*************************************************
% ------------------------------------------------------------------------
% Submitted:      Dr. Eric Suess, Statistics 6401, Fall 2012
% Submitted Date: October 29, 2012
% Accepted Date:  October 29, 2012
% ------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[12]{report}

\usepackage{latexsym}
\usepackage[centertags]{amsmath}
\usepackage{amsfonts}
\usepackage{newlfont}
%\usepackage{graphicx,fullpage,subfigure,pstricks}

\setlength{\oddsidemargin}{-0.4cm}
\setlength{\evensidemargin}{0cm}
\setlength{\topmargin}{-0.75cm}
\setlength{\textheight}{8.9in}
\setlength{\textwidth}{6.5in}
\renewcommand{\baselinestretch}{1}
\setlength{\parskip}{3mm}
\setlength{\parindent}{0mm} % indented paragraphs just don't
%\pagestyle{plain}

\begin{document}

\pagestyle{myheadings}
\markright{Statistics 6401, Winter 2012}

\large
\begin{center}
\textbf{Project I}
\end{center}

\noindent {\bf Instructions:} Complete the following exercises.

\begin{enumerate}
\item
To better understand the second problem on the Midterm about the gamma density, run the available R code to see the effect of increasing $\alpha$.

\begin{enumerate}

\item  What happens to the gamma density as $\alpha$ increases?  What kind of parameter is $\alpha$?

\begin{verbatim}
# plot the gamma p.d.f

x = seq(0,10,0.1)

alpha = 10
lambda = 5

curve(dgamma(x, shape = alpha, rate = lambda), 0, 20, add = TRUE)


alpha = 20      # bigger alpha here	
lambda = 5      # bigger lambda here

curve(dgamma(x, shape = alpha, rate = lambda), 0, 20, add = TRUE, lty = 1)

for(i in 1:10){

alpha = 20 + 10*i	    # bigger alpha here	
lambda = 5            # bigger lambda here

curve(dgamma(x, shape = alpha, rate = lambda), 0, 20, add = TRUE, lty = i)

}
\end{verbatim}

\item  Change the R code to investigate the effect of changing $\lambda$.  What happens to the gamma density as $\lambda$ increases?  What kind of parameter is $\lambda$?

\end{enumerate}

\item To better understand the fifth problem on the Midterm about the logistic distribution, run the available R code.
    
\begin{verbatim}
# plot the logistic p.d.f.

x = seq(0,1,0.0001)
#x

y = log(x/(1-x))
#y

X11()
par(mfrow=c(2,2))
plot(x,y,type='l',main="transformation")

F_y = exp(y)/(1+exp(y))
#F_y

plot(y,F_y,type='l',main="cdf")

f_y = exp(y)/(1+exp(y))^2
#f_y

plot(y,f_y,type='l',main="pdf")

mu = 1
sigma = .5
f_y = (1/sigma)*exp((y-mu)/sigma)/(1+exp((y-mu)/sigma))^2
f_y

plot(y,f_y,type='l',main="pdf, mu = 1, sigma=0.5")
\end{verbatim}

\begin{enumerate}
\item
Print the pictures for each part of problem 5.  Clearly label each picture for each part.
\end{enumerate}


\item Read the two BVN Handouts from the class website.
\begin{itemize}
\item BVNmatrixnotation.pdf
\item 2dRotationalTransformation.pdf
\end{itemize}


\begin{enumerate}
\item What are the two transformations that take two independent normal random values to
two correlated/dependent normal random values?
\item  What are the two rotational transformations that take two correlated normal random values to
two independent normal random values?
\item Run the code provided in the RBVNsim3.R handout.  Verify that the transformations perform 
as described.
\end{enumerate}

\item Investigate the use of the R packages, IDPmisc and gplots.  In the IDPmisc package there
is a command ipairs that is useful for plotting large amounts of data using color.  In the gplots
package there is a command hist2d that is also useful for large data and uses color.

Run the code provided at the bottom of the RBVNsim3.R handout.  Use the output to better visualize 
the correlation/dependence between the random values that have been simulated in the previous part.

\end{enumerate}


\end{document}
% ------------------------------------------------------------------------
