Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. (10 pts) Use the sample() function to generate a vector named train to split College01 into a training (containing roughly 70% of the observations)

image text in transcribed
image text in transcribed
4. (10 pts) Use the sample() function to generate a vector named train to split College01 into a training (containing roughly 70% of the observations) and a test set (containing the rest). train should contain indices of observations that belong to the training set. Run " set.seed(2)" first in order to ensure reproduciblety of results. How many elements does train have? Print out the first 25 elements in train. > dim(College01.ts) [13 234 19 > set.seed(2) > train - sample(nrow(College01), 0.7'nrom(College01)> train[1:25] [13 144 546 445 131 730 729 108 642 360 423 424 183 582 139 310 651 744 172 338 57 502 293 632 114 262 College01. to - College01[train,] > College01. ts - College01[-train,] > dim(College01.tr) 543 19 > die(College01.ts) [13 234 19 Train has 543 elements. 5. (15 pts) Build a logistic regression model using all appropriate predictors to predict whether a college belongs to " high" or "low" category, i.e., whether a college has higher- or lower- than-average graduation rate. Fit the model using the training data and predict for gr01 in the test set. Show your results. What are the training and test error rates? (Note: need to use the contrasts() function to find out how R codes the values of gr01, i.e., when R automatically converts " high"/"low" to 0/1, the contrasts() function tells us whether " high" or "low" is coded as 1.) 6. (15 pts) Build a linear discriminate analysis (LDA) model using all appropriate predictors to predict whether a college belongs to " high" or "low" category, i.e., whether a college has higher- or lower-than-average graduation rate. Fit the model using the training data and predict for gr01 in the test set. Show your results. What are the training and test error rates? 7. (15 pts) Build a quadratic discriminate analysis (QDA) model using all appropriate predictors to predict whether a college belongs to " high" or "low" category, i.e., whether a college has higher- or lower-than-average graduation rate. Fit the model using the training data and predict for gr01 in the test set. Show your results. What are the training and test error rates

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Chance And Chaos

Authors: David Ruelle

1st Edition

069121395X, 9780691213958

More Books

Students also viewed these Mathematics questions

Question

1. Background knowledge of the subject and

Answered: 1 week ago