Compute the leverage (hat) value for each observation from a fitted model object.

# S3 method for ssn_lm
hatvalues(model, ...)

# S3 method for ssn_glm
hatvalues(model, ...)

Arguments

model

A fitted model object from ssn_lm() or ssn_glm().

...

Other arguments. Not used (needed for generic consistency).

Value

A vector of leverage (hat) values for each observation from the fitted model object.

Details

Leverage values measure how far an observation's explanatory variables are relative to the average of the explanatory variables. In other words, observations with high leverage are typically considered to have an extreme or unusual combination of explanatory variables. Leverage values are the diagonal of the hat (projection) matrix. The larger the hat value, the larger the leverage.

Examples

# Copy the mf04p .ssn data to a local directory and read it into R
# When modeling with your .ssn object, you will load it using the relevant
# path to the .ssn data on your machine
copy_lsn_to_temp()
temp_path <- paste0(tempdir(), "/MiddleFork04.ssn")
mf04p <- ssn_import(temp_path, overwrite = TRUE)

ssn_mod <- ssn_lm(
  formula = Summer_mn ~ ELEV_DEM,
  ssn.object = mf04p,
  tailup_type = "exponential",
  additive = "afvArea"
)
hatvalues(ssn_mod)
#>           1           2           3           4           5           6 
#> 0.111004780 0.055738061 0.033706428 0.074359366 0.020156027 0.005693127 
#>           7           8           9          10          11          12 
#> 0.001624725 0.057398164 0.073923742 0.058051176 0.025562432 0.027726546 
#>          13          14          15          16          17          18 
#> 0.025641370 0.060692330 0.083505795 0.029915738 0.015064681 0.017762234 
#>          19          20          21          22          23          24 
#> 0.007203224 0.014860920 0.014280350 0.012121476 0.073987730 0.030984461 
#>          25          26          27          28          29          30 
#> 0.051576193 0.054619566 0.013623967 0.043036889 0.120814555 0.112522931 
#>          31          32          33          34          35          36 
#> 0.058861422 0.019483321 0.005954595 0.004592189 0.009847750 0.005559533 
#>          37          38          39          40          41          42 
#> 0.002381727 0.033445107 0.035807368 0.046264890 0.057583822 0.065328710 
#>          43          44          45 
#> 0.138148339 0.030372326 0.159209917