Generic function for extracting the empirical estimating functions of a fitted model.

estfun(x, ...)

Arguments

x

a fitted model object.

...

arguments passed to methods.

Value

A matrix containing the empirical estimating functions. Typically, this should be an \(n \times k\) matrix corresponding to \(n\) observations and \(k\) parameters. The columns should be named as in coef or terms, respectively.

The estimating function (or score function) for a model is the derivative of the objective function with respect to the parameter vector. The empirical estimating functions is the evaluation of the estimating function at the observed data (\(n\) observations) and the estimated parameters (of dimension \(k\)).

See also

References

Zeileis A (2006). “Object-Oriented Computation of Sandwich Estimators.” Journal of Statistical Software, 16(9), 1--16. doi:10.18637/jss.v016.i09

Zeileis A, Köll S, Graham N (2020). “Various Versatile Variances: An Object-Oriented Implementation of Clustered Covariances in R.” Journal of Statistical Software, 95(1), 1--36. doi:10.18637/jss.v095.i01

Examples

## linear regression
x <- 1:9
y <- sin(1:9/5)
m <- lm(y ~ x)

## estimating function: (y - x'beta) * x
estfun(m)
#>   (Intercept)           x
#> 1 -0.13577304 -0.13577304
#> 2 -0.04481531 -0.08963062
#> 3  0.03061755  0.09185265
#> 4  0.08353989  0.33415956
#> 5  0.10786351  0.53931755
#> 6  0.09864034  0.59184202
#> 7  0.05225971  0.36581794
#> 8 -0.03340770 -0.26726157
#> 9 -0.15892494 -1.43032449
residuals(m) * cbind(1, x)
#>                             x
#>  [1,] -0.13577304 -0.13577304
#>  [2,] -0.04481531 -0.08963062
#>  [3,]  0.03061755  0.09185265
#>  [4,]  0.08353989  0.33415956
#>  [5,]  0.10786351  0.53931755
#>  [6,]  0.09864034  0.59184202
#>  [7,]  0.05225971  0.36581794
#>  [8,] -0.03340770 -0.26726157
#>  [9,] -0.15892494 -1.43032449