Question

Use the built in R dataset called “mtcars.” You can see what variables this dataset contains...

  1. Use the built in R dataset called “mtcars.” You can see what variables this dataset contains by typing help(mtcars). Calculate a scatter plot for the variables: wt and mpg. Also, calculate the correlation coefficient. Calculate a least squares line and plot it in the scatterplot.

Homework Answers

Answer #1

I have attached the code below as well as the output.

data=mtcars help(data) x=data$wt y=data$mpg plot(x,y) cor(x,y) model=lm(y~x) yest=37.285-5.344*x plot(x,y) lines(x,yest,type="l")

The scatter plot is as follows:

where my x variate corresponds to weight and y variate corresponds of mpg.

To find correlation between them cor command is used and output is:

cor(x,y)
[1] -0.8676594

hence the correlation is -0.8676594.

The least square estimates are as follows

Coefficients:
(Intercept) x
37.285 -5.344

Hence the model is

Yest=37.285-5.344*X

Therefore the least squares line is calculated and the graph is as follows

Hence the line is the least square line and the points are scatterplot.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
3. The R-built in dataset called beaver2 (try ?beaver2) contains the variables temp (body temperature in...
3. The R-built in dataset called beaver2 (try ?beaver2) contains the variables temp (body temperature in °Celsius) and active (0 = inactive, 1 = active outside its retreat). Answers should be in the form of R code on how to accomplish each part and include the correct statistical explanation for those that require it in the question. The significance level for alpha =0.05. Please be as thorough as possible and please submit written explanations(no pictures). Thank you so much!!! a....
This problem requires the use of R-Studio. Consider the mtcars data. In R, you can use...
This problem requires the use of R-Studio. Consider the mtcars data. In R, you can use the following code to get the data: dta <- mtcars Use ?mtcars to read the information about this data set. In what follows, we will fit the regression model: mpgi=β0 + β0vsi+ εi, i=1,2,...,n. Note that, vs is categorical variable, whose value is 1 if the observed car has the V-shaped engine or 0 otherwise. (A) Which of the following is the most accurate...
n this CT assignment, we will use R software to analyze a dataset GoogleAmazonStock.xlsx. It contains...
n this CT assignment, we will use R software to analyze a dataset GoogleAmazonStock.xlsx. It contains daily closing stock prices for Google and Amazon from 8/22/2017 to 8/22/2018. When we examine stock prices (or other financial assets) we often transform them into a (simple) return series. The return series are computed by the formula: (present price/past price) - 1. The dataset contains both stock prices and return series. 1. Using R, construct time series (line) plots for both stock prices...
Use the classroom dataset. A researcher wants to be able to use shoe size to predict...
Use the classroom dataset. A researcher wants to be able to use shoe size to predict height. Shoe size= 6, 9, 7.5, 9.5, 8, 10.5, 8, 8, 7.5, 7.5, 9, 9, 8.5, 11.5, 8.5, 9, 7, 5, 8, 8, 8.5, 6.5, 6 Height(in)= 62, 67, 62, 69, 63, 67, 66, 63, 68, 64, 63, 66, 65, 72, 64, 65, 66, 61, 67, 64, 65, 60, 64 A) what variable is the response variable and which is the predictor variable? B)...
Do heavier cars really use more gasoline? Suppose a car is chosen at random. Let x...
Do heavier cars really use more gasoline? Suppose a car is chosen at random. Let x be the weight of the car (in hundreds of pounds), and let y be the miles per gallon (mpg). x 30 44 33 47 23 40 34 52 y 33 21 22 13 29 17 21 14 Complete parts (a) through (e), given Σx = 303, Σy = 170, Σx2 = 12,123, Σy2 = 3950, Σxy = 6040, and r ≈ −0.853. (a) Draw...
Do heavier cars really use more gasoline? Suppose a car is chosen at random. Let x...
Do heavier cars really use more gasoline? Suppose a car is chosen at random. Let x be the weight of the car (in hundreds of pounds), and let y be the miles per gallon (mpg). x 27 43 29 47 23 40 34 52 y 31 18 27 13 29 17 21 14 Complete parts (a) through (e), given Σx = 295, Σy = 170, Σx2 = 11,617, Σy2 = 3950, Σxy = 5794, and r ≈ −0.951. (a) Draw...
Data Set A- 7,7,7,9,9,9,10 Data Set B- 4,6,6,6,8,9,9,9,10,10,10 Step 1 Create a bar graph that examines...
Data Set A- 7,7,7,9,9,9,10 Data Set B- 4,6,6,6,8,9,9,9,10,10,10 Step 1 Create a bar graph that examines a variable or variables in your data set. Step 2 Find the sample mean, median (if it exists) mode for each set of data Next find the sample standard deviations for each set of data Create a box and whisker plot for each variable for each set data Eliminate any outliers from the samples. Redo part 1 for each variable (if necessary, if not...
1. Can you tell a child's shoe size by their age? A chart showing shoe size...
1. Can you tell a child's shoe size by their age? A chart showing shoe size by age for girls was used to obtain the following data: x= age y= shoe size 1 5 2 8 4 10 5 11 7 12 a) Construct a scatter diagram of the data. Make sure to label the axes. b) Does there appear to be a linear relationship? c) Calculate the correlation coefficient r. Show all of your work. Use a table to...
Do heavier cars really use more gasoline? Suppose a car is chosen at random. Let x...
Do heavier cars really use more gasoline? Suppose a car is chosen at random. Let x be the weight of the car (in hundreds of pounds), and let y be the miles per gallon (mpg). x 28 42 29 47 23 40 34 52 y 30 17 24 13 29 17 21 14 Complete parts (a) through (e), given Σx = 295, Σy = 165, Σx2 = 11,587, Σy2 = 3701, Σxy = 5650, and r ≈ −0.945. (a) Draw...
Please show formulas in excel Do heavier cars really use more gasoline? Suppose a car is...
Please show formulas in excel Do heavier cars really use more gasoline? Suppose a car is chosen at random. Let x be the weight of the car (in hundreds of pounds), and let y be the miles per gallon (mpg). x 29 46 33 47 23 40 34 52 y 29 22 24 13 29 17 21 14 Complete parts (a) through (e), given Σx = 304, Σy = 169, Σx2 = 12,244, Σy2 = 3837, Σxy = 6045, and...