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

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

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

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

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

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

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

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

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

Arguments

object

A fitted model object from splm(), spautor(), spglm(), or spgautor().

type

"response" for fitted values of the response, "spcov" for fitted values of the spatial random errors, or "randcov" for fitted values of the random effects. If from spglm() or spgautor(), "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 "spcov" the fitted values for each observation are (generally) the best linear unbiased predictors of the spatial dependent and spatial independent 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 "spcov" and "randcov" can generally be used to check assumptions for each component of the fitted model object (e.g., check a Gaussian assumption).

Examples

spmod <- splm(z ~ water + tarp,
  data = caribou,
  spcov_type = "exponential", xcoord = x, ycoord = y
)
fitted(spmod)
#>        1        2        3        4        5        6        7        8 
#> 1.966709 2.253251 2.046762 2.049806 2.336347 2.046762 2.049806 1.966709 
#>        9       10       11       12       13       14       15       16 
#> 2.253251 2.046762 1.966709 2.253251 2.046762 2.336347 2.129858 2.049806 
#>       17       18       19       20       21       22       23       24 
#> 2.336347 2.129858 2.253251 2.046762 2.129858 1.966709 2.049806 2.336347 
#>       25       26       27       28       29       30 
#> 2.129858 2.049806 2.336347 2.129858 1.966709 2.253251 
fitted.values(spmod)
#>        1        2        3        4        5        6        7        8 
#> 1.966709 2.253251 2.046762 2.049806 2.336347 2.046762 2.049806 1.966709 
#>        9       10       11       12       13       14       15       16 
#> 2.253251 2.046762 1.966709 2.253251 2.046762 2.336347 2.129858 2.049806 
#>       17       18       19       20       21       22       23       24 
#> 2.336347 2.129858 2.253251 2.046762 2.129858 1.966709 2.049806 2.336347 
#>       25       26       27       28       29       30 
#> 2.129858 2.049806 2.336347 2.129858 1.966709 2.253251 
fitted(spmod, type = "spcov")
#> $de
#>           1           2           3           4           5           6 
#>  0.19009135  0.08808946 -0.05288712 -0.06331824 -0.02856777  0.09098076 
#>           7           8           9          10          11          12 
#>  0.01072506 -0.09354048 -0.12314818 -0.05923981 -0.03596157 -0.07841306 
#>          13          14          15          16          17          18 
#> -0.13175388 -0.11441342 -0.11280667 -0.12561669 -0.08822084 -0.17365706 
#>          19          20          21          22          23          24 
#> -0.17132052 -0.14840042 -0.08447864 -0.10445284 -0.17663020 -0.19065413 
#>          25          26          27          28          29          30 
#> -0.13413900 -0.08936860 -0.15019468 -0.15571767 -0.17050442 -0.15814674 
#> 
#> $ie
#>            1            2            3            4            5            6 
#>  0.264329030  0.101709816 -0.183964708 -0.020497847  0.069254386  0.086299996 
#>            7            8            9           10           11           12 
#>  0.040488767 -0.069202761 -0.167184456  0.111532939 -0.044769687 -0.044859570 
#>           13           14           15           16           17           18 
#> -0.054034211  0.144136768 -0.023062960 -0.287330302  0.198971087 -0.137268598 
#>           19           20           21           22           23           24 
#> -0.036948221 -0.057389311  0.069654486  0.133809193 -0.072211253 -0.096740681 
#>           25           26           27           28           29           30 
#>  0.133346093  0.062593275 -0.136219497  0.054886276 -0.007208414 -0.032119633 
#>