Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two level stratification with dht2 #46

Open
erex opened this issue Feb 27, 2020 · 2 comments
Open

Two level stratification with dht2 #46

erex opened this issue Feb 27, 2020 · 2 comments

Comments

@erex
Copy link
Member

erex commented Feb 27, 2020

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
Copy link
Member Author

erex commented Apr 7, 2020

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
Copy link
Contributor

dill commented Apr 21, 2020

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

dill pushed a commit that referenced this issue May 11, 2020
@dill dill added this to the 1.0.2 release milestone Jul 13, 2020
@dill dill modified the milestones: 1.0.3 release, 1.0.4 release Sep 7, 2020
@dill dill modified the milestones: 1.0.3 release, 1.0.4 release Jan 12, 2021
@dill dill removed this from the 1.0.4 release milestone Jan 12, 2021
@dill dill removed their assignment Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants