Lab 4 .
docx
keyboard_arrow_up
School
Durham College *
*We aren’t endorsed by this school
Course
DATA
Subject
Statistics
Date
Apr 3, 2024
Type
docx
Pages
6
Uploaded by JudgeBravery13371
Lab 4: Linear Regression Extensions
1.
Write coefficients from a linear model with response = mpg, and explanatory variables
horsepower and origin, with an interaction between horsepower and origin
CODE:-
library(tidyverse)
library(ISLR2)
smallData<- ISLR2::Auto
autoModel <- lm(mpg ~ horsepower + origin + horsepower:origin, data =smallData)
coef(autoModel)
OUTPUT:-
2.
Predict the average mpg for four cars: (100 horsepower, American), (100 horsepower, Japanese),
(170 horsepower, American), (170 horsepower, Japanese).
CODE
:- mpgPrediction <- data.frame(horsepower = c(100, 100, 170, 170), origin=c(1,3,1,3))
predict(autoModel,mpgPrediction) OUTPUT:-
3.
What do you notice about how the predictions change as horsepower increases?
ANS:- From the obtained output we can observe that predictions show decreasing trend as horsepower
increases.
4.
What Plot a scatter plot with x = horsepower, y = mpg
CODE
: - autoModel %>% ggplot(aes(x = horsepower, y = mpg)) + geom_point() +
geom_smooth(method="lm")
OUPUT
: - 5.Based on the plot, do you think a simple linear regression will work well here?
ANS:- No, the simple linear regression will not work well here as it more looks like curve.
6.Write coefficients from a linear model with response = mpg and explanatory = horsepower, with a suitable
transformation for the horsepower variable (for example, square it)
CODE:- autoSqrModel <- lm(mpg ~ horsepower + I(horsepower^2), data = smallData)
coef(autoSqrModel) 7.Predict the average mpg for 3 cars: 80 horsepower, 100 horsepower, 120 horsepower.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
mpg_Average_Prediction <- data.frame(horsepower = c(80, 80, 80, 100, 100, 100, 120, 120, 120),origin = c(1,
2,
3,
1,
2,
3,
1,
2,3))
predict(autoModel, mpg_Average_Prediction)
8. What do you notice about these predictions?
ANS:- For 80 , horsepower increases from American to japnese
For 100 , firstly it increases and then it decreases for japnese
For 120 , it shows similar values for Europe and japnese .
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Documents
Related Questions
We have data on Lung Capacity of persons and we wish
to build a multiple linear regression model that predicts
Lung Capacity based on the predictors Age and
Smoking Status. Age is a numeric variable whereas
Smoke is a categorical variable (0 if non-smoker, 1 if
smoker). Here is the partial result from STATISTICA.
b*
Std.Err.
of b*
Std.Err.
N=725
of b
Intercept
Age
Smoke
0.835543
-0.075120
1.085725
0.555396
0.182989
0.014378
0.021631
0.021631
-0.648588
0.186761
Which of the following statements is absolutely false?
A. The expected lung capacity of a smoker is expected
to be 0.648588 lower than that of a non-smoker.
B. The predictor variables Age and Smoker both
contribute significantly to the model.
C. For every one year that a person gets older, the lung
capacity is expected to increase by 0.555396 units,
holding smoker status constant.
D. For every one unit increase in smoker status, lung
capacity is expected to decrease by 0.648588 units,
holding age constant.
arrow_forward
Tire pressure (psi) and mileage (mpg) were recorded for a random sample of seven cars of thesame make and model. The extended data table (left) and fit model report (right) are based on aquadratic model
What is the predicted average mileage at tire pressure x = 31?
arrow_forward
The following result perspective in RapidMiner shows a multiple linear regression model.
Based on the diagram, the model for our dependent variable Y is Predicted Y=
(Insulation *0.420)+(Temperature *0.071)+(Avg_Age*0.065)+(Home_Size *0.311)+7.589
Attribute
Insulation
Temperature
Avg Age
Home Size
(Intercept)
O True
O False
Coefficient
3.323
-0.869
1.968
3.173
134.511
Std. Error
0.420
0.071
0.065
0.311
7.589
Std. Coefficient
0.164
-0.262
0.527
0.131
?
Tolerance
0.431
0.405
0.491
0.914
?
t-Stat
7.906
-12.222
30.217
10.210
17.725
arrow_forward
when a regression is used as a method of predicting dependent variables from one or more independent variables. How are the independent variables different from each other yet related to the dependent variable?
arrow_forward
Independent variable data is listed in cells B2 through B100, and dependent variable data is in cells C2 through C100. Which spreadsheet function would calculate the slope of a linear regression model of this data?
Group of answer choices
=SLOPE(B2:B100,C2:C100)
=SLOPE(C2:C100,B2:B100)
=SLOPE(B2,C2)
=SLOPE(C2,C100,B2,B100)
arrow_forward
A pediatrician records the age x (in yr) and average height y (in inches) for girls between the ages of 2 and 10.
Height (in.)
50-
y
Height of Girls vs. Age
(7,48)
40-
(3,38)
30-
20
10-
2
6
8
10
Age(yr)
X
(a) Use the points (3, 38) and (7, 48) to write a linear model for these data.
(b) Interpret the meaning of the slope in the context.
(c) Use the model to forecast the average height of 11-yr-old girls. Round all calculations to the nearest hundredth of an inch, if necessary.
(d) If the height of a girl at age 11 is 90% of her full-grown adult height, use the result of part (c) to estimate the average height of adult women. Round to the
nearest tenth of an inch.
CYDIANATION.
arrow_forward
Professional basketball has truly become a sport that generates interest among fans around the world. More and more players come from outside the United States to play in the National Basketball Association (NBA). You want to develop a regression model to predict the number of wins achieved by each NBA team, based on field goal (shots made) percentage and three-point field goal percentage. The data are stored in NBA.xlsx .
TEAM
Wins
Field Goal %
Three-Point Field Goal %
Points Per Game
Rebound
Freedraw
Turnover
Houston Rockets
65
46
36.2
112.4
43.5
19.6
13.8
Toronto Raptors
59
47.2
35.8
111.7
44
17.3
13.4
Golden State Warriors
58
50.3
39.1
113.5
43.5
16.6
15.4
Boston Celtics
55
45
37.7
104
44.5
16
14
Philadelphia 76ers
52
47.2
36.9
109.8
47.4
17.1
16.5
Cleveland Cavaliers
50
47.6
37.2
110.9
42.1
18.1
13.7
Portland Trail Blazers
49
45.2
36.6
105.6
45.5
16.7
13.5
Indiana Pacers
48
47.2
36.9
105.6
42.3
14.9
13.3
New Orleans Pelicans
48
48.3
36.2
111.7
44.3
16.1
14.9…
arrow_forward
Professional basketball has truly become a sport that generates interest among fans around the world. More and more players come from outside the United States to play in the National Basketball Association (NBA). You want to develop a regression model to predict the number of wins achieved by each NBA team, based on field goal (shots made) percentage and three-point field goal percentage. The data are stored in NBA.xlsx .
TEAM
Wins
Field Goal %
Three-Point Field Goal %
Points Per Game
Rebound
Freedraw
Turnover
Houston Rockets
65
46
36.2
112.4
43.5
19.6
13.8
Toronto Raptors
59
47.2
35.8
111.7
44
17.3
13.4
Golden State Warriors
58
50.3
39.1
113.5
43.5
16.6
15.4
Boston Celtics
55
45
37.7
104
44.5
16
14
Philadelphia 76ers
52
47.2
36.9
109.8
47.4
17.1
16.5
Cleveland Cavaliers
50
47.6
37.2
110.9
42.1
18.1
13.7
Portland Trail Blazers
49
45.2
36.6
105.6
45.5
16.7
13.5
Indiana Pacers
48
47.2
36.9
105.6
42.3
14.9
13.3
New Orleans Pelicans
48
48.3
36.2
111.7
44.3
16.1
14.9…
arrow_forward
Why would the male lifespan not be the dependent variable?
arrow_forward
The least squares regression equation for the association
between Quality of Marriage (y) and Quality of Parent-Child
Relationship (x) is as follows: .
A) What is the value for i) the intercept and ii) the slope?
Slope:
Intercept:
B) Based on this equation, what is the predicted Quality of
Parent-Child Relationship for someone whose Quality of
Marriage is 3?
C) Now let's say in our data we have a person whose Quality of
Marriage is 3 and his Quality of Parent-Child Relationship is 1.
What is the residual in prediction?
Question 6.
You are a teacher at a gifted school, and you feel that the newest
class of students is even brighter than usual. The mean IQ at
your school is 127, and the mean IQ of this new class is 134. In
total, there are 32 students in this new class. Also, the standard
deviation of the school's IQ is 8. Use the eight steps to test
whether this new class of students is significantly more
intelligent than the school's student body overall (take a picture
of your…
arrow_forward
Range of ankle motion is a contributing factor to falls among the elderly. Suppose a team of researchers is studying how compression hosiery, typical shoes, and medical shoes affect range of ankle motion.
In particular, note the variables Barefoot and Footwear2. Barefoot represents a subject's range of ankle motion (in degrees) while barefoot, and Footwear2 represents their range of ankle motion (in degrees) while wearing medical shoes.
Use this data and your preferred software to calculate the equation of the least-squares linear regression line to predict a subject's range of ankle motion while wearing medical shoes, ?̂ , based on their range of ankle motion while barefoot, ? . Round your coefficients to two decimal places of precision.
?̂ =
A physical therapist determines that her patient Jan has a range of ankle motion of 7.26°7.26° while barefoot. Predict Jan's range of ankle motion while wearing medical shoes, ?̂ . Round your answer to two decimal places.
?̂ =
Suppose Jan's…
arrow_forward
I appreciate help I can receive on this
arrow_forward
Range of ankle motion is a contributing factor to falls among the elderly. Suppose a team of researchers is studying how compression hosiery, typical shoes, and medical shoes affect range of ankle motion.
In particular, note the variables Barefoot and Footwear1. Barefoot represents a subject's range of ankle motion (in degrees) while barefoot, and Footwear1 represents their range of ankle motion (in degrees) while wearing typical shoes.
Use this data and your preferred software to calculate the equation of the least-squares linear regression line to predict a subject's range of ankle motion while wearing typical shoes, y^ , based on their range of ankle motion while barefoot, x . Round your coefficients to two decimal places of precision.
?̂ =
A physical therapist determines that her patient Jan has a range of ankle motion of 7.26° while barefoot. Predict Jan's range of ankle motion while wearing typical shoes, ?̂ . Round your answer to two decimal places.…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you


