I ran into an issue with the vcov method for zeroinfl objects. Here is a reproducible example (the 1st example for zeroinfl())
require(pscl)
## ... messages deleted ...
data("bioChemists", package = "pscl")
fm_zip <- zeroinfl(art ~ . | 1, data = bioChemists)
vcov(fm_zip, "zero")
## Error in `rownames<-`(`*tmp*`, value = names(cf)): attempt to set 'rownames' on an object with no dimensions
The problem is that we subset the entire covariance matrix; and if a 1x1 matrix is the result, then it drops to a simple numeric value rather than a matrix. So you need to add drop = FALSE in a couple of places. The code, with my annotations added, is
> pscl:::vcov.zeroinfl
function (object, model = c("full", "count", "zero"), ...)
{
model <- match.arg(model)
rval <- object$vcov
if (model == "full")
return(rval)
cf <- object$coefficients[[model]]
wi <- seq(along = object$coefficients$count)
rval <- if (model == "count")
rval[wi, wi] ### should be rval[wi, wi, drop = FALSE]
else rval[-wi, -wi] ### should be rval[-wi, -wi, drop = FALSE]
colnames(rval) <- rownames(rval) <- names(cf)
return(rval)
}
<bytecode: 0x000001e6efea00d8>
<environment: namespace:pscl>
I took a look at vcov.hurdle and it appears to have the same vulnerability.
I ran into an issue with the
vcov
method forzeroinfl
objects. Here is a reproducible example (the 1st example forzeroinfl()
)Created on 2023-01-13 with reprex v2.0.2
The problem is that we subset the entire covariance matrix; and if a 1x1 matrix is the result, then it drops to a simple numeric value rather than a matrix. So you need to add
drop = FALSE
in a couple of places. The code, with my annotations added, isI took a look at
vcov.hurdle
and it appears to have the same vulnerability.