Question: Please answer and show code output for each part of the question 1. Write Your Own Function - SCAD penalty function (40 points) SCAD penalty
Please answer and show code output for each part of the question

1. Write Your Own Function - SCAD penalty function (40 points) SCAD penalty function is defined as: if |x| $ 1 if 1 3 This function is linear on the interval [-1,1], quadratic on the interval [-3,-1] and [1,3] and constant outside of [-3,3). It transitions from linear to quadratic and then to constant "smoothly", and looks like this: 1.5 scad(x) 0.5 0.0 -2 2 X It is often used in the varible selection. Interested in more? Read the paper: Variable Selection via Nonconcave Penalized Likelihood and its Oracle Properties (Fan and Li, 2001). . la. Write a function scad () that takes as an input a number r, and returns the SCAD value w(z), as defined above. Hint: the body of a function is just a block of R code, e.g., in this code you can use if () and else () statements. Check that scad(1) returns 1, and scad(4) returns 2. . 1b. The scad function can be modified so that the transition from quadratic to constant happens at an arbitrary cutoff value a, as in: if la| $ 1 if 1 a Here a is required to be larger than 2. Starting with your solution code to the last question, update your scad() function so that it takes two arguments: a, a number at which to evaluate the loss, and a a number representing the cutoff value. If a $ 2, the return value should be NULL. It should now return va(x), as defined above. Check that scad (3, 3) returns 2, and scad (6, 4) returns 2.5. . le. Update your scad() function so that the default value of the cutoff a is 3. Check that acad (5) returns 2. . Id. Check that scad (a-5, x-6) returns 3. Check that scad (5, 6) returns 3.4. Explain why these are different
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
