Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

give the code for this part(Cross validation). 4. Cross-validation: in class we talked about cross-validation (CV) as a way to select the best model by

  give  the code for this part(Cross validation).
image

4. Cross-validation: in class we talked about cross-validation (CV) as a way to select the best model by estimating "test error". In k-fold CV, each of k equally sized random partitions of data (chunks) are used in a heldout set (called validation set or test set). After k runs, we average the held-out error as our final estimate of the validation error. For this part, we will run cross-validation on only a single model, as a way to estimate our test error for future predictions (we are not using it here for model selection since we are considering only one model). Perform 6-fold cross-validation on this model to estimate the (average) test error. (a) First randomly partition data into 6 equal sized chunks. Use set.seed (10) before cut/sample. Hint: a simple way to randomly assign each observation to a chunk is to do the following. First, use cut (..., label=FALSE) to divide observation ids (1, 2, ...) into roughly equal numbers of chunk ids. Then, randomize output of cut () by using sample(). (b) Perform 6-fold cross-validation with training error and validation errors of each chunk determined from (4a). Since same computation is repeated 6 times, we can define the following function for simplicity. do. chunk

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial Management for Public Health and Not for Profit Organizations

Authors: Steven A. Finkler, Thad Calabrese

4th edition

133060411, 132805669, 9780133060416, 978-0132805667

More Books

Students also viewed these Computer Network questions

Question

What is accounting?

Answered: 1 week ago