Description Usage Format Examples
A synthetic dataset on weekly ice cream sales in two locations in Amsterdam, along with air temperature. The idea is that the ice cream salesman first sold icecream in 'Oosterpark', and decided to move shop to the 'Dappermarkt' the year after. Did sales improve? This dataset can be used to show that naive conclusions from simple linear model fits can be misleading, and that the use of covariates (here, air temperature) can change conclusions about effects.
1 |
A data frame with 40 rows and 3 variables:
temperature
double Air temperature (C)
sales
double Icecream sales per week (in local currency)
location
factor Either 'Dappermarkt' or 'Oosterpark'
1 2 3 4 5 6 7 8 9 10 11 | data(icecream)
# Linear model, temperature as covariate
fit_ice <- lm(sales ~ temperature*location, data=icecream)
# Try to guess from coefficients where the sales were higher:
summary(fit_ice)
# What about now?
with(icecream, plot(temperature, sales, pch=19, col=location))
legend("topleft", levels(icecream$location), fill=palette())
|
Call:
lm(formula = sales ~ temperature * location, data = icecream)
Residuals:
Min 1Q Median 3Q Max
-63.018 -32.222 3.449 28.157 83.390
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 78.407 27.717 2.829 0.00759 **
temperature 37.481 1.704 21.995 < 2e-16 ***
locationOosterpark 99.644 42.527 2.343 0.02477 *
temperature:locationOosterpark -11.194 2.255 -4.963 1.68e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 36.86 on 36 degrees of freedom
Multiple R-squared: 0.9588, Adjusted R-squared: 0.9554
F-statistic: 279.6 on 3 and 36 DF, p-value: < 2.2e-16
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.