[SOLVED] STAT340: Discussion 7: Linear regression

$25

File Name: STAT340:_Discussion_7:_Linear_regression.zip
File Size: 376.8 KB

5/5 - (1 vote)

STAT340: Discussion 7: Linear regression

STAT340: Discussion 7: Linear regression

Copyright By Assignmentchef assignmentchef

link to source

XKCD comic

Today were going to use the built-in mtcars dataset to practice simple linear regression. Note this is a built-in dataset provided as part of the datasets package in R.

Background

Run ?(mtcars) in the console (do NOT add it to this Rmd file) and briefly read the help page. Specifically, take note of the following:

What is the source of this data?
What is this dataset measuring? (i.e.what is the response variable?)
What predictors are available and what do they mean?

Feel free to also run head(mtcars, 10) or View(mtcars) to inspect the data frame briefly before moving on.

Uncomment the line below and finish it. Specifically, use lm to run a regression of mpg on one other predictor (an easy way to do this is to use mpg ~ var where var is the predictor youre using). Make sure to also include data = mtcars as an argument or it wont know where to get the variable names from.

# lm.mtcars = lm()

View a summary of the regression by uncommenting and running the line below

# summary(lm.mtcars)

Briefly inspect the residuals plot by running plot(lm.mtcars,which=1:2) . What do you observe, and what does it mean?

REPLACE TEXT WITH RESPONSE

Interpretation

Uncomment the line below to get the estimated coefficients along with their standard errors.

# summary(lm.mtcars)$coefficients[,1:2]

Give an interpretation of the estimate and standard error for your predictor. Be careful in your wording of the interpretation.

REPLACE TEXT WITH RESPONSE

What does the intercept here mean? (Except for special situations, we generally dont care much about the intercept, but you should still understand what it means.)

REPLACE TEXT WITH RESPONSE

What is the R for this model? (Hint: look at the output of summary) Give an interpretation of this value.

REPLACE TEXT WITH RESPONSE

Briefly read about the adjusted R here. What is the adjusted R of this model and how does this differ from the normal R value? (Hint: again, look at the output of summary).

REPLACE TEXT WITH RESPONSE

Generate (95%) confidence intervals for the coefficients using the confint function. Give an interpretation of these confidence intervals.

# confint()

REPLACE TEXT WITH RESPONSE

Try with others!

Repeat the steps above for at least 1 other predictor. Which of these two predictors seems to offer a better predictive ability for mpg? How do you know?

CS: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] STAT340: Discussion 7: Linear regression
$25