<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\section*{Assignment 1 Deadline: 13th November 2017, 12 noon}
\thispagestyle{plain}

Submit your answers in p.d.f. format, by email, to me {\tt noble\textcircled{a}mimuw.edu.pl}.

\begin{enumerate}
 \item The purpose of this exercise is to investigate how $\widehat{\beta}$ is computed. The formula $(X^t X)^{-1} Y$ is correct, but it turns out to be inefficient even for moderate values of  $p$ (the number of explanatory variables). The command {\tt lm} does not use this formula for computing $\widehat{\beta}$, the minimiser of of $(Y - X\beta)^t (Y - X\beta)$.
 
 Generate some artificial data by:
 
 \begin{verbatim}
&gt; x &lt;- 1:20
&gt; y &lt;- x + rnorm(20)
 \end{verbatim}

 Fit a polynomial in {\tt x} for predicting {\tt y}; that is, fit the model
 
 
 \[ Y = \beta_0 + \beta_1 x + \ldots + \beta_p x^p + \epsilon.\]
 
 \noindent Compute $\widehat{\beta}$ in two ways, firstly by {\tt lm()} and secondly by direct computation of $\widehat{\beta} = (X^t X)^{-1}X^t Y$. At what degree of polynomial does the direct computation present difficulties? What about {\tt lm()}?
 
 {\tt lm()} uses a different minimisation procedure which is more efficient than the formula. In fact, the formula is hardly ever the best way to proceed, particularly when assumptions about linear independence of the columns of $X$ cannot be made. 
 
   

\item The data set {\tt CPS1988} is found in the {\bf AER} package. Read the description and activate it. 
 
\begin{enumerate}
\item Regress the logarithm of the wage on all available regressors plus experience squared. 
 
What is the {\em return} on (i.e. the coefficient estimate of) {\tt education} for this model? 
\item Now test the relevance of {\tt ethnicity} using the function {\tt anova()} (firstly, create a model without {\tt ethnicity}).
 
\noindent What are your conclusions? 
\vspace{5mm}

\noindent {\bf Note}: If {\tt cps\_lm} is the model with ethnicity, you can create the model without {\tt ethnicity} using the {\tt update} command:
\begin{verbatim}
&gt; cps_noeth2 &lt;- update(cps_lm, formula = .~.-ethnicity)
\end{verbatim}

\item Now use the package {\bf lmtest} to get a Wald test. 
\begin{verbatim}
&gt; install.packages("lmtest")
&gt; library("lmtest")
&gt; waldtest(cps_lm,.~.-ethnicity)
\end{verbatim}
What are your conclusions? 
\end{enumerate}
\thispagestyle{plain}

\item Consider the data set {\tt PSID1982} in the {\bf AER} package. 
\begin{enumerate}
\item Regress the logarithm of the wage on all regressor variables plus experience squared.
\item Consider the {\tt boxcox()} function in {\bf MASS} for deciding on the best transformation. Is the logarithm a good choice of transformation? If not, suggest a better one.
\item Does gender interact with education and / or experience?
\item Consider the possible models including and excluding interactions. Which model seems best to you? Consider $R^2$ adjusted, AIC and BIC criteria for deciding between models with different numbers of parameters.
\end{enumerate}

\thispagestyle{plain}

\end{enumerate} 
</pre></body></html>