Hi Michael,
huxtable requires that the tidy() method works on the model type you are trying to use, which converts the model output into a data frame. Unfortunately there's no existing tidy() method for unmarkedFit in the broom package, but I wrote one. See example below, I haven't tested on other model types besides occu.
library(unmarked)
library(huxtable)
library(broom)
# Load data
data(frogs)
pferUMF <- unmarkedFrameOccu(pfer.bin)
siteCovs(pferUMF) <- data.frame(sitevar1 = rnorm(numSites(pferUMF)))
obsCovs(pferUMF) <- data.frame(obsvar1 = rnorm(numSites(pferUMF) * obsNum(pferUMF)))
# Fit occupancy models
fm_null <- occu(~ 1 ~ 1, pferUMF)
fm_covs <- occu(~ obsvar1 ~ sitevar1, pferUMF)
# Write required tidy and glance methods
tidy.unmarkedEstimate <- function(x, ...){
submod <- paste0("[",x...@short.name,"]")
nul <- capture.output(out <- summary(x))
names(out) <- c("estimate", "std.error", "statistic", "p.value")
out <- cbind(term = paste(submod, rownames(out)), out)
rownames(out) <- NULL
tibble::as_tibble(out)
}
tidy.unmarkedFit <- function(x, submodel, ...){
if(missing(submodel)) submodel <- names(x)
stopifnot(all(submodel %in% names(x)))
out <- lapply(x@estimates@estimates[submodel], tidy)
do.call("rbind", out)
}
glance.unmarkedFit <- function(x, ...){
tibble::tibble(AIC=x@AIC, nobs=numSites(x@data))
}
# Try out new methods
tidy(fm_covs)
tidy(fm_covs, submodel='state') # only occupancy submodel
glance(fm_covs)
# Print some tables
# Note that only the AIC statistic works
huxreg(fm_null, fm_covs, statistics=c("AIC"))
# Add CI
huxreg(fm_null, fm_covs, ci_level=0.95, error_format="{conf.low} to {conf.high}",
statistics=c("AIC"))
# Include only occupancy submodel in output table
huxreg(fm_null, fm_covs, statistics=c("AIC"),
tidy_args=list(submodel="state"))