The data was sourced from https://www.mathsisfun.com/data/correlation.html, which is an educational website. It is composed of 12 data points, one for each month of the year, starting in January and ending in December.
Revenue<-c(215, 325, 185, 332, 406, 522, 412, 614, 544, 421, 445, 408)
Temperature<-c(14.2,16.4,11.9,15.2,18.5,22.1,19.4,25.1,23.4,18.1,22.6,17.2)
IC<-lm(Temperature~Revenue)
summary(IC)
##
## Call:
## lm(formula = Temperature ~ Revenue)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.64513 -0.49846 -0.08613 0.41632 2.62743
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.412805 1.219376 5.259 0.000369 ***
## Revenue 0.030471 0.002902 10.499 1.02e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.213 on 10 degrees of freedom
## Multiple R-squared: 0.9168, Adjusted R-squared: 0.9085
## F-statistic: 110.2 on 1 and 10 DF, p-value: 1.016e-06
plot(Revenue,Temperature,main="Ice Cream Revenue v. Temperature",xlab="Revenue (dollars)",ylab="Temperature (Celsius)")
abline(IC,col="red")
fitted<-coef(IC)
int<-fitted[1]
slope<-fitted[2]
slope
## Revenue
## 0.03047139
residuals(IC)
## 1 2 3 4 5 6
## 1.23584611 0.08399334 -0.15001223 -1.32930638 -0.28418914 -0.21887024
## 7 8 9 10 11 12
## 0.43298252 -0.02223800 0.41075921 -1.14125997 2.62742670 -1.64513192
res<-residuals(IC)
res
## 1 2 3 4 5 6
## 1.23584611 0.08399334 -0.15001223 -1.32930638 -0.28418914 -0.21887024
## 7 8 9 10 11 12
## 0.43298252 -0.02223800 0.41075921 -1.14125997 2.62742670 -1.64513192
plot(Revenue,res)
abline(a=0,b=0,col="blue")
This data was modeled with the linear equation \(Temperature=\epsilon\ revenue + \alpha\) where the slope is equal to 0.030471. The \(R^2\) value is 0.9168, which indicates a strongly linear relationship between ice cream revenue and temperature. As the temperature increased, the ice cream revenue (sales) also increased.