# Understanding confidence intervals with coefficients

maybe someone can put me in the right direction. I already read some of the "understand confidence intervals" posts, but none of them seem to give me the information I need. I am a student and I am dealing with a task, of which I do not understand the solution the professor has provided.

We are an ice cream shop and based on the history of data we have been thinking of adding two more types of ice cream to the shop. We have a total of 5 different shops, where each of them has a different amount of types of ice cream. We have been given a full year of data, where each day records temperature, types of ice cream available, the revenue, and the location.

I created a linear model based on the data. The question where I am struggling to understand the solution is the following.

Question: Does it make sense to sell two more types of ice cream? The costs would increase by 2000$per location. What is the confidence interval for the revenue generated? What I basically did is the following: df = read.csv(....) modell1= lm(revenue ~ temp + location + types, data=df) confidenceprediction = data.frame() for( i in 1:1000){ confidenceprediction = rbind(confidenceprediction, predict(modell1, newdata = data.frame( types = df$$types[i]+2, temp = df$$temp[i], location=df$location[i]), interval = "confidence"))
}
colMeans(confidenceprediction)

# > colMeans(confidenceprediction)
# fit      lwr      upr
# 697.0656 674.1053 720.0259



I wanted to use my model to predict a revenue each day with two more types of ice cream. I used the interval="confidence" parameter to get a confidence value. Then I looked at the column Means for the entire prediction. This tells me that in a 95% confidence interval, my revenue should be at least 674$$and max 720$$.

However, his solution just does something I cannot quite grasp.

confint(modell1)["types",]*2*365
#    2.5 %    97.5 %
# -1194.145  7851.394



He just multiplies the confidence interval, taken from the model by two, and of course by 365.

Please answer me this: Why is he allowed to do something like this, and why does it differ from my solution so much?

For the sake of it here is a summary and a full confint. We did not transform any values or introduced interaction terms.

> summary(modell1)

Call:
lm(revenue ~ temp + location + types, data=df)

Residuals:
Min      1Q  Median      3Q     Max
-428.21  -76.52    1.13   81.02  394.08

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 542.7094    39.8734  13.611  < 2e-16 ***
temp          6.7115     0.5877  11.421  < 2e-16 ***
locationB   105.9596    30.3248   3.494 0.000497 ***
locationC     2.4538    12.2817   0.200 0.841683
locationD   -11.5054    15.3460  -0.750 0.453595
locationE   -18.1600    12.3012  -1.476 0.140184
types        4.5598     3.1572   1.444 0.148988
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 120.4 on 993 degrees of freedom
Multiple R-squared:  0.4748,    Adjusted R-squared:  0.4716
F-statistic: 149.6 on 6 and 993 DF,  p-value: < 2.2e-16

> confint(modell1)
2.5 %     97.5 %
(Intercept) 464.463523 620.955204
temp          5.558346   7.864708
locationB    46.451474 165.467683
locationC   -21.647215  26.554820
locationD   -41.619779  18.609023
locationE   -42.299320   5.979235
types       -1.635815  10.755334

$$$$

• Concerning your lecturer's solution: is the multiplication not due to the fact that you work with daily data and add two new types of ice cream? Hence you need to multiply the uncertainty interval for the types variable by 2 (since you add two new flavours) and 365 days to get annual revenue. May 30 '20 at 14:21
• @horseoftheyear hmm, that would make sense. But he cannot just ignore the fact that there are locations that sell 13 types, and others that sell 17 types? Additionally, doesn't this method introduce a lot of room for error? On a mean(df$types) we get 13.64 types of ice cream per day. Is the confidence interval based on this 13.64 value? I do not know how this is calculated within the model itself, we never discussed this. But multiplying it would mean we sell ~27 types of icecream now or? May 30 '20 at 14:24 • So the types variable is a count for the number of different types of ice cream available at a location (from your description). Hence the estimated coefficient represents the effect of a one unit increase in types on the outcome variable, revenue. Ergo an additional type of ice cream is associated with an increase of 5$\pm\$ 3 whatever-currency in daily revenue. May 30 '20 at 14:38
• Ah! everything makes sense now. Let's say I want to know how a +1.5 degree temperature increase reflects in the revenue I can just do a confint(model1)["temperature",]*1.5*365 and I have my solution. Could you maybe explain me, why my prediction solution does not come close to the interval we get with the confint` method? May 30 '20 at 14:44
• The prediction approach you used generates prediction intervals for single observations, which you then average. This is a different interval compared to the regression uncertainty interval based on a parameter estimate. May 30 '20 at 15:04