This homework serves as a practice to the lecture on the Hat matrix.
Grading: 70% problem 1 and 30% for problem 2.
Please describe your results and include R code, and put everything into a SINGLE .pdf document to submit.
The document needs to have a file size less than 1M (file size larger than 1M will automatically incur a 10% of the grade, and a file size larger than 10M will incur a 50% penalty of the grade)
1. In the toy data example (price Vs age of used car).
a) What is the Hat matrix?
b) Verify that the Hat matrix is symmetric and idempotent.
c) Verify that all diagonal entries are in the range of [0,1].
d) What is the trace of the Hat matrix?
2. Verify the following property of matrix trace
trace(AB)=trace(BA)
by running the following R code three times:
A<-matrix(sample(1:5,16, replace=TRUE),4,4);
B<-matrix(sample(1:5,16, replace=TRUE),4,4);
sum(diag(A %*% B))
sum(diag(B %*% A))