estfun.singleRStaticCountData {singleRcapture} | R Documentation |
Heteroscedasticity-Consistent Covariance Matrix Estimation for singleRStaticCountData class
Description
S3 method for vcovHC
to handle singleRStaticCountData
class objects.
Works exactly like vcovHC.default
the only difference being that this method handles vector generalised linear models.
Updating the covariance matrix in variance/standard error estimation for population size estimator can be done via redoPopEstimation()
Usage
## S3 method for class 'singleRStaticCountData'
estfun(x, ...)
## S3 method for class 'singleRStaticCountData'
bread(x, ...)
## S3 method for class 'singleRStaticCountData'
vcovHC(
x,
type = c("HC3", "const", "HC", "HC0", "HC1", "HC2", "HC4", "HC4m", "HC5"),
omega = NULL,
sandwich = TRUE,
...
)
Arguments
x |
a fitted |
... |
for
|
type |
a character string specifying the estimation type, same as in |
omega |
a vector or a function depending on the arguments residuals (i.e. the derivative of log-likelihood with respect to each linear predictor), diaghat (the diagonal of the corresponding hat matrix) and df (the residual degrees of freedom), same as in |
sandwich |
logical. Should the sandwich estimator be computed? If set to FALSE only the meat matrix is returned. Same as in |
Value
Variance-covariance matrix estimation corrected for heteroscedasticity of regression errors.
Author(s)
Piotr Chlebicki, Maciej Beręsewicz
See Also
sandwich::vcovHC()
redoPopEstimation()
Examples
set.seed(1)
N <- 10000
gender <- rbinom(N, 1, 0.2)
eta <- -1 + 0.5*gender
counts <- rpois(N, lambda = exp(eta))
df <- data.frame(gender, eta, counts)
df2 <- subset(df, counts > 0)
mod1 <- estimatePopsize(
formula = counts ~ 1 + gender,
data = df2,
model = "ztpoisson",
method = "optim",
popVar = "analytic"
)
require(sandwich)
HC <- sandwich::vcovHC(mod1, type = "HC4")
Fisher <- vcov(mod1, "Fisher") # variance covariance matrix obtained from
#Fisher (expected) information matrix
HC
Fisher
# usual results
summary(mod1)
# updated results
summary(mod1, cov = HC,
popSizeEst = redoPopEstimation(mod1, cov = HC))
# estimating equations
mod1_sims <- sandwich::estfun(mod1)
head(mod1_sims)
# bread method
all(vcov(mod1, "Fisher") * nrow(df2) == sandwich::bread(mod1, type = "Fisher"))