In: Statistics and Probability
Use R statictical software. Load the ISLR package to get the
Auto data set. Fit below non-linear models to the Auto data set. We
will treat horsepower as the predictor and mpg as the
response.
• Fit the cubic spline with 3 knots (25th percentile, 50th
percentile, and 75th percentile of horsepower)
• Fit the natural spline with 3 knots (25th percentile, 50th
percentile, and 75th percentile of horsepower)
• Fit the smoothing spline by choosing optimal lambda with
cross-validation. (Hint: cv = TRUE can be used inside
smooth.spline() function to choose optimal lambda with
cross-validation.)
• Fit the local regression with span = 0.75.
Also, plot the data and add the non-linear fits to the
plot