Greetings Libby.
You've discovered an interesting bug in dht2
. I've not worked with station-specific sampling fractions before.
It appears the code will perform the computations with station-specific sampling fractions, it simply won't let you see the estimates. Note that the error message comes not from calling
dht2
, but rather from the print
function displaying the results.
A work-around for this bug is to examine the object created by dht2
without printing. Here's an example using the
minke
data set included in the Distance
package.
library(Distance)
data(minke)
minke_df <- ds(minke, truncation=1.5, adjustment=NULL)
# now estimate abundance using dht2
# stratum labels are in the Region.Label column
minke_dht2 <- dht2(minke_df, flatfile=minke, stratification="geographical",
strat_formula=~Region.Label)
# can alternatively report density
# print(minke_dht2, report="density")
attr(minke_dht2,"density")$Density
attr(minke_dht2,"density")$Density_CV
attr(minke_dht2,"density")$LCI
attr(minke_dht2,"density")$UCI
It may not be a pretty of presenting the density estimates, but it is better than an error message. I'll log this bug in our issues tracker. Thanks for finding it.