\documentclass[notitlepage,12pt]{article}
%twocolumn
\usepackage{epsfig}
\usepackage{fullpage,psfrag}
\usepackage{graphicx}
\usepackage{color}
\usepackage{subfigure}
\usepackage{rotating}
\usepackage{setspace}
\usepackage{geometry}
%\usepackage{endfloat}
\usepackage{hyperref}


%\usepackage{loflot}
%\setstretch{0.8}

\textheight 8
in \oddsidemargin 0.03in \textwidth 6.0in
 \topmargin -.25in
\parskip .1in

%\title{Stat 849: Homework Assignment 1\\
%Due: October 8, 2004}
%\author{}
%\date{}
\usepackage{natbib}

%\newcommand{\xv}{\mbox{\boldmath$x$}}
%\newcommand{\uv}{\mbox{\boldmath$u$}}
%\newcommand{\xiv}{\mbox{\boldmath$\xi$}}

\begin{document}
%\pagestyle{empty}

\begin{center}
FALL 2008\\
Stat 849: Homework Assignment 2\\
Due: October 5, 2009 \\
Total points = 300\\
\end{center}

\begin{enumerate}

\item (50 pts) Consider the following multiple linear regression problem
\[Y = \beta_0 + \beta_1X1+ \beta_2X_2 + \beta_3X3+\beta_4X_4+\epsilon.\]
Construct tests for the following hypotheses:
\begin{enumerate}
\item $H_0: \beta_1= \beta_2 = \beta_3 = \beta_4 = \beta$ vs. $H_A: \textnormal{not so}$.
\item $H_0:\beta_1 = \beta_2, \beta_3 = \beta_4$ vs. $H_A: \textnormal{not so}$.
\item $H_0:\beta_1-2\beta_2 = 4\beta_3, \quad \beta_1 + 2\beta_2 = 0$ vs. $H_A: \textnormal{not so}$.
\end{enumerate}
\item (50 pts) In this question,
you are going to do a simulation study to compare the least squares
estimator with the weighted least squares estimator. In particular,
you are going to generate $Y \sim \mathcal{N}(X\beta, V)$, where $V$
is a diagonal variance covariance matrix.
\begin{verbatim}
#n is the sample size
X1 = rnorm(n, 3, 2)
X2 = rexp(n, 1)
X3 = rgamma(n, 2, 3)
beta0 = 2
beta1 = 1.2
beta2 = -1.4
beta3 = -0.5

#To store estimated coefficients
ESTOLS = NULL
ESTWLS = NULL

#generate error vector E ~ N(0, V)
mu = rep(0, n)
Sigma = diag(runif(n, 0.5, 3)) #diagonal variance-covariance
                               #matrix with different diagonal entries

for (simno in 1:S){ #S is the number of simulations
  #generation of one data set
  E = mvrnorm(n = 1, mu, Sigma) #sample from the error vector
  Y = beta0 + beta1 * X1 + beta2 * X2 + beta3 * X3 + E

  #I am omitting some of the steps below, you need to fill these in.
  #Fit ordinary least squares.
  #Fit weighted least squares.
  #Extract coefficient estimates from the ordinary least squares fit and
  #weighted least squares fit and store in ESTOLS and ESTWLS repectively.
  #e.g. ESTOLS[simno] = summary(lm1)...
}
\end{verbatim}
You can focus on all or one of the coefficients above ($\beta_0$, $\beta_1$, $\beta_2$, $\beta_3$) and you
need to show that weighted least squares estimation in this scenario indeed provides better estimates
 of the coefficients. For example, you can do $10,000$ simulations and compute mean squared error of
ordinary least squares and weighted least squares estimators based
on these, e.g., $\frac{1}{S} \sum_{s = 1}^S (\hat{\beta}_k^{OLS,s} -
\beta_k)^2$, where $S$ is the total number of simulations,
$\hat{\beta}_k^{OLS,s}$ is the ordinary least squares estimates in
the $s$-th
 simulation, and $\beta_k$ is the \textit{true} parameter value. You need to set $S$ to a large number,
e.g., 10,000.

Try different sample sizes and report other performance measures such as the bias and
standard errors of the estimated coefficients.

