Skip to contents

Computes the hat values for feols or feglm estimations.

Usage

# S3 method for class 'fixest'
hatvalues(model, exact = TRUE, boot.size = 1000, ...)

Arguments

model

A fixest object. For instance from feols or feglm.

exact

Logical scalar, default is TRUE. Whether the diagonals of the projection matrix should be calculated exactly. If FALSE, then it will be approximated using a JLA algorithm. See details. Unless you have a very large number of observations, it is recommended to keep the default value.

boot.size

Integer scalar or NULL, default is 1000. This is only used when exact == FALSE. This determines the number of bootstrap samples used to estimate the projection matrix. If equal to NULL, it falls back to the default value of 1000.

...

Not currently used.

Value

Returns a vector of the same length as the number of observations used in the estimation.

Details

Hat values are not available for fenegbin, femlm and feNmlm estimations.

Hat values for generalized linear model are disussed in Belsley, Kuh and Welsch (1980), Cook and Weisberg (1982), etc.

When exact == FALSE, the Johnson-Lindenstrauss approximation (JLA) algorithm is used which approximates the diagonals of the projection matrix. For more precision (but longer time), increase the value of boot.size. See Kline, Saggio, and Sølvsten (2020) for details.

References

Belsley, D. A., Kuh, E. and Welsch, R. E. (1980). Regression Diagnostics. New York: Wiley. Cook, R. D. and Weisberg, S. (1982). Residuals and Influence in Regression. London: Chapman and Hall. Kline, P., Saggio R., and Sølvsten, M. (2020). Leave‐Out Estimation of Variance Components. Econometrica.

Examples


est = feols(Petal.Length ~ Petal.Width + Sepal.Width, iris)
head(hatvalues(est))
#> [1] 0.02042587 0.02110119 0.01838332 0.01933430 0.02273855 0.03265226