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

Encounter rate variance of Buckland 2001 cannot be requested by ds #182

Open
erex opened this issue Jun 16, 2024 · 1 comment
Open

Encounter rate variance of Buckland 2001 cannot be requested by ds #182

erex opened this issue Jun 16, 2024 · 1 comment

Comments

@erex
Copy link
Member

erex commented Jun 16, 2024

er_method argument in ds is ignored by dht

Either observed counts (er_method=1) or expected counts (er_method=2) can be requested. Default is "2". When user request er_method=1 results are still using er_method=2

I believe the problem lies within dht, however, users calling ds from the Distance package will not get the results they expect if they specify er_method=1

MRE

library(Distance)
data(Savannah_sparrow_1981)
cu <- convert_units("meter", NULL, "hectare")
pooler1 <- ds(Savannah_sparrow_1981, transect="point", key="hn", adjustment = "cos",
           convert_units = cu, er_method = 1)  # encounter var uses observed counts
pooler1$dht$individuals$summary

pooler2 <- ds(Savannah_sparrow_1981, transect="point", key="hn", adjustment = "cos",
              convert_units = cu, er_method = 2)  # encounter var uses expected counts
pooler2$dht$individuals$summary

se.ER and cv.ER are identical regardless of value of er_method.

Debug trail

  • Inside ds
    • dht_option object varflag is set to value of `er_option
  • Inside dht
    • options$varflag is given default value of 2
    • dht.se is called with options as an argument
  • Inside dht.se
    • encounter rate variance computed depending upon value of options$varflag
@erex
Copy link
Member Author

erex commented Jun 17, 2024

Supplement to this issue

I checked whether the lack of difference in ER variance estimates was caused by either a) miscommunication between ds and dht and b) lack of covariate in the Savannah sparrow detection function model.

I turned my attention to the amakihi data set to introduce a covariate in the detection function and I ran the analysis in ddf rather than through ds. Result below: my interpretation is that I still can't induce differences in ER variance estimation using varflag:

data("amakihi")  # multiple years as strata
bust <- unflatten(amakihi)
detsize <- ddf(dsmodel=~mcds(key="hn", formula=~MAS),
               data=bust$data, method="ds", meta.data = list(point=TRUE, width=82.5))
summary(detsize)
meth1 <- dht(detsize, region.table = bust$region.table, sample.table = bust$sample.table,
             obs.table = bust$obs.table, options = list(varflag=1))
meth1$individuals$summary
meth2 <- dht(detsize, region.table = bust$region.table, sample.table = bust$sample.table,
             obs.table = bust$obs.table, options = list(varflag=2))
meth2$individuals$summary

Result

> meth1 <- dht(detsize, region.table = bust$region.table, sample.table = bust$sample.table,
+              obs.table = bust$obs.table, options = list(varflag=1))
> meth1$individuals$summary
  Region      Area CoveredArea Effort    n   k       ER     se.ER      cv.ER
1   1292  855298.6    855298.6     40  140  40 3.500000 0.3121472 0.08918492
2    194  876681.1    876681.1     41  172  41 4.195122 0.3088521 0.07362173
3    493  876681.1    876681.1     41  231  41 5.634146 0.3289972 0.05839344
4    494  513179.2    513179.2     24  141  24 5.875000 0.2712859 0.04617632
5    495  855298.6    855298.6     40  212  40 5.300000 0.4938078 0.09317129
6    792  876681.1    876681.1     41  146  41 3.560976 0.1945877 0.05464449
7    793  855298.6    855298.6     40  201  40 5.025000 0.2984737 0.05939775
8  Total 5709118.2   5709118.2    267 1243 267 4.655431 0.1262862 0.02712664
> meth2 <- dht(detsize, region.table = bust$region.table, sample.table = bust$sample.table,
+              obs.table = bust$obs.table, options = list(varflag=2))
> meth2$individuals$summary
  Region      Area CoveredArea Effort    n   k       ER     se.ER      cv.ER
1   1292  855298.6    855298.6     40  140  40 3.500000 0.3121472 0.08918492
2    194  876681.1    876681.1     41  172  41 4.195122 0.3088521 0.07362173
3    493  876681.1    876681.1     41  231  41 5.634146 0.3289972 0.05839344
4    494  513179.2    513179.2     24  141  24 5.875000 0.2712859 0.04617632
5    495  855298.6    855298.6     40  212  40 5.300000 0.4938078 0.09317129
6    792  876681.1    876681.1     41  146  41 3.560976 0.1945877 0.05464449
7    793  855298.6    855298.6     40  201  40 5.025000 0.2984737 0.05939775
8  Total 5709118.2   5709118.2    267 1243 267 4.655431 0.1262862 0.02712664

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant