# A tibble: 8 × 6
`Data set` term estimate std.error statistic p.value
<chr> <chr> <dbl> <dbl> <dbl> <dbl>
1 Data set 1 (Intercept) 3.00 1.12 2.67 0.0257
2 Data set 1 x 0.500 0.118 4.24 0.00217
3 Data set 2 (Intercept) 3.00 1.13 2.67 0.0258
4 Data set 2 x 0.5 0.118 4.24 0.00218
5 Data set 3 (Intercept) 3.00 1.12 2.67 0.0256
6 Data set 3 x 0.500 0.118 4.24 0.00218
7 Data set 4 (Intercept) 3.00 1.12 2.67 0.0256
8 Data set 4 x 0.500 0.118 4.24 0.00216
Scatter plots
Code
fig_norm_anscombe <- norm_anscombe %>%mutate(data_sample =str_c("Data set ", data_sample))fig_norm_anscombe %>%ggplot() +aes(x, y, group = data_sample) +geom_point() +geom_smooth(data =filter(fig_norm_anscombe, data_sample =="Model 2"),method ="lm",formula = y ~ x +I(x ^2) ) +geom_smooth(data =filter(fig_norm_anscombe, data_sample =="Model 3", y <11) ) +geom_abline(slope =0.5, intercept =3, colour ="red") +theme_bw() +facet_wrap(. ~ data_sample)
Residuals vs fitted
Example 2: Wage and Education
Example 3: Sales and CEO salary
Example 4: Acceptable linearity
Example 5: Fuel taxes influence on fuel consumption?
As a federal policy maker, we would like to understand how fuel taxes were affecting the gasoline consumption across the states.
We use data on fuel consumption in 2001 across all states in the USA (each observation represents a state). Data from (weisberg2013a?).
Variables present in the data are:
\(\text{Tax}\) : Gasoline state tax rate, cents per gallon;
\(\text{Dlic}\) : The number of licensed drivers per 1000 population over the age of 16;;
\(\text{Income}\) : in 1000 USD Per capita personal income (year 2000);
\(\text{Miles}\) : Miles of Federal-aid highway miles in the state;
\(\text{Fuel}\) : Gasoline consumption per capita (gal.);