On rstudio please help me… I answered 1 through 4 so I just need…

Question On rstudio please help me… I answered 1 through 4 so I just need… On rstudio please help me… I answered 1 through 4 so I just need answers from 5 to 7… First, load the data as follows:“`{r, message = FALSE}## install.packages(“mediation”) RUN THIS LINE IF TO INSTALL THE PACKAGElibrary(tidyverse)library(caret)library(rpart.plot)jobs <- mediation::jobs```and familiarize yourself with the data by looking at the (admittedly sparse)documentation:```{r, eval = FALSE}?mediation::jobs```#1We are only interested in a small number of variables in this dataset: age,sex, race, education, degree of economic hardship, and depression level. Use`dplyr` to reduce the dataset to just these variables.```{r, eval = FALSE}## Modify the code below and set eval = TRUE so that it runs when you knit## your filelibrary(dplyr)as.tibble(jobs)job=jobs%>%  dplyr::select(age,sex,depress1,depress2,educ,econ_hard)job“`#2 The depression score, `depress1`, is a measure of depression taking valuesbetween 1 and 5. Fit a classification and regression tree (CART) to this datasetusing the `rpart` function and visualize the result using `rpart.plot`. Speakingqualitatively, which variables appear to be the most important for predictingdepression?“`{r}depress1=factor(jobsd$depress1)depress1CART=rpart(depress1~age+sex+econ_hard+depress2+educ,method=”class”,data=job)CARTrpart.plot(CART)summary(CART)#most important variables are depress2,econ_hard,age“`  #3 Remember that how deep a decision tree is grown depends on the _complexityparameter_ `cp` and the minimum number of observations associated to eachnode `minsplit`. Refit the CART model with `cp = 0.006` and `minsplit = 5` andplot the result. How do the results compare to the previous question?“`{r}CART1=rpart(depress1~age+sex+econ_hard+depress2+educ,method=”class”,data=job,minsplit=5,cp=0.006)CART1rpart.plot(CART1,box.palette = 0)summary(CART1)# the most important variables are depress2,econ_hard,educ,ageprobabilities=predict(CART1,type=”prob”)probabilitiessummary(probabilities)“` #4 Referring to the figure in the previous question, what group of people doesthe decision tree determine to have the _lowest_ level of depression on average?What about the _highest_?The people with lowest probability of depression are educated people of factor 5 with probability of 0.28.People with highest probability of depression are educated people of factor 2 with probability of 0.4. # 5 In order to prevent overfitting, it is ideal to choose `cp` usingcross-validation. The following code creates a collection of `cp`’s to evaluate:“`{r}possible_cps <- data.frame(cp = 10^seq(from = -1, to = -5, length = 30))```**Use `10` replications of `20`-fold cross-validation to find the best value of`cp` with `minsplit = 2`.** Then use `rpart.plot` to see how this compares withthe default tree from Question 2. **How does this tree differ from the treefrom Question 2?**```{r, warning = FALSE}## Setting up the cross-validationset.seed(23849)control <- rpart.control(minsplit = 2)## Your R-code here## train_control <- ...## tuned_rpart <- ...```#6 For comparison, let's see how this compares to the linear regression model.Fit a linear regression of `depress1` on everything and then run `summary()`on the fit.```{r}## Your code here```**Based on the fit, given two individuals, one of whom is male and the other ofwhom is female, but who are otherwise identical in terms of sex, age, etc., howmuch higher/lower of a depression score is the female expected to have relativeto the male?**  # 7 Let's now see which of the two approaches (linear regression or a decision tree)performs best in terms of predictive performance. Do the same cross-validationexperiment on the linear regression model that you did on the CART. Which ofthe two methods performs best in terms of RMSE?```{r}## Setting up the cross-validationset.seed(23849)## Your code here; we are using the same train_control from earlier## cv_lm <- train(..., trControl = train_control)```  Engineering & Technology Computer Science SDS 321 Share QuestionEmailCopy link Comments (0)