\item (50 pts)  A study was conducted to  investigate the relationship
between the size of the ants and the distance at which they
foraged.  Ants were collected at various distances from the
colony, weighed, and measured. Because an ant's weight provides a
measure of how much food, or energy, it carries, and because
headwidth measurements allow the ants to be classified by size,
the data provides detailed information on the correlations among
ant size, foraging distance, and energy supply. Some colonies
develop "worker-conservative" foraging strategies, in which ants
foraging at greater distances consume relatively more food: this
minimizes the risk of starvation and leads to fewer deaths. Other
colonies use strategies that conserve energy (the colonies overall
supply of food). In this case long distance foragers, who are more
likely to die, will consume less food so that their deaths will
not be as much of a strain on the colony's food supply.
The data was collected at the Sierra Nevada Aquatic Research
Laboratory (SNARL) in the Great Basin Desert Province. Collection
trays were placed into the ground at different distances from the
entrance to the ant colonies' mounds, and any ants walking into
them were trapped. Below is a brief description of the data
collected and the data is available on the course web site.

\begin{itemize}
\item \texttt{Colony:} This is a number that identifies which
colony the ant was taken from. A total of 10 colonies is
considered.

\item \texttt{Distance:} This indicates (in meters) how far from
the mound's entrance the tray was replaced.

\item \texttt{Mass:} Weight of the ant in milligrams. This
variable is used as a measure of how much food (energy) each ant
had.

\item \texttt{Headwith:} A measure of the ant's maximum headwidth.
Headwidth is a good indicator of an ant's size.
\end{itemize}


\begin{enumerate}
\item Provide a pair plot of the data. What are your initial
observations regarding the relationship of \texttt{Headwidth}  to \texttt{Colony} and \texttt{Distance}?

\item Construct a linear regression model of \texttt{Headwidth} as a function of \texttt{Colony} and \texttt{Distance}
 and answer the following questions based on this linear model.
\begin{enumerate}
\item What are the dimensions of the design matrix?  What is the row entry
of the design matrix for an ant from colony $4$ with a distance of
$4$?
\item How do you interpret the coefficients in this model? Be explicit.


\item   Test whether \texttt{Headwidth} is related to
\texttt{Colony} and \texttt{Distance}. Write down the hypothesiss being tested
explicitly and report the test statistic, its distributions and the result of the test.

\item Test whether
\texttt{Headwidth} is related to Distance allowing the presence of
\texttt{Colony} variable in the model. Write down the hypothesiss being tested
explicitly and report the test statistic, its distributions and the result of the test.
\end{enumerate}

\item  Scientists have reasons to believe that sizes of the ants
from colonies 8 and 10 should be about half  the size of the ants
from other colonies. Sizes of the ants from rest of the colonies
are considered to be approximately equal. Test
this hypothesis in the context of the above linear regression model.

\item Scientists decide to include the \texttt{Mass} variable in the
model based on the pair plot of the data. Extend the above
regression model to include the \texttt{Mass} variable. Consider
appropriate transformations if necessary.

\item Consider the plot given in Figure \ref{iplot}.
\begin{figure}[tbh]
\begin{center}
\includegraphics[angle=0,scale=0.7]{ants_iplot}
\caption{\label{iplot} \textit{Plot for part (d).}}
\end{center}
\end{figure}
Interpret this plot. Perform a test to determine whether the data
supports the general observation from this plot by restricting your
full model NOT to include any interactions with the \texttt{Mass}
variable. If you fail to reject the corresponding null hypothesis,
can you think of a reason why that might be the case? Can you
suggest another way of using the \texttt{Distance} variable in this
analysis?
%
%\begin{verbatim}
% Analysis of Variance Table
% Response: Headwidth
%                             Df  Sum Sq Mean Sq
% Colony                       9   746.6    83.0
% Distance                     1   391.3   391.3
% Mass                         1 17957.4 17957.4
% Colony:Distance              9    34.7     3.9
% Colony:Mass                  9    64.6     7.2
% Distance:Mass                1    30.0    30.0
% Colony:Distance:Mass         9   118.6    13.2
% Residuals                 1064  4504.1     4.2
%\end{verbatim}
\item If you can suggest another way of using the
\texttt{Distance} variable  in your analysis, implement this and
compare the results with part (e).

