In: Statistics and Probability
For the mtcars dataset (in R), comment on how Rear axle ratio is associated with Displacement (cu.in.) and Miles/(US) gallon using the following steps:
ANSWER::
R Code:
#data
Mtcars = mtcars
View(mtcars)
#Scatterplot
plot(Mtcars$mpg,Mtcars$disp,main = "Scatter plot between mpg and
disp")
#correlation coefficient between mpg and disp
cor(Mtcars$mpg,Mtcars$disp)
#calculate regression coefficient using lm function
lm(Mtcars$disp~Mtcars$mpg)
#Fitted regression line
abline(lm(Mtcars$disp~Mtcars$mpg))
(a)
(b)
Correlation coefficient = -0.8475514
(c)
fitted regression line:
(d)
Using the above-fitted regression line we conclude that mpg is negatively associated with displacement.
Similarly, we can do for the mpg and hp
R code:
# between mpg and hp
#Scatterplot
plot(Mtcars$mpg,Mtcars$hp,main = "Scatter plot between mpg and
disp")
#correlation coefficient between mpg and disp
cor(Mtcars$mpg,Mtcars$hp)
#calculate regression coefficient using lm function
lm(Mtcars$hp~Mtcars$mpg)
#Fitted regression line
abline(lm(Mtcars$hp~Mtcars$mpg))
(a)
(b)
correlation coefficient = -0.7761684
(c)
(d)
Using the above-fitted regression line we conclude that mpg is negatively associated with Gross horsepower.
NOTE:: I HOPE THIS ANSWER IS HELPFULL TO YOU......**PLEASE SUPPORT ME WITH YOUR RATING......
**PLEASE GIVE ME "LIKE".....ITS VERY IMPORTANT FOR,ME......PLEASE SUPPORT ME .......THANK YOU