Question

In: Statistics and Probability

Question 2 The rest of the questions deal with the Motor Trend Car and Sport data...

Question 2 The rest of the questions deal with the Motor Trend Car and Sport data from 1974

# It is famous dataset called mtcars comes built in to R. Use the line of code below

# to familiarize yourself with it head(mtcars)

## mpg cyl disp hp drat wt qsec vs am gear carb

## Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4

## Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4

## Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1

## Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1

## Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2

## Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1

Question 2a # how many observations are there in this data set?

Question 2b # plot a histogram showing the frequencies of the "cyl" column # as always, make sure the plot is properly labeled.

Question 2c # which car has the highest "qsec"? # which car has the highest "mpg"?

Question 2d The next two questions are great practice for your final project! 1 # plot a scatter plot of mpg vs qsec. Are the variables correlated? If so, are they # negatively correlated or positively correlated?

Question 2e # plot a scatter plot of mpg vs disp. Are the variables correlated? If so, are they # negatively correlated or positively correlated?

Solutions

Expert Solution

R code with comments (all statement starting with # are comments and can be removed)

#Question 2a
# how many observations are there in this data set?
n<-nrow(mtcars)
sprintf('Number of observations in this data set is %g',n)

#output

#Question 2b
# plot a histogram showing the frequencies of the "cyl" column
# as always, make sure the plot is properly labeled.
hist(mtcars$cyl,main='Histogram of number of cylinders',xlab='# of Cylinders')

#get this plot

#Question 2c
# which car has the highest "qsec"?
cname<-rownames(mtcars)[which.max(mtcars$qsec)]
sprintf('The car that has the highest "qsec" is %s',cname)
# which car has the highest "mpg"?
cname<-rownames(mtcars)[which.max(mtcars$mpg)]
sprintf('The car that has the highest "mpg" is %s',cname)

#get this output

#Question 2d The next two questions are great practice for your final project! 1
# plot a scatter plot of mpg vs qsec.
plot(mtcars$qsec,mtcars$mpg,xlab="qsec",ylab="mpg",main="mpg vs qsec")

#get this plot

Are the variables correlated?

Yes the 2 variables are correlated, as we can see an approximate linear relationship between qsec and mpg.

We can see that as the value of qsec (time taken to cover 1/4 mile) increases, the mpg increases (slower car has higher mileage).

That means we can say that there are positively correlated

# Question 2e
# plot a scatter plot of mpg vs disp.
plot(mtcars$disp,mtcars$mpg,xlab="disp",ylab="mpg",main="mpg vs disp")

#get this plot

Are the variables correlated?

Yes the 2 variables are correlated, because we can see an approximate linear relationship between disp and mpg.

We can see that as the value of disp (volume of engine displacement ) increases, the mpg decreases (higher volume engine has lower mileage).

That means we can say that there are negatively correlated


Related Solutions

The Motor Trend Car Road Tests dataset (mtcars.csv) contains the data extracted from the 1974 Motor...
The Motor Trend Car Road Tests dataset (mtcars.csv) contains the data extracted from the 1974 Motor Trend US magazine and comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models). The dataset contains 32 observations on 11 variables. Analyze the dataset according to the following steps: 1. Calculate sample mean and sample variance of each variable. 2. Calculate the sample variance-covariance matrix and the sample correlation matrix. What can you say about the variance-covariance...
Using the Motor Trend Car Road Tests dataset mtcars, in faraway R package, fit a model...
Using the Motor Trend Car Road Tests dataset mtcars, in faraway R package, fit a model with mpg: Miles/(US) gallon as the response and the other variables as predictors. (a) Which variables are statistically significant at the 5% level? For each and every test provide the null and alternative hypotheses, critical region (or rejection region), test statistics and your conclusions. (30) (b) What interpretation should be given to the coefficient for vs: Engine? (3) (c) Compute 90 and 95% confidence...
Use the data below to answer the three questions that follow it. $/£ (USD/GBP) - Sport...
Use the data below to answer the three questions that follow it. $/£ (USD/GBP) - Sport Rate is 1.2360 $/£ (USD/GBP) - 180-day forward rate is 1.2300 $ interest rates are 0.25% (one quarter of a percent or 25 basis points) £ (GBP) interest rates are 1.00% If you could borrow either £ 10,000,000 or $ 10,000,000 how much profit could you make from a covered interest arbitrage? Be sure to state your answer in terms of USD or GPB.
Data are gathered on each car in the motor pool, regarding number of miles (in thousand...
Data are gathered on each car in the motor pool, regarding number of miles (in thousand miles) driven in a given year, and maintenance costs (in thousand dollars) for that year: Part of the linear regression analysis output are shown in below: Car Number 1 2 3 4 5 Miles Driven (x) 80 29 53 13 15 Repair Costs (y) 3.2 2.15 2.65 2.2 2.325 Construct a 95% confidence interval for the conditional mean of y given x0=50. (A) [2.476,...
A car starts from rest and travels east with an acceleration of 4x10^-3 m/s^2. Another car...
A car starts from rest and travels east with an acceleration of 4x10^-3 m/s^2. Another car travels towards west at a constant speed of 70kph. The two cars are 100km apart. a. What is the time it takes for the two cars to meet b. time it takes for them to be 100km apart for the second time
Data protection must be provided at three different levels 1) data at rest 2) data in...
Data protection must be provided at three different levels 1) data at rest 2) data in use and 3) data in motion. Question: provide recommendations and best practice policies that a company must follow in order to protect sensitive data for each one of the 3 different levels
There are 2 different questions, and the data table is below each question. Please answers them...
There are 2 different questions, and the data table is below each question. Please answers them all A drug test is administered to 10000 individuals as indicated in the contingency table below. Determine the specificity, the sensitivity the PPV and NPV of the test. Also give the prevalence of drug use in the population. Would you trust a positive result for this test (meaning does this accurately indicate that you are a drug user?) Would you trust a negative result?...
A car starts from rest at a stop sign. It accelerates at 4.4 m/s^2 for 6.9...
A car starts from rest at a stop sign. It accelerates at 4.4 m/s^2 for 6.9 s, coasts for 2.3 s, and then slows down at a rate of 3.4 m/s^2 for the next stop sign. How far apart are the stop signs?
Trend Analysis - The following data pertain to Company A: (in millions) Year 2 Year 1...
Trend Analysis - The following data pertain to Company A: (in millions) Year 2 Year 1 Revenue $39,474 $35,137 Net income 5,658 5,642 Accounts receivable 4,389 3,725 Inventory 2,290 1,926 Total current assets 10,151 9,130 Total assets 34,628 29,930 Total current liabilities 7,753 6,860 Total long-term liabilities 9,641 7,702 Total stockholder equity 20,000 18,000 Common-Size Income Statements - Company A reported the following income statements: COMPANY A INCOME STATEMENT FOR THE YEARS ENDED DECEMBER YEAR 2 AND YEAR 1 (in...
Question No: 2 Short Theory Questions:                                    &
Question No: 2 Short Theory Questions:                                                                   Note: Answer the following questions:                                                                                                                                              What are revaluation model of the property, plant and equipment? What is current rate method?   What is horizontal analysis? Answer all (Write in box “True or False “ ) Transfer pricing is setting prices on goods and services exchanged between separate divisions within the same firm and these prices have a direct impact on the profits of the different division.                                                                                                                (           ) Harmonization is the process...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT