The augment()
function in the broom package for R creates a dataframe of predicted values from a regression model. Columns created include the fitted values, the standard error of the fit and Cook's distance. They also include something with which I'm not familar and that is the column .hat
.
Can anyone explain what this value is, and is it different between linear regression and logistic regression?
library(broom)
data(mtcars)
m1 <- lm(mpg ~ wt, data = mtcars)
head(augment(m1))
.rownames mpg wt .fitted .se.fit .resid .hat .sigma .cooksd
1 Mazda RX4 21.0 2.620 23.28261 0.6335798 -2.2826106 0.04326896 3.067494 1.327407e-02
2 Mazda RX4 Wag 21.0 2.875 21.91977 0.5714319 -0.9197704 0.03519677 3.093068 1.723963e-03
3 Datsun 710 22.8 2.320 24.88595 0.7359177 -2.0859521 0.05837573 3.072127 1.543937e-02
4 Hornet 4 Drive 21.4 3.215 20.10265 0.5384424 1.2973499 0.03125017 3.088268 3.020558e-03
5 Hornet Sportabout 18.7 3.440 18.90014 0.5526562 -0.2001440 0.03292182 3.097722 7.599578e-05
6 Valiant 18.1 3.460 18.79325 0.5552829 -0.6932545 0.03323551 3.095184 9.210650e-04