Help with d part please
95 () For each model, compute the 10-fold CV estimate for the test error by following the steps: Run the folloring command Tines. 6.r) 97 set.seed(1) # the seed can be arbitrary but we use 1 for the sake of consistency 98 fold.index cut(sampleC1:nrow(Weekly)), breaks-10, labels-FALSE) testIn 101 Write a for loop from i -1 toi - 10 and in each loop, perform each of the following steps: 182 i. Fit a logistic regression model using all but the observations thot satisfy fold.index-i to predict Direction using Logl and Lag? for model train (i) and using Lagi, Lag2, ICLag1'2), I(Lag2'2) for modelCii) 103 ii. Compute the posterior probability of the market moving up for the observations that satisfy 184 fold.index.. 105 iii. Use the posterior probabilities for the observations that satisfy fold.indexei and use the threshold 186 8.5 in order to predict whether or not the market moves up. the error rate was mode in predicting Direction for those observations thot sotisfy 188 fold.index--i 109 Take the average of the 18 numbers obtained in iv in order to obtain the 18-fold CV estinate for the test 118 error. 112 113r 114 error.3repCe, din(heekly)[1]) 115. for (i in 1:10) t test.i 1 and only the first elenent will be usedthe condition has length s 1 and only the first element will be usedthe condition has length >1 and only the first elenent will be usedthe condition has length > 1 and only the first element wilt be usedthe condition has length > 1 and only the first element will be usedthe condition has length 1 and only the first element "in be usedthe condition has length > 1 and only the first elenent will be usedthe condi tion has length > 1 and only the first elenent will be used[1] the condition has length >1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe element will be usedthe condition has length > 1 and only the first element will be usedthe 1 and only the first elenent will be usedthe 95 () For each model, compute the 10-fold CV estimate for the test error by following the steps: Run the folloring command Tines. 6.r) 97 set.seed(1) # the seed can be arbitrary but we use 1 for the sake of consistency 98 fold.index cut(sampleC1:nrow(Weekly)), breaks-10, labels-FALSE) testIn 101 Write a for loop from i -1 toi - 10 and in each loop, perform each of the following steps: 182 i. Fit a logistic regression model using all but the observations thot satisfy fold.index-i to predict Direction using Logl and Lag? for model train (i) and using Lagi, Lag2, ICLag1'2), I(Lag2'2) for modelCii) 103 ii. Compute the posterior probability of the market moving up for the observations that satisfy 184 fold.index.. 105 iii. Use the posterior probabilities for the observations that satisfy fold.indexei and use the threshold 186 8.5 in order to predict whether or not the market moves up. the error rate was mode in predicting Direction for those observations thot sotisfy 188 fold.index--i 109 Take the average of the 18 numbers obtained in iv in order to obtain the 18-fold CV estinate for the test 118 error. 112 113r 114 error.3repCe, din(heekly)[1]) 115. for (i in 1:10) t test.i 1 and only the first elenent will be usedthe condition has length s 1 and only the first element will be usedthe condition has length >1 and only the first elenent will be usedthe condition has length > 1 and only the first element wilt be usedthe condition has length > 1 and only the first element will be usedthe condition has length 1 and only the first element "in be usedthe condition has length > 1 and only the first elenent will be usedthe condi tion has length > 1 and only the first elenent will be used[1] the condition has length >1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe element will be usedthe condition has length > 1 and only the first element will be usedthe 1 and only the first elenent will be usedthe