Glencoe Algebra 1, Student Edition, 9780079039897...
Algebra
ISBN:9780079039897
Author:Carter
Publisher:McGraw Hill

Elementary Linear Algebra (MindTap Course List)
Algebra
ISBN:9781305658004
Author:Ron Larson
Publisher:Cengage Learning

Related Questions
- We have data on Lung Capacity of persons and we wish to build a multiple linear regression model that predicts Lung Capacity based on the predictors Age and Smoking Status. Age is a numeric variable whereas Smoke is a categorical variable (0 if non-smoker, 1 if smoker). Here is the partial result from STATISTICA. b* Std.Err. of b* Std.Err. N=725 of b Intercept Age Smoke 0.835543 -0.075120 1.085725 0.555396 0.182989 0.014378 0.021631 0.021631 -0.648588 0.186761 Which of the following statements is absolutely false? A. The expected lung capacity of a smoker is expected to be 0.648588 lower than that of a non-smoker. B. The predictor variables Age and Smoker both contribute significantly to the model. C. For every one year that a person gets older, the lung capacity is expected to increase by 0.555396 units, holding smoker status constant. D. For every one unit increase in smoker status, lung capacity is expected to decrease by 0.648588 units, holding age constant.arrow_forwardTire pressure (psi) and mileage (mpg) were recorded for a random sample of seven cars of thesame make and model. The extended data table (left) and fit model report (right) are based on aquadratic model What is the predicted average mileage at tire pressure x = 31?arrow_forwardThe following result perspective in RapidMiner shows a multiple linear regression model. Based on the diagram, the model for our dependent variable Y is Predicted Y= (Insulation *0.420)+(Temperature *0.071)+(Avg_Age*0.065)+(Home_Size *0.311)+7.589 Attribute Insulation Temperature Avg Age Home Size (Intercept) O True O False Coefficient 3.323 -0.869 1.968 3.173 134.511 Std. Error 0.420 0.071 0.065 0.311 7.589 Std. Coefficient 0.164 -0.262 0.527 0.131 ? Tolerance 0.431 0.405 0.491 0.914 ? t-Stat 7.906 -12.222 30.217 10.210 17.725arrow_forward
- when a regression is used as a method of predicting dependent variables from one or more independent variables. How are the independent variables different from each other yet related to the dependent variable?arrow_forwardIndependent variable data is listed in cells B2 through B100, and dependent variable data is in cells C2 through C100. Which spreadsheet function would calculate the slope of a linear regression model of this data? Group of answer choices =SLOPE(B2:B100,C2:C100) =SLOPE(C2:C100,B2:B100) =SLOPE(B2,C2) =SLOPE(C2,C100,B2,B100)arrow_forwardA pediatrician records the age x (in yr) and average height y (in inches) for girls between the ages of 2 and 10. Height (in.) 50- y Height of Girls vs. Age (7,48) 40- (3,38) 30- 20 10- 2 6 8 10 Age(yr) X (a) Use the points (3, 38) and (7, 48) to write a linear model for these data. (b) Interpret the meaning of the slope in the context. (c) Use the model to forecast the average height of 11-yr-old girls. Round all calculations to the nearest hundredth of an inch, if necessary. (d) If the height of a girl at age 11 is 90% of her full-grown adult height, use the result of part (c) to estimate the average height of adult women. Round to the nearest tenth of an inch. CYDIANATION.arrow_forward
- Professional basketball has truly become a sport that generates interest among fans around the world. More and more players come from outside the United States to play in the National Basketball Association (NBA). You want to develop a regression model to predict the number of wins achieved by each NBA team, based on field goal (shots made) percentage and three-point field goal percentage. The data are stored in NBA.xlsx . TEAM Wins Field Goal % Three-Point Field Goal % Points Per Game Rebound Freedraw Turnover Houston Rockets 65 46 36.2 112.4 43.5 19.6 13.8 Toronto Raptors 59 47.2 35.8 111.7 44 17.3 13.4 Golden State Warriors 58 50.3 39.1 113.5 43.5 16.6 15.4 Boston Celtics 55 45 37.7 104 44.5 16 14 Philadelphia 76ers 52 47.2 36.9 109.8 47.4 17.1 16.5 Cleveland Cavaliers 50 47.6 37.2 110.9 42.1 18.1 13.7 Portland Trail Blazers 49 45.2 36.6 105.6 45.5 16.7 13.5 Indiana Pacers 48 47.2 36.9 105.6 42.3 14.9 13.3 New Orleans Pelicans 48 48.3 36.2 111.7 44.3 16.1 14.9…arrow_forwardProfessional basketball has truly become a sport that generates interest among fans around the world. More and more players come from outside the United States to play in the National Basketball Association (NBA). You want to develop a regression model to predict the number of wins achieved by each NBA team, based on field goal (shots made) percentage and three-point field goal percentage. The data are stored in NBA.xlsx . TEAM Wins Field Goal % Three-Point Field Goal % Points Per Game Rebound Freedraw Turnover Houston Rockets 65 46 36.2 112.4 43.5 19.6 13.8 Toronto Raptors 59 47.2 35.8 111.7 44 17.3 13.4 Golden State Warriors 58 50.3 39.1 113.5 43.5 16.6 15.4 Boston Celtics 55 45 37.7 104 44.5 16 14 Philadelphia 76ers 52 47.2 36.9 109.8 47.4 17.1 16.5 Cleveland Cavaliers 50 47.6 37.2 110.9 42.1 18.1 13.7 Portland Trail Blazers 49 45.2 36.6 105.6 45.5 16.7 13.5 Indiana Pacers 48 47.2 36.9 105.6 42.3 14.9 13.3 New Orleans Pelicans 48 48.3 36.2 111.7 44.3 16.1 14.9…arrow_forwardWhy would the male lifespan not be the dependent variable?arrow_forward
- The least squares regression equation for the association between Quality of Marriage (y) and Quality of Parent-Child Relationship (x) is as follows: . A) What is the value for i) the intercept and ii) the slope? Slope: Intercept: B) Based on this equation, what is the predicted Quality of Parent-Child Relationship for someone whose Quality of Marriage is 3? C) Now let's say in our data we have a person whose Quality of Marriage is 3 and his Quality of Parent-Child Relationship is 1. What is the residual in prediction? Question 6. You are a teacher at a gifted school, and you feel that the newest class of students is even brighter than usual. The mean IQ at your school is 127, and the mean IQ of this new class is 134. In total, there are 32 students in this new class. Also, the standard deviation of the school's IQ is 8. Use the eight steps to test whether this new class of students is significantly more intelligent than the school's student body overall (take a picture of your…arrow_forwardRange of ankle motion is a contributing factor to falls among the elderly. Suppose a team of researchers is studying how compression hosiery, typical shoes, and medical shoes affect range of ankle motion. In particular, note the variables Barefoot and Footwear2. Barefoot represents a subject's range of ankle motion (in degrees) while barefoot, and Footwear2 represents their range of ankle motion (in degrees) while wearing medical shoes. Use this data and your preferred software to calculate the equation of the least-squares linear regression line to predict a subject's range of ankle motion while wearing medical shoes, ?̂ , based on their range of ankle motion while barefoot, ? . Round your coefficients to two decimal places of precision. ?̂ = A physical therapist determines that her patient Jan has a range of ankle motion of 7.26°7.26° while barefoot. Predict Jan's range of ankle motion while wearing medical shoes, ?̂ . Round your answer to two decimal places. ?̂ = Suppose Jan's…arrow_forwardI appreciate help I can receive on thisarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Glencoe Algebra 1, Student Edition, 9780079039897...AlgebraISBN:9780079039897Author:CarterPublisher:McGraw HillElementary Linear Algebra (MindTap Course List)AlgebraISBN:9781305658004Author:Ron LarsonPublisher:Cengage Learning


Glencoe Algebra 1, Student Edition, 9780079039897...
Algebra
ISBN:9780079039897
Author:Carter
Publisher:McGraw Hill

Elementary Linear Algebra (MindTap Course List)
Algebra
ISBN:9781305658004
Author:Ron Larson
Publisher:Cengage Learning
