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

Variance components table branch #76

Open
erex opened this issue Feb 1, 2023 · 1 comment
Open

Variance components table branch #76

erex opened this issue Feb 1, 2023 · 1 comment
Assignees
Milestone

Comments

@erex
Copy link
Member

erex commented Feb 1, 2023

Trying to assess variance components table added to dht in this branch.

  • Used Savannah_sparrow_1980 as test case.
  • Tried to compare results with Distance for Windows
  • data sets in R and Distance for Windows don't match
  • exported DistWin data and took into R
  • used region.table, sample.table, obs.table because multispecies data frame was going to be subset
  • created new problem that prevented comparing DistWin with dht components table
  • Problem was this
    • Savannah_sparrow has multiple strata
    • transect numbers start with 1 within each stratum
    • all laid out in sample.table
    • however, all detections are assigned to the first stratum (none to strata 2 and 3)
  • compares transect numbering in other R data sets
    • minke numbers transects across strata (does not begin numbering again at 1)
    • amakihi does number transects starting at 1 for each stratum (temporal replicate survey as stratum)

Note the data issue has been resolved, see next comment

songbirds.csv

birds <- read.csv("E:/Troubleshoot/Arapaho/songbirds.csv", header=TRUE)
birds80 <- birds[birds$Year==1980, ]
table(birds$species, birds$Region.Label)
regtab <- data.frame(Region.Label=unique(birds80$Region.Label),
                     Area=rep(1,3))
p1.stns <- c(seq(1:110), seq(112, 122, by=2), seq(150, 156, by=2))
p2.stns <- seq(1:125)
p3.stns <- c(seq(1:4), seq(6, 25, by=1), seq(27, 125, by=1))
samtab <- data.frame(Sample.Label=c(p1.stns, p2.stns, p3.stns) ,
                     Region.Label=c(rep("1980_1", length(p1.stns)),
                                    rep("1980_2", length(p2.stns)),
                                    rep("1980_3", length(p3.stns))) ,
                     Effort=1)
obstab <- data.frame(object=birds80$Observation,
                     Region.Label=birds80$Region.Label,
                     Sample.Label=birds80$Sample.Label)
cu <- convert_units("meter", NULL, "hectare")
sasp <- birds80[birds80$species=='SASP', ]
# obstab <- data.frame(object=sasp$Observation,
#                      Region.Label=sasp$Region.Label,
#                      Sample.Label=sasp$Sample.Label)

hncos <- ds(sasp, key="hn", transect="point",
            convert_units = cu,
            region_table = regtab, sample_table = samtab,
            obs_table = obstab)
@erex
Copy link
Member Author

erex commented Feb 9, 2023

Checking variance component table computation using Savannah Sparrow 1980 data.

Results from DistWin

Stratum 1
Component Percentages of Var(D)
Detection probability : 15.9
Encounter rate : 81.0
Cluster size : 3.1

Stratum 2
Component Percentages of Var(D)
Detection probability : 28.1
Encounter rate : 66.1
Cluster size : 5.8

Stratum 3
Component Percentages of Var(D)
Detection probability : 30.4
Encounter rate : 61.8
Cluster size : 7.8

Results from Distance package

mrds * 2.2.8.9003 2023-02-01 [1] Github (906a1ff)

Variance contributions
Region ER Detection
1 1980_1 80.74720 19.25280
2 1980_2 66.81556 33.18444
3 1980_3 66.02137 33.97863
4 Total 44.97079 55.02921

Conclusion

Variance component table produced by mrds seems unaware of group size in this data set. The contribution attributable to encounter rate variability is roughly correct (except stratum 3) and both detection function uncertainty and group size variability is combined into component called "Detection".

Minimum Reproducible Example

Songbird csv file linked to previous comment, with this simplified analysis code

library(Distance)
birds <- read.csv("E:/Troubleshoot/Arapaho/songbirds.csv", header=TRUE)
birds80 <- birds[birds$Year==1980, ]
table(birds$species, birds$Region.Label)
regtab <- data.frame(Region.Label=unique(birds80$Region.Label),
                     Area=rep(1,3))
p1.stns <- c(seq(1:110), seq(112, 122, by=2), seq(150, 156, by=2))
p2.stns <- seq(1:125)
p3.stns <- c(seq(1:4), seq(6, 25, by=1), seq(27, 125, by=1))
samtab <- data.frame(Sample.Label= c(p1.stns, p2.stns, p3.stns),
                     Region.Label=c(rep("1980_1", length(p1.stns)),
                                    rep("1980_2", length(p2.stns)),
                                    rep("1980_3", length(p3.stns))) ,
                     Effort=1)
cu <- convert_units("meter", NULL, "hectare")
sasp <- birds80[birds80$species=='SASP', ]
hncos3 <- ds(sasp, key="hn", transect="point",
            convert_units = cu, 
            region_table = regtab, sample_table = samtab) 
print(hncos3$dht) # only with print statement is component table produced

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

3 participants