DistanceDevelopment / Distance

Simple distance sampling analysis
GNU General Public License v3.0
9 stars 8 forks source link

Two level stratification with `dht2` #46

Open erex opened 4 years ago

erex commented 4 years ago

Finally tried to test this with Savannah sparrow data sets. Results of dht2 doesn't seem to work as expected; warnings are issues plus density estimates aren't comparable to estimates produced with multiple, single-level stratification

library(Distance)
data("Savannah_sparrow_1980")
data("Savannah_sparrow_1981")
tom <- rbind(Savannah_sparrow_1980, Savannah_sparrow_1981)
tom$object <- NULL
convert <- convert_units("meter", NULL, "Hectare")
fred <-ds(data=tom, key="hn", adj="cos", transect="point", 
          formula=~Study.Area+Region.Label, convert.units = convert)  # year&pasture as detfn covariates
summary(fred)
plot(fred, pdf=TRUE)
tst <- dht2(fred, flatfile=tom, strat_formula = ~Region.Label+Study.Area, 
            stratification="geographical", convert_units = convert)
bob <- attr(tst, "density")
knitr::kable(bob[,c(2,1,8,10,12,11)], 
             caption="Density estimates using two-level stratification.", digits=3)
only80 <- ds(data=Savannah_sparrow_1980, key="hn", transect="point", convert.units = convert)
only81 <- ds(data=Savannah_sparrow_1981, key="hn", transect="point", convert.units = convert)
knitr::kable(only80$dht$individuals$D, caption="Density estimates 1980, separately estimated.",
             digits=3)
knitr::kable(only81$dht$individuals$D, caption="Density estimates 1981, separately estimated.",
             digits=3)
##  Result:  good agreement in density estimates for 1980, but 1981 strat estimates are 50% too large
erex commented 4 years ago

Message from user (Matt Nuttall) on 07Apr20

Is it possible to stratify by two levels – one level being geographic strata within a given year, and then again separating the different years? Would it be a case of having an extra column in “observations”, “transects” and “geo_strat” which had the extra stratification layer, and then having “formula = ~Region.Label + strata” in the dht2 call?

dill commented 4 years ago

The answer to this is "not at the moment." I will update to stop() when multi-variable stratification is specified for now.