hat values in regression?

Discuss statistics related things
Post Reply
sfcheung
Posts: 11
Joined: Wed Jan 19, 2022 5:29 am

hat values in regression?

Post by sfcheung »

In the standard module for linear regression, there is an option to save Cook's distance, predicted values, and residuals.
Is there also an option to save hat values? I searched but have not yet found this option, if it exists. I thought it should be somewhere, given that the module can save Cook's distance, and hatvalues() is in the stats package.

Thanks.

-- Shu Fai
bcollins
Posts: 6
Joined: Wed Sep 06, 2017 6:09 pm

Re: hat values in regression?

Post by bcollins »

Yes. In the current version you can save all three. Aren't hat values the same as predicted values?
sfcheung
Posts: 11
Joined: Wed Jan 19, 2022 5:29 am

Re: hat values in regression?

Post by sfcheung »

Sorry for the confusion caused. By hat values I meant the values of leverage reported in SPSS or hatvalues() in the stats package (previously in the car package, if I recall correctly). This is an example:

Code: Select all

set.seed(487053)
n <- 100
x <- rnorm(n)
y <- .6 * x + rnorm(n, 0, sqrt(1 - .6^2))
fit <- lm(y ~ x)
head(fitted(fit))
#>           1           2           3           4           5           6 
#> -0.76511150  0.22895093  0.05261076  0.36833248  0.24762286 -0.66486406
head(hatvalues(fit))
#>          1          2          3          4          5          6 
#> 0.02376032 0.01138044 0.01009515 0.01345880 0.01160445 0.02034855
Post Reply