3.15

In addition to the instructions in the textbook, draw a scatterplot with the regression line drawn on the plot.

plot(RECALL~POSITION, data = names)
names_mod <- lm(RECALL~POSITION, data = names)
summary(names_mod)
## 
## Call:
## lm(formula = RECALL ~ POSITION, data = names)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.69255 -0.18558  0.05066  0.20889  0.37671 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.570443   0.055075  10.358   <2e-16 ***
## POSITION    0.026422   0.009244   2.858   0.0049 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2542 on 142 degrees of freedom
## Multiple R-squared:  0.05441,    Adjusted R-squared:  0.04775 
## F-statistic: 8.171 on 1 and 142 DF,  p-value: 0.004899
abline(names_mod)

Type the regression equation and interpret the beta coefficients below. RECALL= 0.570+0.026(POSITION) For every one unit increase in POSITION, we would expect a 0.026 increase in the RECALL.

8.5

Read the problem description in the book but do not answer the questions in the book. Instead, respond to the questions shown below.

a.

Construct a scatterplot of FAILTIME vs. TEMP, fit a simple linear regression model to the data, and construct a residual plot. Arrange your plots in a 1x2 grid.

par(mfrow = c(1, 2))
plot(FAILTIME~TEMP, data = wafer)
wafer_mod <- lm(FAILTIME ~ TEMP, data = wafer)
abline(wafer_mod)
plot(wafer_mod, which = 1)

b.

Is there evidence of lack of fit? Briefly explain your answer. Yes, there is clear evidence of a lack of fit. The scatterplot exhibits a curved downward relationship between TEMP and FAILTIME, and the residual plot displays a distinct U-shaped pattern rather than a random scatter around zero.

c.

Apply a data transformation to achieve linearity. Display the scatterplot and residual plot for your final model ONLY, and arrange the graphs in a 1x2 grid. (Note: You may have to transform the x and/or y variables, and there may be more than one possible solution. You only have to report one of them.

par(mfrow = c(1, 2))
plot(log(FAILTIME)~TEMP, data = wafer)
wafer_mod <- lm(log(FAILTIME) ~ TEMP, data = wafer)
abline(wafer_mod)
plot(wafer_mod, which = 1)

summary(wafer_mod)
## 
## Call:
## lm(formula = log(FAILTIME) ~ TEMP, data = wafer)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.13049 -0.16959 -0.06977  0.36982  1.11624 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 19.202442   1.336477  14.368 5.31e-12 ***
## TEMP        -0.080662   0.009108  -8.856 2.34e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5414 on 20 degrees of freedom
## Multiple R-squared:  0.7968, Adjusted R-squared:  0.7866 
## F-statistic: 78.43 on 1 and 20 DF,  p-value: 2.342e-08

d.

Type the equation of your final regression line below. If necessary, back-transform the y-variable. log(FAILTIME)=19.202-0.080(TEMP) FAILTIME= (e19.202)*(e(-0.080(TEMP)))

e.

Write a sentence interpreting the slope of the final model. For every 1-unit change in temperature, we would expect failtime to decrease by 7.745%.

8.28

Read the problem description in the book but do not answer the questions in the book. Instead, respond to the questions shown below.

a.

Construct a scatterplot of HOURS vs. WAGES.

plot(HOURS~WAGES, data = miss)

What do you notice? The scatterplot shows a neagtive relation between WAGES and HOURs,with one extreme outlier around WAGES=12 and HOURS=540 . The relation appears to be linear.

b.

Fit a simple linear regression model to the data and perform a complete residual analysis. Arrange your plots in a 2x2 grid.

par(mfrow = c(2,2))
plot(HOURS~WAGES, data = miss)
miss_mod <- lm(HOURS~WAGES, data= miss)
abline(miss_mod)
plot(miss_mod, which = 1)
summary(miss_mod)
## 
## Call:
## lm(formula = HOURS ~ WAGES, data = miss)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -74.40 -48.27 -34.87 -14.94 443.06 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)   270.63     133.57   2.026   0.0638 .
## WAGES         -14.11      10.86  -1.299   0.2164  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 130.1 on 13 degrees of freedom
## Multiple R-squared:  0.1149, Adjusted R-squared:  0.04685 
## F-statistic: 1.688 on 1 and 13 DF,  p-value: 0.2164
plot(miss_mod, which = 3)
plot(miss_mod, which = 5)

plot(miss_mod)

Is there evidence of lack of fit? How do you know?

No, there is no strong evidence of a curved pattern, though the single extreme outlier heavily levers the slope of the regression line.

Is there evidence of heteroscedasticiy? How do you know?

No. The Scale-Location and Residuals vs. Fitted plot has an approximately horizontal red line which is flat around 0 and the spread of the residuals is fairly constant across the fitted values.

Is there evidence of non-normality? How do you know?

Yes. The Normal Q-Q plot shows a severe deviation from the straight reference line at the upper tail due to the extreme value of observation #13.

Are there any unusual values? If so, classify them as outliers, high leverage points, and/or influential points.

YES.Observation #13 is classified as an outlier because it has a high residual value. The Residuals VS Leverageplot shows there are 2 moderate leverage points and no high leverage and no influential point.

c.

After searching through its employees’ files, the firm has found that empolyee #13 had been fired but that his name had not been removed from the active employee payroll. This explains the large accumulation of work-hours missed by that employee. The code shown below will remove employee #13 from the data set. Refit the model to the data set after removing employee #13, and perform a complete residual analysis on the new model. Arrange your graphs in a 2x2 grid.

miss2 <- miss |> 
  filter(row_number() != 13)
par(mfrow = c(2,2))
plot(HOURS~WAGES, data = miss2)
miss2_mod <- lm(HOURS ~ WAGES, data = miss2)
abline(miss2_mod)
plot(miss2_mod, which = 1)
summary(miss2_mod)
## 
## Call:
## lm(formula = HOURS ~ WAGES, data = miss2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -43.007 -20.456  -4.515  14.339  59.435 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  246.580     29.383   8.392 2.30e-06 ***
## WAGES        -14.745      2.386  -6.181 4.72e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 28.59 on 12 degrees of freedom
## Multiple R-squared:  0.761,  Adjusted R-squared:  0.7411 
## F-statistic:  38.2 on 1 and 12 DF,  p-value: 4.721e-05
plot (miss2_mod, which= 3)
plot(miss2_mod, which = 5)

plot(miss2_mod)

Is there evidence of lack of fit? How do you know? Yes there is an evidence of lackk of fit because the Residuals Vs the Fitted plot shows a curved pattern rather than random scatter areound zero.

Is there evidence of heteroscedasticiy? How do you know? Yes there is evidence of heteroscedasticity because the Scale Location plot shows a non constant spread of residuals and the red line is not flat.

Is there evidence of non-normality? How do you know?

From the summary statustics the median is close to 0 and first quartile and third quartile appears to be approximately equal. SO there is no evidence for non normality.

Are there any unusual values? If so, classify them as outliers, high leverage points, and/or influential points.

From the Residual vs the Leverage plot, there are no any outiers. THere is one moderately leverage point, no high leverage and maybe one influential point when D(Cook Distance) is greater than 0.5 but less than1.

8.39

Only answer parts a, b, and c.

a.

There is an evidence of lack of fit(non linearity) because the residuals show a systematic curved pattern.

b.

There is evidence of heteroscedasity because the variability of the residuals increases as x increases. THe vertical spread of the residuals become larger as x increases, giving a fan shape.

c.

There is an outlier because one standardized residual is beyond -3s.