1. In R copy the stackloss data into an object called Stack. For the 17th observation of Stack, successively replace the Water.Temp value of 19 with the values 19, 20, 21, … 29 (degrees Celsius). For...

1 answer below »

View more »
Answered Same DayNov 10, 2021

Answer To: 1. In R copy the stackloss data into an object called Stack. For the 17th observation of Stack,...

Mohd answered on Nov 10 2021
119 Votes
-
-
-
11/10/2021
library(magrittr)
library(dplyr)
library(ggplot2)
library(rmarkdown)
library(skimr)
library(faraway)
library(ggeffects)
library(stargazer)
1. In R copy the stackloss data into an object called Stack. For the 17th observation of Stack, successively replace the Water.Temp value of 19 with the values 19, 20, 21, … 29 (degrees Cel
sius).
For each instance obtain the estimated regression coefficients (a four-vector) using least-squares and least-absolute values regression.
Then, for each coefficient, produce a plot of the coefficient estimate versus the value of Water.Temp that was used for the 17th observation.
Plot the least-squares and least-absolute values regression estimates on the same plot (use different colors).
Because there are four coefficients, you can use par(mfrow = c(2,2)) to make each one a separate subplot in a 2 × 2 plot matrix. Make sure that the subplots are properly labeled! When you are done,
write a few sentences to compare the sensitivity of least-squares versus least-absolute values regression to changes in this one observation.
Stack<-stackloss
mod_1<-lm(stack.loss~Water.Temp,data=Stack)
#summary(mod_1)
plot(mod_1)
Stack[17,2]<-20
mod_2<-lm(stack.loss~Water.Temp,data=Stack)
#summary(mod_2)
Stack[17,2]<-21
mod_3<-lm(stack.loss~Water.Temp,data=Stack)
#summary(mod_3)
Stack[17,2]<-22
mod_4<-lm(stack.loss~Water.Temp,data=Stack)
#summary(mod_4)
Stack[17,2]<-23
mod_5<-lm(stack.loss~Water.Temp,data=Stack)
#summary(mod_6)
Stack[17,2]<-25
mod_7<-lm(stack.loss~Water.Temp,data=Stack)
#summary(mod_7)
Stack[17,2]<-26
mod_8<-lm(stack.loss~Water.Temp,data=Stack)
#summary(mod_8)
Stack[17,2]<-27
mod_9<-lm(stack.loss~Water.Temp,data=Stack)
#summary(mod_9)
Stack[17,2]<-28
mod_10<-lm(stack.loss~Water.Temp,data=Stack)
#summary(mod_10)
Stack[17,2]<-29
mod_11<-lm(stack.loss~Water.Temp,data=Stack)
#summary(mod_11)
stargazer(mod_1,mod_2,mod_3,mod_4,mod_5,type="text")
##
## ====================================================================================
## Dependent variable:
## ------------------------------------------------------
## stack.loss
## (1) (2) (3) (4) (5)
## ------------------------------------------------------------------------------------
## Water.Temp 2.817*** 2.815*** 2.786*** 2.729*** 2.647***
## (0.357) (0.370) (0.386) (0.405) (0.425)
##
## Constant -41.911*** -42.002*** -41.510*** -40.437*** -38.819***
## (7.606) (7.903) (8.273) (8.694) (9.137)
##
## ------------------------------------------------------------------------------------
## Observations 21 21 21 21 21
## R2 0.767 0.753 0.732 0.705 0.671
## Adjusted R2 0.754 0.740 0.718 0.689 0.654
## Residual Std. Error (df = 19) 5.043 5.187 5.400 5.670 5.982
## F Statistic (df = 1; 19) 62.373*** 57.922*** 51.967*** 45.360*** 38.821***
##...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here
April
January
February
March
April
May
June
July
August
September
October
November
December
2025
2025
2026
2027
SunMonTueWedThuFriSat
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30