联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Algorithm 算法作业Algorithm 算法作业

日期:2020-04-05 11:25

Lab 8 Assignment

The assignments must be in the correct format.

? All code you write in R must be compiled using R-Markdown with the output and answers

into MS-Word or PDF formats.

– The assignment must be done using R-Markdown. The output of this document will

include all the R code, R output and answers to the questions. Answers must be

written in full sentences.

Questions

1. This question is based on Question 6, Chapter 7, Page 299. Please modify as below.

(a) This question will perform polynomial regression to predict wage using age. Use

cross-validation to select the optimal degree d for the polynomial. What degree is

chosen and what is the test error obtained from cross validation?

Fit the model of degree d to the whole data and make a plot of the resulting polynomial

fit to the data.

(b) This question will look at a step function to predict wage using age. Use cross

validation to choose the optimal number of cuts. What is the number of cuts chosen

and what is the test error obtained from cross validation. For this assignment set the

maximum number of cuts to be 8.

Fit the model with the selected number of cuts to the whole data and plot the fit

obtained.

2. You are looking at two models in Question 1. Choose a preferred model from these two

and briefly discuss why it was chosen.

3. This question is based on Question 9, Chapter 7, Page 299.

(a) This question will look using a natural spline ns() to predict nox using dis. Use

cross-validation or another approach to select the best degrees of freedom for the

spline. What degrees of freedom were selected and what was the test error?

Fit a natural spline model with the select degrees of freedom on the whole data and

plot the resulting fit to the data.

(b) Fit a smoothing spline to the data using cross validation to select the degrees of

freedom. What degrees of freedom were selected? Plot the resulting fit on the data.

(c) Fit a local regression using the loess() function. Use the span of 0.375 to define

the neighbourhood (37.5%). Plot the resulting function on the data.

This just leaves generalized additive models. You can try this on your own time.


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp