psolymos / ResourceSelection

Resource Selection (Probability) Functions for Use-Availability Data in R
https://peter.solymos.org/ResourceSelection/
9 stars 4 forks source link

vcov.rsf should not drop non-existent intercept #3

Closed psolymos closed 7 years ago

psolymos commented 7 years ago
vcov.rsf <-
function (object, type, ...)
{
    boot <- object$bootstrap
    if (missing(type)) {
        type <- if (is.null(boot))
        "mle" else "boot"
    }
    type <- match.arg(type, c("mle", "boot"))
    if (type == "boot" && is.null(boot))
        stop("no bootstrap results found")
    np <- object$np
    if (type == "boot") {
        rval <- cov(t(boot))
    } else {
        rval <- matrix(NA, np, np)
#        h <- if (object$link == "log") {
#            data.matrix(object$results$hessian[-1,-1,drop=FALSE])
#        } else {
#            object$results$hessian
#        }
#        rval[1:np, 1:np] <- solve(h)
        rval[1:np, 1:np] <- solve(object$results$hessian)
    }
    rval <- data.matrix(rval)
    cf <- coef(object)
    colnames(rval) <- rownames(rval) <- names(cf)
    return(rval)
}