Reference no: EM131222395
Read ISL p.43-51, the Lab section of chapter 1. This is a good getting-started guide to R. To follow along you will need to download the data sets from Data Sets and Figures from the ISL website (https://www-bcf.usc.edu/~gareth/ISL/data.html).
Return to the R script file provided for Lecture 1 and review the code.
2. Answer Q8 of ISL Chapter 2. You can skip part c(vi).
3. Q9 of ISL Chapter 2.
4. Q10 of ISL Chapter 2.
5. (Pivot tables in R) "UC Salary 2014.xlsx" contains 2014 salary information for UC Irvine and Riverside, and it is extracted from https://ucpay.globl.org/.
a) Read the data into R and report the variables in the dataset.
Suppose we want to create a pivot table for the median gross salary for various combinations of campus and titles that include the term "PROF-HCOMP". In other words:
While Excel's native pivot table can compute the average salary for each campus-title combination, it cannot do the same for statistics like the median. R on the other hand can do it using any statistic. We will create the table above using the following steps.
b) Create a new dataset in R by selecting the rows of the salary table that contain the term "PROF-HCOMP" in the TITLE field. Note that "HS CLIN PROF-HCOMP" also contains the term, for example. The command grep("PROF-HCOMP", X) will return TRUE for each entry in the variable X that contains the term, and FALSE otherwise. How would you use it to create the new dataset?
c) The TITLE field of the subsetted data contains only titles with the terms "PROF-HCOMP". Yet if you type in "levels(newdata$TITLE)" you will still get a list of all the original titles. What happens if you reset the factor levels of TITLE by entering "newdata$TITLE = factor(newdata$TITLE)"?
d) Create the pivot table above using the aggregate() function introduced in the lecture on hierarchical clustering. To report median salary by campus-title combination, simply enter "aggregate(GROSS~CAMPUS+TITLE, newdata, median)". You can replace the median function with any other statistic e.g. mean().
6. (Based on DMBI p190, problem 9.4) The file Modified Corolla.xlsx contains data on used Toyota Corollas on sale during late summer of 2004 in the Netherlands. The data is a version of the example we studied in class. It has 1,436 observations containing attributes such as Price, Age, Kilometers, HP, and other specifications. The goal is to predict the price of a used Corolla based on its specifications using a regression tree.
a) Read the file into R as the dataset "car". Use the is.factor() function to check if Fuel_Type is stored as a categorical variable. If it is not, tell R that it should be treated as such using the command "car$Fuel_Type = factor(car$Fuel_Type)".
b) Split the dataset 80/20 into training/validation.
b) Fit a regression tree to the output variable Price and all other input variables. Use the minimum error tree to score the test data, and draw the tree. What are the two most important variables for predicting the car's price? What is the RMS error for the test set?
c) Fit a linear regression model to the same training set, and use Best Subset search to find the best subset of variables for a given subset size. Based on the adjusted R2 output you should see that 15 to 17 variables are best. Recall that neither measure depends on the validation set. Hence use the validation RMS error to choose between these models. Which variables are dropped by the chosen model? Are they used in the regression tree? Compare the test RMS error of the chosen model to the test error of the tree.
Hint: Everything you need for this question is in the script files for the lectures on linear regression and regression trees. Consult also ISL sections 3.6.2-3.6.3 and 8.3.2.
Attachment:- Assignment.rar
Reconsider ethical relativism
: Do you agree that the Holocaust is a clear instance of where a cross-cultural judgment about moral wrong and right can be made?
|
Calcutta the weighted average cost
: The cost of financing with retained earnings is 14%, the cost of preferred stock financing is 11% and the before tax cost of debt financing is 11%. Calcutta the weighted average cost of capital (WACC) given a tax rate of 25%.
|
Determining the capital structure
: You do not have to select three companies listed on the same exchange; however, the companies selected must have information that is readily and easily accessible, such as through the firm's Web site. Specifically, you will need to research the fo..
|
Describe impact on banks of collapse of the currency board
: During the time of the currency board, Argentinean banks offered accounts in both dollars and pesos, - Describe the impact on banks of the collapse of the currency board.
|
Create a pivot table for the median gross salary
: MGT 819 Homework - Suppose we want to create a pivot table for the median gross salary for various combinations of campus and titles that include the term "PROF-HCOMP".
|
What do you think of salvatierra argument
: What do you think of Salvatierra's argument? Do you think other organizers can learn anything from faith-based organizers? Vice-versa? Why or why not? Is faith-based organizing beneficial for society? Why or why not?
|
Upcoming wedding and plan to take year-end vacations
: Instead of her schooling, your parents are paying $8,000 for her upcoming wedding and plan to take year-end vacations costing $5,000 per year for the next three years.
|
Investment fund for the eastern football league
: You are chairperson of the investment fund for the Eastern Football League. You are asked to set up a fund of semiannual payments to be compounded semiannually to accumulate a sum of $100,000 after 10 years at an 8 percent annual rate (20 payments..
|
How could concern over an election drive up the risk premium
: How could concern over an election drive up the risk premium? - How was the risk premium connected to the value of the currency?
|