I have three variables:
- Number of house sales
- Month (in couples)
- Region of a city (N-W-E-S)
and I want to calculate confidence intervals for the residual of the errors. So, given the data:
month <- c("1", "1", "1", "1", "2", "2", "2", "2", "3", "3", "3",
"3", "4", "4", "4", "4", "5", "5", "5", "5", "6", "6", "6",
"6")
region <-c("1", "2", "3", "4", "1", "2", "3", "4", "1", "2", "3",
"4", "1", "2", "3", "4", "1", "2", "3", "4", "1", "2", "3",
"4")
sales <-c(85, 107, 61, 22, 40, 65, 58, 51, 60, 41, 45, 27, 15,
30, 68, 63, 28, 3, 57, 12, 36, 21, 10, 16)
data <- cbind(sales, month, region)
data <- as.data.frame(data)
salesmod <- lm(sales ~ month + region, data=data)
summary(salesmod)
anova(salesmod)
We can check the degrees of freedom and the sum of the residuals from the summary(salesmod) and anova(salesmod).
Call:
lm(formula = sales ~ month + region, data = data)
Residual standard error: 22.88 on 15 degrees of freedom
Multiple R-squared: 0.4855, Adjusted R-squared: 0.2111
F-statistic: 1.769 on 8 and 15 DF, p-value: 0.1623
> anova(salesmod)
Analysis of Variance Table
Response: sales
Df Sum Sq Mean Sq F value Pr(>F)
month 5 6368.7 1273.74 2.4325 0.0835 .
region 3 1042.8 347.60 0.6638 0.5871
Residuals 15 7854.5 523.63
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
So the variance of the residuals would be $523.63/15=34.90867$, but how do I compute a confidence intervals for this value (of given 95% confidence).