Question: 1. Consider the Szeged Weather Data. The average temperature across all years/months is about 12 degrees. Create a new binary variable that is 1 if
1. Consider the Szeged Weather Data. The average temperature across all years/months is about 12 degrees. Create a new binary variable that is 1 if the given month/year is greater than or equal to 12, and 0 otherwise. For the questions below, you may compute any gradients/hessians numerically, but you are to write your own optimization code unless told to do otherwise. (a) Writing out your own gradient descent algorithm, fit a logistic regression model with your new variable as the outcome and WindSpeed as the predictor. Check your answer using both the optim function as well as glm. (b) Now repeat (a), but using Newtons method (i.e. use the Hessian as well as the gradient). Compare the number of iterations it took to converge with the number from (a). (c) We are now going to add on a penalty to the log-likelihood `(0, 1) = `(0, 1) 2 1 . Write an R function that takes 0 as its input and returns the minimizer of the above function using gradient descent. Evaluate this function for several values of and plot 1 as a function of . How does influence the estimate?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
