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

Introduction to epidemiology assignment -assignment should

Introduction to Epidemiology Assignment - Assignment should be typed, with adequate space left between questions. Read the following paper, and answer the questions below: Sundquist K., Qvist J. Johansson SE., Sundquist ...

Question 1 many high school students take the ap tests in

Question 1. Many high school students take the AP tests in different subject areas. In 2007, of the 144,796 students who took the biology exam 84,199 of them were female. In that same year,of the 211,693 students who too ...

Basic statisticsactivity 1define the following terms1

BASIC STATISTICS Activity 1 Define the following terms: 1. Statistics 2. Descriptive Statistics 3. Inferential Statistics 4. Population 5. Sample 6. Quantitative Data 7. Discrete Variable 8. Continuous Variable 9. Qualit ...

Question 1below you are given the examination scores of 20

Question 1 Below you are given the examination scores of 20 students (data set also provided in accompanying MS Excel file). 52 99 92 86 84 63 72 76 95 88 92 58 65 79 80 90 75 74 56 99 a. Construct a frequency distributi ...

Question 1 assume you have noted the following prices for

Question: 1. Assume you have noted the following prices for paperback books and the number of pages that each book contains. Develop a least-squares estimated regression line. i. Compute the coefficient of determination ...

Question 1 a sample of 81 account balances of a credit

Question 1: A sample of 81 account balances of a credit company showed an average balance of $1,200 with a standard deviation of $126. 1. Formulate the hypotheses that can be used to determine whether the mean of all acc ...

5 of females smoke cigarettes what is the probability that

5% of females smoke cigarettes. What is the probability that the proportion of smokers in a sample of 865 females would be greater than 3%

Armstrong faber produces a standard number-two pencil

Armstrong Faber produces a standard number-two pencil called Ultra-Lite. The demand for Ultra-Lite has been fairly stable over the past ten years. On average, Armstrong Faber has sold 457,000 pencils each year. Furthermo ...

Sppose a and b are collectively exhaustive in addition pa

Suppose A and B are collectively exhaustive. In addition, P(A) = 0.2 and P(B) = 0.8. Suppose C and D are both mutually exclusive and collectively exhaustive. Further, P(C|A) = 0.7 and P(D|B) = 0.5. What are P(C) and P(D) ...

The time to complete 1 construction project for company a

The time to complete 1 construction project for company A is exponentially distributed with a mean of 1 year. Therefore: (a) What is the probability that a project will be finished in one and half years? (b) What is the ...

  • 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