Extract fitted values from fitted model objects. fitted.values is an alias.

# S3 method for ssn_lm
fitted(object, type = "response", ...)

# S3 method for ssn_lm
fitted.values(object, type = "response", ...)

# S3 method for ssn_glm
fitted(object, type = "response", ...)

# S3 method for ssn_glm
fitted.values(object, type = "response", ...)

Arguments

object

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

type

"response" for fitted values of the response, "tailup" for fitted values of the tailup random errors, "taildown" for fitted values of the taildown random errors, "euclid" for fitted values of the Euclidean random errors, "nugget" for fitted values of the nugget random errors, or "randcov" for fitted values of the random effects. If from ssn_glm(), "link" for fitted values on the link scale. The default is "response".

...

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

Value

The fitted values according to type.

Details

When type is "response", the fitted values for each observation are the standard fitted values \(X \hat{\beta}\). When type is "tailup", "taildown", "euclid", or "nugget" the fitted values for each observation are (generally) the best linear unbiased predictors of the respective random error. When type is "randcov", the fitted values for each level of each random effect are (generally) the best linear unbiased predictors of the corresponding random effect. The fitted values for type "tailup", "taildown", "euclid", "nugget", and "randcov" can generally be used to check assumptions for each component of the fitted model object (e.g., check a Gaussian assumption).

If from ssn_glm(), when type is "response", the fitted values for each observation are the standard fitted values on the inverse link scale: \(g^{-1}\)(\(X \hat{\beta} + \nu\)), where \(g(.)\) is a link function, \(\beta\) are the fixed effects, and \(\nu\) are the spatial and random effects.

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"
)
fitted(ssn_mod)
#>         1         2         3         4         5         6         7         8 
#> 14.417439 14.246817 14.042070 15.236427 14.929306 14.656310 14.656310 14.485688 
#>         9        10        11        12        13        14        15        16 
#> 14.383315 14.315066 14.349190 14.315066 14.280941 13.393704 13.154833 12.847712 
#>        17        18        19        20        21        22        23        24 
#> 12.369969 12.301720 12.199347 11.823977 11.823977 11.721604 13.018335 12.165222 
#>        25        26        27        28        29        30        31        32 
#> 12.096973 12.096973 11.312110 10.834367 10.356624  9.708258 13.461953 13.223082 
#>        33        34        35        36        37        38        39        40 
#> 12.642965 12.540592 12.711214 12.404094 11.721604 11.380359 11.039114 10.902616 
#>        41        42        43        44        45 
#> 10.186001  9.981254 12.062849 11.448608 11.175612 
fitted.values(ssn_mod)
#>         1         2         3         4         5         6         7         8 
#> 14.417439 14.246817 14.042070 15.236427 14.929306 14.656310 14.656310 14.485688 
#>         9        10        11        12        13        14        15        16 
#> 14.383315 14.315066 14.349190 14.315066 14.280941 13.393704 13.154833 12.847712 
#>        17        18        19        20        21        22        23        24 
#> 12.369969 12.301720 12.199347 11.823977 11.823977 11.721604 13.018335 12.165222 
#>        25        26        27        28        29        30        31        32 
#> 12.096973 12.096973 11.312110 10.834367 10.356624  9.708258 13.461953 13.223082 
#>        33        34        35        36        37        38        39        40 
#> 12.642965 12.540592 12.711214 12.404094 11.721604 11.380359 11.039114 10.902616 
#>        41        42        43        44        45 
#> 10.186001  9.981254 12.062849 11.448608 11.175612