Create a pivot table for the median gross salary

Assignment Help Basic Statistics
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

Reference no: EM131222395

Questions Cloud

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?

Reviews

Write a Review

Basic Statistics Questions & Answers

  Find probability of among three children there is one girl

Find the probability of Among three children, there is exactly one girl. Among three children, there are exactly two girls. Among three children, all are girls.

  Write down both the null and alternative hypotheses

Check any assumptions of the hypothesis test; Write down both the null and alternative hypotheses; Carry out the t test and report the p-value, and the test statistic.

  Determining five step hypothesis test

Test the null hypothesis that a population mean is 50 against the alternate hypothesis that the mean is not 50. What "model" should be used and why?

  The outcome is patients self-reported effect of treatment

a study is designed to investigate whether there is a difference in response to various treatments in patients with

  Correlation coefficient between two variables

Suppose we found the correlation coefficient between two variables, X and Y, to be r = 0.95. Which of the following is most appropriate?

  Find x1 such that pxgtx1 06 consider an interval for x

assume x is normally distributed with a mean of 12 and a variance of 16.a calculate p9ltxlt17b find x1 such that pxgtx1

  A new screening test for a disease has a sensitivity score

a new screening test for a disease has a sensitivity score of .89. which of the following statements are true of this

  The relationship among variables is sufficient to warrant

Describe the data appear the strength of the relationship among variables is sufficient to warrant using linear regression forecasting.

  Binomial probability density function

Identify each variable in the formula for the binomial probability density function. Also, explain what the fraction: n! / (n-x)!x! calculates.

  Percentile of the thickness distribution

The shell thicknesses of the eggs produced by a large flock of hens follow approximately a normal distribution with mean equal to 0.38 mm and standard deviation equal to 0.03 mm. Find the 95th percentile of the thickness distribution.

  Find some conditional probabilities

Beth knows the probabilities for her genetic types from part (c) of the previous exercise. She marries Bob, who is albino. Bob's genetic type must be aa.

  Find mean and standard deviation for sampling distribution

If the population mean for how much alumni spend is $115.50 per week eating out socially, what is the mean and standard deviation for the sampling distribution of x?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd