Exercises the coming week
Week 10
Exercises from the book: 4.2 and 5.1
Exercises from ISLR: 4.9 and 4.14 (a-f)
Exam STK2100 2018: Problem 2
Extra exercise 6
Exercises for past weeks
Week 9
Exercises from the book: 4.1
- Solution: Berit's suggested solution (similar to the one in the solution manual, but with an argument for why the solution is the eigenvector corresponding to the largest eigenvalue of \(\mathbf{W}^{-1} \mathbf{B}\))
Exercise from ISLR: 4.13 (without KNN)
- Solution: R script.
Extra exercise: Modify the example with principal component (PC) regression in the R script r-code-week7.R, so that the numbers of principal components are selected through cross-validation instead of through separate training and test sets. Comment on the results.
- Solution: R script.
?
Week 8
Exercises from the book: 3.2 and 3.29:
- Solutions: For ex. 3.2, see Vera’s script from last year or Lars’ script from 2023. For ex. 3.29, see here (which is similar to this one, but I have added some details and corrected a small typo). Detailed discussions of both exercises can also be found in this solution manual.
Exercises from ISLR: 3.9 a)-c) and e)-f)
- Solutions: See here.
?
Week 7
Exercises from ISLR: 3.3. 3.4, 3.6, and 3.7
- Solutions: See here.
Extra exercises 4 and 5 (you will need this: extra4.r)
- Solutions: See Vinni's solutions and extra4_extended.r.
?
Week 6
Exercises from ISLR: 3.8 and 3.5
- Solutions: See?Vinni's solutions,?this one?or?that one.
Extra exercises (see link above): 1, 2 and 3?
- Solutions:?See?Vinni's solutions, except 2d, for which you can see?Vera's solution?(the lower bound is simply \(\sigma^2\), attained when \(f(x) = g(x)\)). For exercise 1, there are also?Geir's solutions?(excluding the R-part).?
?
Week 5
Exercises from the book: 2.7
- Solutions: See the slides from the exercise session here. Alternatively, see pages 8-9 here, but note a few typos. In (a) for linear regression: \(\hat\beta\) should be \((X^TX)^{-1}X^Ty\) and not \(X(X^TX)^{-1}X^Ty\). For k-NN, a \(y_i\) is missing in the expression. In (b) you should add and subtract \( \mathrm{E}_{\mathcal{Y}|\mathcal{X}}[\hat{f}(x_0)] \) instead of \( \mathrm{E}_{\mathcal{Y}|\mathcal{X}}[f(x_0)] \), and similarly with the unconditional expectation in exercise (c).
Exercises from ISLR: 2.1, 2.2, and 2.8 (see the webpage for the book for downloading data; the easiest alternative is to install the ISLR library (through the command install.packages("ISLR")), make the library available (through the library("ISLR")), and then make the data available through data(College)).
- Solutions:?link to R-file.