\end{enumerate}


\item (50 pts) Regulation of genes largely depend on the activities of
site-specific DNA binding proteins called transcription factors.
These factors recognize short DNA sequences in a specific manner,
i.e, each nucleotide in a sequence defining a potential binding site
is represented by one letter from the nucleotide alphabet $\{A, C,
G, T\}$. The sequences at which these proteins bind are not unique.
Binding can also occur at variants of the optimal site with some
variants being more preferential for binding than others.

In a recent study, the DNA-binding specificities of Zif268 zinc
fingers were investigated using microarray technology in an
experiment that tested the feasibility of using microarrays for
analyzing large number of DNA-protein interactions (if you are
curious about what microarrays are, check out
\url{http://www.bio.davidson.edu/Courses/genomics/chip/chip.html}).
The data from this experiment is available in the course website and
contains binding measurements on all possible $64$ $3$mers, e.g.,
AAA, AAC, etc. For each 3mer, there are a total of 9 replicates and
both the mean and standard error of data for each 3mer are reported.
The \texttt{Ka} value of a sequence is proportional to the
probability of Zif268 zinc finger protein binding to that sequence.

Model the log of the probability of Zif268  zinc finger binding to
any sequence of nucleotides as a linear function of the sequence
composition.  Explicitly state what the covariates are. Scientists
believe that, due to physical constraints of the DNA-protein
interactions, positions within a binding site often interact.
Evaluate this hypothesis using the available data and suggest a
final model. Interpret your model in detail.



\item (25 pts) A tax consultant studied the current relation between
selling price and assessed valuation of one-family residential
dwellings in a large tax district by obtaining data for a random
sample of 16 percent "arm's length" sales transactions of one family
dwellings located on corner lots and for a random sample of 48
recent sales of one-family dwellings not located on corner lots. In
the collected data (available in \texttt{assessedval.txt}), both
selling price $Y$ and assessed valuation $X_1$ are expressed in
thousand dollars, whereas lot location $X_2$ is coded 1 for corner
lots and 0 for non-corner lots.

Assume that the error variances in the two populations are equal and
the regression model
\[Y_i = \beta_0 + \beta_1 X_{i1} + \beta_2X_{i2} +
\beta_3X_{i1}X_{i2} + \epsilon_i\] is appropriate.
\begin{enumerate}
\item Plot the sample data for the two populations in an
appropriate way. Does the regression relation appear to be the same
for the  two populations?

\item Test for identity of the regression functions for dwellings
on corner lots and dwellings in other locations at the significance
level of $5\%$. State the alternatives, decision rule, and
conclusion.

\item Plot the estimated regression functions for the two
populations and describe the nature of the differences between them.

\item Find the 95\% confidence interval for the estimate of
$\beta_1$.
\end{enumerate}

\item (25 pts) Consider the following two models where
$E(\epsilon) = 0$ and $\textnormal{Var}(\epsilon) = \sigma^2I$:

Model A: $Y = X_1\beta_1 + \epsilon$,\\
Model B: $Y = X_1\beta_1 + X_2\beta_2 + \epsilon$.

Show that $R_A^2 \le R_B^2$, where $R^2$ is defined as the multiple R-squared
in the linear regression model. What does this imply for the usage of multiple R-squared
in selecting among models of different dimensions?


\item (50) Suppose we want to fit the no intercept model $Y_i = \beta X_i + \epsilon_i$, $i=1, \cdots, n$
using weighted least squares. Assume that the observations are uncorrelated but have unequal variances.
\begin{enumerate}
\item Find a general formula for the weighted least squares estimator of $\beta$.
\item What is the variance of the weighted least squares estimator?
\item Suppose that $\textnormal{Var}(Y_i)=cX_i$, that is the variance of $Y_i$ is proportional
to the corresponding $X_i$. Using the results of part (a) and (b), find the weighted
least squares estimator of $\beta$ and the variance of this estimator.
\end{enumerate}

\end{enumerate}


\end{document}
