Question: 1. Write your own code to implement the following simulation scheme: (1) Set sample size N = 125 (2) Set number of features p (treat
1. Write your own code to implement the following simulation scheme: (1) Set sample size N = 125 (2) Set number of features p (treat p as a variable) (3) Independently simulate each feature data by rnorm(N), the collection of all the feature data is denoted by X (4) Simulate regression coefficient by rnorm(p) (5) Simulate outcome Y by Y = X + e, where e N(0, I) Vary p from 10, 20, 30, 40, ..., 100 to generate 10 datasets, and answer the following questions: (i) Find the least-squares solution and compute the training error for each dataset (ii) Implement a 2-fold CV procedure and estimate the EPE for each dataset (iii) Implement a 10-fold CV procedure and estimate the EPE for each dataset (iv) Plot the training error, EPE by 2-fold and 10-fold CV procedures versus model complexity p in a single plot (v) Comment on the observed patterns
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
