Compute the Cook's distance for each observation from a fitted model object.
Usage
# S3 method for ssn_lm
cooks.distance(model, ...)
# S3 method for ssn_glm
cooks.distance(model, ...)
Details
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.
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"
)
cooks.distance(ssn_mod)
#> 1 2 3 4 5 6
#> 1.352055e-01 1.838183e-02 1.031477e-02 2.394619e-04 6.738905e-06 2.853609e-03
#> 7 8 9 10 11 12
#> 1.444345e-05 7.407903e-05 8.913727e-04 2.902180e-02 7.151814e-02 1.478130e-01
#> 13 14 15 16 17 18
#> 1.325513e-03 8.944452e-02 2.518628e-02 2.855456e-02 4.559303e-02 3.189087e-02
#> 19 20 21 22 23 24
#> 3.236705e-03 1.820146e-03 1.613470e-04 2.607051e-04 5.023190e-04 9.990331e-02
#> 25 26 27 28 29 30
#> 1.362150e-03 1.769408e-03 2.791224e-02 2.507513e-03 7.423961e-03 5.168470e-02
#> 31 32 33 34 35 36
#> 3.062191e-04 3.654006e-04 1.628686e-03 2.898565e-03 1.940961e-04 8.450436e-03
#> 37 38 39 40 41 42
#> 5.261079e-05 7.816457e-05 6.103392e-05 9.366436e-03 1.201142e-02 1.870026e-03
#> 43 44 45
#> 5.228889e-03 8.723253e-03 2.611896e-03