Homework 4
PSTAT 126, Winter 2022
Due date: March 11, 2022 at 23:59 PT
Note: Please show all the procedures of your analysis, and prepare the homework solution using RMarkdown. All code should be well documented. A RMarkdown homework template is available on GauchoSpace. Homework should be submitted on GauchoSpace.
Copyright By PowCoder代写 加微信 powcoder
You should write up your homework solution on your own. In particular, do not share your homework RMarkdown file with other student.
Q1. This question uses the Auto dataset available in the ISLR package. The dataset under the name Auto is automatically available once the ISLR package is loaded (as shown in the following code chunk).
The dataset Auto contains the following information for 392 vehicles:
• mpg: miles per gallon
• cylinders: number of cylinders (between 4 and 8)
• displacement: engine displacement (cu.inches)
• horsepower: engine horsepower
• weight: vehicle weight (lbs)
• acceleration: time to accelerate from 0 to 60 mph (seconds)
• year: model year (modulo 100)
• origin: origin of the vehicle (numerically coded as 1: American, 2: European, 3: Japanese) • name: vehicle name
Our goal is to analyze various linear models where mpg is the response variable.
(a). (2 pts) In this dataset, which predictors are qualitative, and which predictors are quantitative?
(b). (2 pts) Fit a MLR model to the data, in order to predict mpg using all of the other predictors except for name. For each predictor in the fitted MLR model, comment on whether you can reject the null hypothesis that there is no linear association between that predictor and mpg, conditional on the other predictors in the model.
(c). (2 pts) Indicate clearly how the coefficient estimates associated with the predictor origin should be interpreted.
(d). (2 pts) What mpg do you predict for a Japanese car with three cylinders, displacement 100, horsepower of 85, weight of 3000, acceleration of 20, built in the year 1980?
(e). (2 pts) On average, holding all other predictor variables fixed, what is the difference between the mpg of a Japanese car and the mpg of an European car?
(f). (2 pts) Fit a model to predict mpg using origin and horsepower, as well as an interaction between origin and horsepower. Present the summary output of the fitted model, and write out the fitted linear model.
library(ISLR) Auto
(g). (2 pts) Following the previous question: On average, how much does the mpg of a Japanese car change with a one-unit increase in horsepower?
(h). (2 pts) If we are fitting a polynomial regression with mpg as the response variable and weight as the predictor, what should be a proper degree of that polynomial?
(i). (4 pts) Perform a backward selection, starting with the full model which includes all predictors except for name. What is the best model based on the adjusted R2 criterion? What are the predictor variables in that best model?
Q2. In a binary classification problem, let p represent the probability of class label “1”, which implies that 1 − p represents probability of class label “0”. The logistic function (also called the “inverse logit”) is the cumulative distribution function of logistic distribution, which maps a real number z to the open interval (0, 1):
p(z)= 1+ez. (1)
(a). (4 pts) Show that indeed the inverse of a logistic function is the logit function: p
z(p)=ln 1−p . (2)
(b). Assume that z = β0 + β1×1, and p = logistic(z). (2 pts) How does the odds of the outcome change if you increase x1 by two? (1 pts) Assume β1 is negative: what value does p approach as x1 → ∞? (1 pts) What value does p approach as x1 → −∞?
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com