ggplot(LionNoses, aes(proportion.black, age)) + geom_point() +
geom_smooth(method = "lm")Understand approaches for visualizing fitted multiple regression models
Call:
lm(formula = clutch ~ year + date, data = clutch.r)
Residuals:
Min 1Q Median 3Q Max
-3.2815 -0.6219 -0.2235 0.6514 3.9304
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 15.852483 0.757991 20.914 < 2e-16 ***
year1998 -0.344801 0.287552 -1.199 0.233
year1999 -0.125952 0.274168 -0.459 0.647
date -0.041478 0.005904 -7.026 1.07e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.288 on 130 degrees of freedom
Multiple R-squared: 0.2789, Adjusted R-squared: 0.2623
F-statistic: 16.76 on 3 and 130 DF, p-value: 2.889e-09
\[Clutch_i \sim N(\mu_i, \sigma^2)\] \[\mu_i = \beta_0+\beta_1I(Year = 1998)_i + \beta_2I(year = 1999)_i + \beta_3date_i\]
\(\beta_3\) reflects the “effect” of nest initiation date after accounting for year.
How can we visualize this “effect”?
See the paper by Larano and Corcobado (2008) and Section 3.14 in the Book.
Plots the part of \(Y\) not explained by other predictors (i.e., \(X_{-i}\)) against the part of \(X_i\) not explained by the other predictors (\(X_{-i}\)).
Lets us visualize the effect of \(X_i\) after accounting for all other predictors.
Plots \(X_i\beta_i + \hat{\epsilon}_i\) versus \(X_i\).
See Section 3.14.3 in the Book. Consider a focal predictor \(X_i\) and the set of all other predictors \(X_{-i}\).
We can plot adjusted means by varying a focal variable over its range of observed values, while holding all non-focal variables at constant values (e.g., at their means or modal values).
Depict \(E[Y_i | X_{-i} = x_{-i}]\) versus \(X_i\).
Alternatively, we can plot marginal means. These are formed in much the same way, except that predictions are averaged across different levels of each categorical variable.
These two types of means are equivalent if there are no categorical predictors in the model.