---
title: " HW Question Week 10 "
author: "STA2101F 2021"
date: ''
output:
  pdf_document: default
  html_document: default
fontsize: 12pt
---


```{r setup, include=FALSE}
# knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(
  echo = FALSE,
  message = FALSE,
  warning = FALSE,
  error = FALSE, 
  out.width = "100%",
  fig.width = 10,
  fig.height = 6.7, 
  fig.retina = 3,
  cache = FALSE)
```
```{r library}
library(faraway)
library(MASS)
data(death)
```

## Due December 2 2021 11.59 pm

**Homework to be submitted through Quercus**

  (a) *Adapted from ELM Ex. 4.4 (1st edition, Ex.6.4 2nd edition)*  The dataset `death`  in the library `faraway` cross-classifies death penalty sentences according to the race of the defendant and the race of the victim.  
    (i) Construct a summary table showing the association of race of defendant with the sentence (death-penalty yes or no), and compute the $\chi^2$ test of independence.  
    (ii) Do this separately for the two tables formed by considering the race of the victim. 
    (iii)  Compare the results to those obtained from a binomial regression with sentence (death-penalty yes or no) as the response and the explanatory variables race of defendant and race of victim.  
  (b) *SM Ex. 8.2.9* Consider a normal linear model $y = X\beta + \epsilon$, where $\text{var}(\epsilon) = \sigma^2 W^{-1}$ and $W$ is a known positive definite symmetric matrix.   
    (i)  Re-express the least squares problem in terms of $y_1= W^{1/2}y$, $X_1 = W^{1/2}X$, and $\epsilon_1=W^{1/2}\epsilon$.  
     (ii) Show that $\text{var}(\epsilon_1)=\sigma^2I_n$.  
    (iii) Find the least squares estimates, hat matrix, and residual sum of squares for the re-expressed regression, in terms of the original $y$, $X$, and $W$.  
    
  (c) *Bonus/Required for PhD* Suppose that $W$ depends on an unknown scalar parameter $\rho$. Find the profile log-likelihood function for $\rho$: $\ell_{\text p}(\rho) = \max_{\beta,\sigma^2}\ell(\beta,\sigma^2,\rho)$, and outline how to use a least squares algorithm to provide a confidence interval for $\rho$. 

 


     
