Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Statistics and Probability Expert

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 (http://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 http://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

Statistics and Probability, Statistics

  • Category:- Statistics and Probability
  • Reference No.:- M91978330
  • Price:- $120

Guranteed 48 Hours Delivery, In Price:- $120

Have any Question?


Related Questions in Statistics and Probability

Recent test scores on the law school admission test lsat

Recent test scores on the Law School Admission Test (LSAT) are normally distributed with a mean of 162.4 and a standard deviation of 15.9. What is the probability that the mean of 12 randomly selected scores is less than ...

Now assume that i am talking about a normally distributed

Now assume that I am talking about a normally distributed set of data: An IQ test. This IQ test has a mean of 100 and a standard deviation of 15. Find the following probabilities What is the probability that someone scor ...

An athletics coach states that the distribution of player

An athletics coach states that the distribution of player run times (in seconds) for a 100-meter dash are normally distributed with a mean equal to 14.00 and a standard deviation equal to 0.2 seconds. What percentage of ...

Next time you see an elderly man check out his nose and

Next time you see an elderly man, check out his nose and ears! While most parts of the human body stop growing as we reach adulthood, studies show that noses and ears continue to grow larger throughout our lifetime. In o ...

A media rental store rented the following number of movie

A media rental store rented the following number of movie titles in each of these catagories: 160 horrors, 242 drama, 114 mystery, 308 romance, and 134 comedy. If a person selects a movie to rent, find the probability th ...

Suppose thatnbspx1nbspx2 nbspx100nbspis a sample from a

Suppose that  X 1 ,  X 2 , ...,  X 100  is a sample from a normal distribution whose  Sample Mean  has a  N (3,3) distribution. What is the population distribution? (note: specify parameters of the distribution)

Assume that the fisherman can use between 5 and 8 lines

Assume that the fisherman can use between 5 and 8 lines. With 5 lines, the probability of a catch on each line is 0.71. With 6 this probability is 0.63, with 7 it is 0.51, and with 8 the probability is 0.43. 1) How many ...

Fifty-seven percent of employees make judgements about

Fifty-seven percent of employees make judgements about their co-workers based on the cleanliness of their desk. You randomly select 8 employees and ask them if they judge co-workers based on this criterion. The random va ...

A car gets involved in an accident 80 of the time if it is

A car gets involved in an accident 80% of the time if it is defective. If it is not defective, the probability reduces to 40%. 30% of all cars are defective. If a car is involved in an accident, what is the probability t ...

The jo supplies company buys calculators from a korean

The J.O. Supplies Company buys calculators from a Korean supplier. The probability of a defective calculator is 20%. If 15 calculators are selected at random, what is the probability that less than 5 of the calculators w ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As