Exercises 27.5 Homework
1.
Modify Example 27.2.2 so that it runs a loop over degrees from 1 to 7 and within that loop, \(R^2\) is computed for each degree \(d\text{.}\) The code should find the value of \(d\) with maximal \(R^2\text{,}\) display this \(R^2\) value, and plot the graph of polynomial with optimal \(d\text{.}\)
2.
The number of active Covid cases at SU during October 1 - October 23, 2020, is given below.
y = [5 5 4 5 9 25 45 65 77 87 87 89 97 101 90 74 57 26 20 13 12 12 13]';
A good choice for x-values is x = (-11:11)'
because centering the interval at 0 improves the performance of the monomial basis.
Write a script that takes degree \(d\) as input, fits a polynomial of degree \(d\) to the data, displays the t-statistic for the leading coefficient as in Example 27.3.1, and plots the polynomial together with the data points. What value of \(d\) works best for this data, based on the t-statistic and the plot?