\documentclass[11pt]{article} %\usepackage{amsbsy} % for \boldsymbol and \pmb %\usepackage{graphicx} % To include pdf files! \usepackage{amsmath} \usepackage{amsbsy} \usepackage{amsfonts} %\usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=blue, urlcolor=blue]{hyperref} % For links \usepackage{fullpage} % Good for US Letter paper \topmargin=-0.75in \textheight=9.5in \usepackage{fancyhdr} \renewcommand{\headrulewidth}{0pt} % Otherwise there's a rule under the header \setlength{\headheight}{15.2pt} \fancyhf{} \pagestyle{fancy} \cfoot{Page \thepage {} of 2} % %\pagestyle{empty} % No page numbers \begin{document} %\enlargethispage*{1000 pt} \begin{flushright} Name \underline{\hspace{60mm}} \\ $\,$ \\ Student Number \underline{\hspace{60mm}} \end{flushright} \vspace{5mm} \begin{center} {\Large \textbf{STA 442/2101 F 2012 Quiz 7}}\\ \vspace{1 mm} \end{center} \begin{enumerate} \item (5 Points) In a study of energy efficiency, data are collected on $n$ houses. The houses have three different chimney types: Rectangular, Round and Square. Consider a regression model in which the response variable is energy consumption, and the explanatory variables are age of house ($x_1$) and Chimney Type. \begin{enumerate} \item \label{EY} Write $E[Y|\mathbf{X}]$ for the full model. You do \emph{not} need to say how the dummy variables are defined. You will do that in the table below. \vspace{7mm} %\begin{displaymath} % E[Y|\mathbf{X}] = \beta_0 + \beta_1 x_1 + \beta_2 x_2 %\end{displaymath} \item In the table below, make columns showing how the indicator dummy variables for Chimney Type are defined. \emph{Make Rectangular the reference category}. At the top of each column, write the name of a dummy variable from your answer to Question~\ref{EY}. Finally, put $E[Y|\mathbf{X}]$ for each Chimney Type in the last column. \vspace{3mm} \begin{tabular}{|l|c|c|} \hline & \hspace{40mm} & \hspace{20mm}$E[Y|\mathbf{X}]$\hspace{20mm} \\ \hline Rectangular Chimney & & \\ \hline Round Chimney & & \\ \hline Square Chimney & & \\ \hline \end{tabular} %\begin{tabular}{|l|c|c|c|} \hline % & $x_1$ & $x_2$ & % \hspace{20mm}$E[Y|\mathbf{X}]$\hspace{20mm} \\ \hline %Rectangular Chimney & 0 & 0 & $\beta_0$ \\ \hline %Round Chimney & 1 & 0 & $\beta_0+\beta_1$ \\ \hline %Square Chimney & 0 & 1 & $\beta_0+\beta_2$ \\ \hline %\end{tabular} \item Give the null hypothesis you would test to answer each one of the following questions. In each case, the answer is a statement involving the $\beta$ symbols from your model. Remember, we never do one-sided tests. \begin{enumerate} \item Controlling for age of house, is chimney type related to a house's energy consumption? \vspace{10mm} \item Controlling for chimney type, do older houses use more energy? \vspace{10mm} \item Controlling for age of house, do houses with round chimneys use the same average amount of energy as houses with square chimneys? \vspace{10mm} \item Controlling for age of house, compare the expected energy consumption of houses with round chimneys to the \emph{average} of the expected energy consumption of houses with square chimneys and the expected energy consumption of houses with rectangular chimneys. Simplify and \textbf{circle your final answer.} \end{enumerate} \end{enumerate} % Marking for this question probably should not be one point for each part. The way (a), (b) and (c) fit together matters. \newpage \item (3 points) This question is based on your printout from the birth weight data. \textbf{\emph{Write your answers in the blanks below, and also circle them on your printout.} On the printout, label the answers 2a, 2b etc.} \begin{enumerate} \item \underline{\hspace{30mm}} Give just the value of the $t$ or $F$ statistic used to answer this question: Controlling for mother's age and race, is the mother's weight related to her baby's weight? The answer is a single number from your printout. \item \underline{\hspace{30mm}} Give just the value of the $t$ or $F$ statistic used to answer this question: Are \emph{any} of the explanatory variables related to baby's birth weight? The answer is a single number from your printout. \item \underline{\hspace{30mm}} \label{BO} Give just the value of the $t$ or $F$ statistic used to answer this question: Controlling for mother's age and weight, do Black and Other mothers differ in the mean weights of their babies? The answer is a single number from your printout. \end{enumerate} \item (2 points) In plain, non-statistical language, what do you conclude from the test of Question~\ref{BO}? You have more room than you need. \end{enumerate} \vspace{140mm} \begin{center}\textbf{Attach your printout for Question 2 (Homework Question 9). Make sure your name is written on the printout.}\end{center} \end{document} attach(birthwt) race <- factor(race, labels = c("white", "black", "other")) fullmod = lm(bwt ~ age + lwt + race); summary(fullmod) # Switch contrasts to test Black vs other race2 = race contrasts(race2) = contr.treatment(3,base=3) # Other will be ref summary(lm(bwt ~ age + lwt + race2)) # Race controlling for age and weight red1 = lm(bwt ~ age + lwt) anova(red1,fullmod) # Age and weight controlling for race red2 = lm(bwt ~ race) anova(red2,fullmod) # Race controlling for age and weight with a general linear test. # Need car. Compare F = 4.7799 L = rbind(c(0,0,0,1,0), c(0,0,0,0,1) ) linearHypothesis(fullmod,L) # With White as the reference category, repeat the test comparing # Black to Other controlling for age and weight. # Compare F = (-1.222)^2 = 1.493284 L = rbind(c(0,0,0,1,-1)) linearHypothesis(fullmod,L)