Simulated example to compare dht results with dht2 for different ER variance estimators R2, O2 and S2
It is now as consistent as the others with only the total ER cv looking to have an issue
library(dsims)
outer1 <- matrix(c(0,0,1000,0,1000,500,0,500,0,0),ncol=2, byrow=TRUE)
outer2 <- matrix(c(0,500,1000,500,1000,1000,0,1000,0,500),ncol=2, byrow=TRUE)
outer3 <- matrix(c(0,1000,1000,1000,1000,1500,0,1500,0,1000),ncol=2, byrow=TRUE)
pol1 <- sf::st_polygon(list(outer1))
pol2 <- sf::st_polygon(list(outer2))
pol3 <- sf::st_polygon(list(outer3))
sfc <- sf::st_sfc(pol1,pol2,pol3)
strata.names <- c("South", "central", "North")
mp1 <- sf::st_sf(strata = strata.names, geom = sfc)
region <- make.region(region.name = "study.area",
strata.name = strata.names,
shape = mp1)
plot(region)
design <- make.design(region = region,
samplers = rep(10,3),
truncation = 10)
pop.desc <- make.population.description(region = region,
density = make.density(region= region),
N = c(10, 250, 250))
detect <- make.detectability(scale.param = 5,
truncation = 10)
sim <- make.simulation(reps = 10,
design = design,
population.description = pop.desc,
detectability = detect)
set.seed(666)
survey <- run.survey(sim)
plot(survey)
eg.data <- survey@dist.data
fitR2 <- ds(eg.data,
key = "hn",
nadj = 0,
er_var = "R2",
truncation = 10)
fitR2.dht <- fitR2$dht
fitO2 <- ds(eg.data,
key = "hn",
nadj = 0,
er_var = "O2",
truncation = 10)
fitO2.dht <- fitO2$dht
fitS2 <- ds(eg.data,
key = "hn",
nadj = 0,
er_var = "S2",
truncation = 10)
fitS2.dht <- fitS2$dht
# Now use dht2 to check the results
dht2.R2 <- dht2(fitR2.ddf,
flatfile = eg.data,
strat_formula = ~Region.Label,
er_est = "R2",
stratification = "geographical")
dht2.O2 <- dht2(fitR2.ddf,
flatfile = eg.data,
strat_formula = ~Region.Label,
er_est = "O2",
stratification = "geographical")
dht2.S2 <- dht2(fitR2.ddf,
flatfile = eg.data,
strat_formula = ~Region.Label,
er_est = "S2",
stratification = "geographical")
The summary tables in the output have different total encounter rate CV's for dht versus dht2. Note the variability surrounding the estimates is the same for dht and dht2. It is possible this is related to the inconsistent ways things are handled in the summary tables.
Originally posted by @LHMarshall in #174