Utility to extract the residuals from multiple fixest
estimations. If possible,
all the residuals are coerced into a matrix.
Arguments
- object
A
fixes_multi
object.- type
A character scalar, either
"response"
(default),"deviance"
,"pearson"
, or"working"
. Note that the"working"
corresponds to the residuals from the weighted least square and only applies tofeglm
models.- na.rm
Logical, default is
FALSE
. Should the NAs be kept? IfTRUE
, they are removed.- ...
Not currently used.
Value
If all the models return residuals of the same length, a matrix is returned. Otherwise,
a list
is returned.
Examples
base = iris
names(base) = c("y", "x1", "x2", "x3", "species")
# A multiple estimation
est = feols(y ~ x1 + csw0(x2, x3), base)
# We can get all the residuals at once,
# each column is a model
head(resid(est))
#> [,1] [,2] [,3]
#> [1,] -0.6444588 0.10583516 0.08458424
#> [2,] -0.9561394 0.20359754 0.21000282
#> [3,] -1.1114672 -0.06831541 -0.04925142
#> [4,] -1.2338033 -0.20314694 -0.22599409
#> [5,] -0.7221227 -0.05371731 -0.08049948
#> [6,] -0.2551144 0.02604925 0.02280632
# We can select/order the model using fixest_multi extraction
head(resid(est[rhs = .N:1]))
#> [,1] [,2] [,3]
#> [1,] 0.08458424 0.10583516 -0.6444588
#> [2,] 0.21000282 0.20359754 -0.9561394
#> [3,] -0.04925142 -0.06831541 -1.1114672
#> [4,] -0.22599409 -0.20314694 -1.2338033
#> [5,] -0.08049948 -0.05371731 -0.7221227
#> [6,] 0.02280632 0.02604925 -0.2551144