Compute the Cook's distance for each observation from a fitted model object.
# S3 method for ssn_lm
cooks.distance(model, ...)
# S3 method for ssn_glm
cooks.distance(model, ...)
A vector of Cook's distance values for each observation from the fitted model object.
Cook's distance measures the influence of an observation on a fitted model object. If an observation is influential, its omission from the data noticeably impacts parameter estimates. The larger the Cook's distance, the larger the influence.
# 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"
)
cooks.distance(ssn_mod)
#> 1 2 3 4 5 6
#> 1.647503e-02 1.728298e-03 6.579438e-03 8.927099e-03 1.578560e-02 9.701374e-04
#> 7 8 9 10 11 12
#> 5.068794e-05 1.432315e-02 6.663274e-03 1.956699e-02 5.615854e-03 3.310957e-04
#> 13 14 15 16 17 18
#> 3.666827e-04 1.131630e-01 3.727255e-02 1.286650e-02 6.826981e-04 6.797500e-05
#> 19 20 21 22 23 24
#> 3.876893e-03 1.462109e-04 8.518871e-05 1.666836e-03 2.434997e-03 3.522678e-02
#> 25 26 27 28 29 30
#> 9.185776e-02 1.757621e-04 4.823722e-03 9.509376e-02 1.457562e-02 2.230686e-02
#> 31 32 33 34 35 36
#> 2.639139e-02 1.328369e-02 1.305442e-03 1.840481e-03 6.386774e-04 3.336002e-04
#> 37 38 39 40 41 42
#> 1.436665e-04 1.288808e-01 4.569277e-04 1.439454e-03 4.960449e-03 4.691920e-03
#> 43 44 45
#> 1.208746e-02 4.362963e-02 5.795615e-01