Problem 11.27 on page 610 of your textbook

A firm that prints automobile bumper stickers conducts a study to investigate the relation between the direct cost of producing an order of bumper stickers (TOTCOST) and the number of stickers (RunSize, in 1000s of Stickers) in a particular order. The data are as follows:

RunSize = c(2.6,5.0,10,2,0.8,4,2.5,0.6,0.8,1,2,3,0.4,0.5,5,20,5,2,1,1.5,0.5,1,1,0.6,2.0,
            1.5,3,6.5,2.2,1)
TOTCOST = c(230,341,629,187,159,327,206,124,155,147,209,247,135,125,366,1146,
            339,208,150,179,128,155,143,131,219,171,258,415,226,159)

a. Plot a scatterplot of the data. Overlay the LOWESS line on the scatterplot. Based on the plot, is linear regression appropriate to use to model total cost of bumper stickers using the number of stickers .

The lowess line shows a linear relationship so we can continue with the linear regression

plot(RunSize,TOTCOST)
lines(lowess(RunSize,TOTCOST))

b. Calculate the estimate of least squares line.

regression = lm(TOTCOST~RunSize)
summary(regression)
## 
## Call:
## lm(formula = TOTCOST ~ RunSize)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -23.572  -6.859   1.805   7.726  19.552 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  99.7770     2.8273   35.29   <2e-16 ***
## RunSize      51.9179     0.5865   88.53   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.21 on 28 degrees of freedom
## Multiple R-squared:  0.9964, Adjusted R-squared:  0.9963 
## F-statistic:  7837 on 1 and 28 DF,  p-value: < 2.2e-16

c. Interpret the slope of the least squares line.

#For every additional thousand stickers the company produces, the cost of the batch of stickers increases by $51.91

d. Predict the total direct cost of producing 5000 bumper stickers.

prod5= data.frame(RunSize = c(5))
predict(regression,prod5)
##        1 
## 359.3663
# $359.37

e. Estimate the residual standard deviation.

sum(regression$residuals^2)/28
## [1] 148.9994

f. Construct and interpret a 95% confidence interval for the slope of the least squares line.

confint(regression)
##                2.5 %    97.5 %
## (Intercept) 93.98557 105.56848
## RunSize     50.71656  53.11916

g. Construct and interpret a 95% confidence interval for the direct cost of producing 5000 bumper stickers.

predict(regression,prod5,interval = 'confidence')
##        fit      lwr      upr
## 1 359.3663 354.1888 364.5438

g. Construct and interpret a 95% prediction interval for the direct cost of producing 5000 bumper stickers.

predict(regression,prod5,interval = 'predict')
##        fit      lwr      upr
## 1 359.3663 333.8319 384.9007