Use the data from the Copier Service Example to answer the following. a. What is
ID: 3039818 • Letter: U
Question
Use the data from the Copier Service Example to answer the following.
a. What is a 95% confidence interval for yhat when xh= 4?
b. What is a 95% confidence interval for yhat when xh = 8?
c. What is a 95% confidence interval for the average of the next 25 observations when xh = 4?
Copiersx) Time(y) (xi-x)2 (yi-y)2 (xi-x)(yi-y) 2 20 10 3,166 175 4 60 1 265 (65) 3 46 4 916 (87) 2 41 10 1,244 (71) 1 12 17 4,130 (64) 10 137 24 3,689 607 5 68 0 68 (41) 5 89 0 162 64 1 4 17 5,222 (72) 2 32 10 1,960 (89) 9 144 15 4,588 610 10 156 24 6,357 797 6 93 1 280 100 3 36 4 1,621 (121) 4 72 1 18 (17) 8 100 8 563 190 7 105 4 826 201 8 131 8 2,996 438 10 127 24 2,574 507 4 57 1 371 (77) 5 66 0 105 (51) 7 101 4 612 173 7 109 4 1,071 229 5 74 0 5 (11) 9 134 15 3,333 520 7 112 4 1,277 250 2 18 10 3,395 (117) 5 73 0 11 (16) 7 111 4 1,206 243 6 96 1 389 118 8 123 8 2,184 374 5 90 0 189 69 2 20 10 3,166 (113) 2 28 10 2,330 (97) 1 3 17 5,368 (73) 4 57 1 371 (77) 5 86 0 95 49 9 132 15 3,106 502 7 112 4 1,277 250 1 27 17 2,427 (49) 9 131 15 2,996 493 2 34 10 1,786 (85) 2 27 10 2,427 (99) 4 61 1 233 (61) 5 77 0 1 4 sum 230 3,432 340 80,377 5,410 mean 5.111Explanation / Answer
## Input first 2 columns as a data frame. First save the spreadsheet as a .csv file in your working directory
newd = read.csv("Untitled.csv", header = TRUE)
newd = newd[1:2]
## Fit a linear regression model for y on x
fit = lm(y~x, data = newd)
summary(fit)
## Looking at the results (p-value), x is a significant factor in determining y
### PART (a)
newd4 = data.frame(x = c(4))
pred4 = predict(fit, newdata = newd4, interval = "confidence", level = 0.95)
## fit lwr upr
## 59.56084 56.67078 62.45089 <-- [Answer (a)]
### PART (b)
newd8 = data.frame(x = c(8))
pred8 = predict(fit, newdata = newd8, interval = "confidence", level = 0.95)
## fit lwr upr
## 119.7018 115.8157 123.5879 <-- [Answer (b)]
### PART (c)
## Number of observations = nrow(newd) = 45
## Average of next 25 observations can only be done for first 21 rows
avg_25 = list()
for(i in 1:nrow(newd))
{
if(nrow(newd)-i>=24)
{
avg_25[i] = mean(newd$y[i:(i+24)])
}
else
{
avg_25[i] = NA
}
}
newd$z = as.double(avg_25)
rm(avg_25)
newd1 = subset(newd, subset = (newd$z > 0))
plot(y = newd1$z, x = newd1$x)
## Model (linear regression) this new variable z (average of next 25 observations) on x
fit_z = lm(z~x, data = newd1)
summary(fit_z)
## Looking at the results (p-value), x is NOT a significant factor in determining z
newd4 = data.frame(x = c(4))
pred4_z = predict(fit_z, newdata = newd4, interval = "confidence", level = 0.95)
## fit lwr upr
## 83.96217 81.84072 86.08362 <-- [Answer (c)]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.