Model design for post stratification in r

203 views
Skip to first unread message

Samantha Ball

unread,
Nov 17, 2020, 1:10:06 PM11/17/20
to distance-sampling
Hello, 

  Hoping to get some advice regarding model design in r, using the 'Distance' package. This is basic stuff, but I am finding it hard to find advise/ help/ working examples for the r package as opposed to the Distance software. I have one site, fairly small in size (approximately 222.5 ha) which I have been surveying once every few months. I am doing point surveys, from the same points each time and currently have 10 surveys spanning over 2 years. Due to ongoing construction work at the site, the number of times each point was visited was not consistent for all points and 'Effort' is set as the number of times each point was visited. I have 209 observations to clusters of animals (1-6 in size). 

The number of animals recorded at different times of the year has important management implications for the site and therefore I am interested in the population density for each survey, as well as an overall population estimate. This is where I am getting a little confused. As populations for this species fluctuate, the number recorded at each survey are different and I have therefore included the survey number (Survey_Number) as a covariate into my ds() model, as below: 

covar.model<- ds(point_cuts, transect = "point", key="hn",adjustment = NULL, 
                                formula=~as.factor(Survey_Number),
                                convert.units = unit_conversion_point) 

I then use this model in a dht2 model to stratify by the survey number (1-10) and to tell the model that they are replicates.  I have set stratification to 'effort_sum' due to the low number of replicates (10). I have set sample_fraction=0.5 as only 180 degrees of the point is visible (I am aware this is usually used for line transects). 

Model <- dht2(model.hn, flatfile=point_cuts, strat_formula = ~Survey_Number,
                                 stratification = "effort_sum",sample_fraction = 0.5, total_area = 222.5,
                                 ci_width = 0.95, convert_units = unit_conversion_point)

My question is whether I am reasonably on the right track and if this method is appropriate? This model (below) gives a reasonable estimate of the population size, but the output estimates the surveyed area area as being higher than available area for some surveys. Is this likely to be an error with effort? 



I would greatly appreciate any help or advise as I have been going around in circles for this for quite a long time!

Thanks, 
Sam

Eric Rexstad

unread,
Nov 18, 2020, 4:54:35 AM11/18/20
to distance-sampling

Sam

Thanks for the note; there's quite a lot to unpack.  My comments are in no particular order

  • inclusion of Survey_Number as a covariate in your detection function model won't necessarily account for fluctuations in abundance with time.  Rather, the use of a covariate implies that detectability of the target species changes with time.
  • the explanation for CoveredArea exceeding study area size is that the calculation of CoveredArea includes the repeat visits to points, not an error--merely the way CoveredArea is calculated.
  • from the summary it seems not only are the number of visits variable throughout the study (Effort), but the number of points visited (k) vary throughout the study; is that correct?
  • the most telling aspects of the output you provided is the variability in encounter rate for the different surveys.  The number of replicate point stations (not number of visits) is pretty small--falling as low as 4 or 5.  That implies that the variability in encounter rate between points cannot be estimated very well (note the size of the encounter rate CV for surveys 7 and 8 when number of stations is small: >100%).  This encounter rate variability propagates into the uncertainty in the survey-specific densities; they all have CVs of 0.3 or larger.  I'm not sure I would put much confidence in those survey-specific estimates.
  • there does seem to be something not quite right with the confidence interval calculations; several of which range from 0 to infinity.  As I said, those survey-specific estimates are imprecise, but perhaps not that imprecise.
    • would you please re-run your analysis using "replicate" as the value of the stratification argument in your call to `dht2`.  I'm curious to know whether the confidence interval values are better behaved when using that option.  We've not had much experience with the behaviour of the "effort-sum" computations.
Let me know what you find.
--
You received this message because you are subscribed to the Google Groups "distance-sampling" group.
To unsubscribe from this group and stop receiving emails from it, send an email to distance-sampl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/distance-sampling/2647a631-38d7-4b0f-b0af-59cb5cfb9808n%40googlegroups.com.
-- 
Eric Rexstad
Centre for Ecological and Environmental Modelling
University of St Andrews
St Andrews is a charity registered in Scotland SC013532

Samantha Ball

unread,
Nov 20, 2020, 11:24:25 AM11/20/20
to distance-sampling
Hi Eric, 

 Thanks very much for your reply. Apologies in my delay of getting back to you. I took on board what you said and have been examining the data again, unfortunately, to little avail. 

Thank you for the explanation regarding the surveyed sample area- I had seen in several examples that the calculated area exceeded the actual area and was not sure why this could be the case. 

Yes, you are correct in saying that the number of points and the number of visits to these points varied. Unfortunately, there were construction works going on in the area which meant that not all survey points were available at all times in the Northern half of the site. However, along the Southern half of the site, the points (n=9) remained untouched and were surveyed 10 times each. However, if I run the data just of the southern half of the site, ignoring the northern half where construction work was ongoing, I run into similar issues of very large (and incorrect) confidence intervals of 0- Inf. I imagine,  this is due to the same problem of just having too few replicate point stations. 

I ran the same model with 'replicate' set as the stratification argument, as suggested (output below). The same issues are still present, except that the SE and CV are now zero for the 'Total'. 






I think what you are saying from your reply above is that there are not enough detections to look at density on an individual survey level. Stratifying by season may be an option, but I unfortunately have uneven sampling for seasons down to surveys being taken monthly along with Covid (!) having put a 6 month pause on fieldwork. As you can see from the output below, the confidence intervals are better fitted but the CV and CV.ER are still too high. Is this something that is likely to  improve with further data collection? 






Best wishes, 
Sam

Eric Rexstad

unread,
Nov 20, 2020, 12:54:27 PM11/20/20
to Samantha Ball, distance-sampling

Sam

Thanks for doing the "replicate" experiment.  I'm still not happy with the CI estimates produced at the survey level.  Yes, they will be large, but not 0 to infinity.  I note that the degrees of freedom associated with each of those survey-specific estimates are weird (0.10, 0.008, ...) that can't be right.  Are you willing to send along the data (privately, not to the group) so we can further investigate?

Eric Rexstad

unread,
Dec 3, 2020, 9:21:59 AM12/3/20
to Samantha Ball, distance-sampling

Sam

I've spend some more time working with your data set.  The options "replicate" and "effort_sum" don't produce reasonable degrees of freedom for your survey-specific estimates, so for the moment, those options are not to be considered.

If your interest lies in examining density or abundance of your birds over time (and wish to ignore the average estimates across all surveys), then I suggest you use "geographical" as your stratification option (ignoring the Total across all surveys).  Furthermore, you note the small number of replicate points and the small number of detections made during some of the time periods, making inference for some of those surveys dubious.

I've analysed the data pooling some of the surveys to enhance the robustness of the estimates.  Not knowing your study objectives, it is dangerous for me to make decisions about combining surveys.  I combined the Feb19 and Apr19 surveys into a single "spring19" survey;  Jul19 and Sep19 combined into "summer19"; Nov19 and Jan20 into "winter19" and Jun20 through Oct20 into "summer20".  In addition to including those surveys as covariates in the detection function, I also included group size (as your detections were of bird groups). 

The model fits well and might provide robust estimates through time, if not at the temporal granularity you desire.

Code below.  Note the probability density function plots (showing the survey effect) will only work if you download the most recent version of Distance from CRAN.


library(Distance)
sam <- read.csv("C:/Users/erexs/Downloads/sampoints.csv")
sam$object <- NULL
unit_conversion_point <- convert_units("meter", NULL, "hectare")
season <- sam
season$month <- month(as.Date.character(sam$Survey_Date, format = "%d/%m/%Y"))
sp19 <- ifelse(season$month==2 | season$month==4, TRUE, FALSE)
sum19 <- ifelse(season$month==7 | season$month==9, TRUE, FALSE)
win19 <- ifelse(season$month==11 | season$month==1, TRUE, FALSE)
sum20 <- ifelse(season$month==6 | season$month==8 | season$month==10, TRUE, FALSE)
season$Region.Label[sp19] <- "sp19"
season$Region.Label[sum19] <- "sum19"
season$Region.Label[win19] <- "win19"
season$Region.Label[sum20] <- "sum20"
season.only <- ds(season, transect = "point", key="hn",adjustment = NULL,
           formula=~Region.Label, truncation=160,
           convert.units = unit_conversion_point)
season.size <- ds(season, transect = "point", key="hn",adjustment = NULL,
               formula=~Region.Label+size, truncation=160,
               convert.units = unit_conversion_point)
gof_ds(season.only, plot = FALSE)
gof_ds(season.size, plot = FALSE)
AIC(season.only, season.size)
plot(season.size, pdf=TRUE, showpoints=FALSE, main="Season and size as covariates")
add_df_covar_line(season.size, data=data.frame(Region.Label="sp19", size=1),
                  lwd=2, col="blue", pdf=TRUE)
add_df_covar_line(season.size, data=data.frame(Region.Label="sum19", size=1),
                  lwd=2, col="red", pdf=TRUE)
add_df_covar_line(season.size, data=data.frame(Region.Label="win19", size=1),
                  lwd=2, col="green", pdf=TRUE)
add_df_covar_line(season.size, data=data.frame(Region.Label="sum20", size=1),
                  lwd=2, col="darkgreen", pdf=TRUE)
legend("topright", title="Season", legend=c("win19","sp19","sum19","sum20"),
       col=c("green","blue","red","darkgreen"),
       lwd=2)
season.size.dht2 <- dht2(season.size, flatfile=season, strat_formula = ~Region.Label,
                    stratification = "geographical",sample_fraction = 0.5, total_area = 222.5,


                    ci_width = 0.95, convert_units = unit_conversion_point)

print(season.size.dht2, report="density")



On 20/11/2020 16:24, Samantha Ball wrote:
Reply all
Reply to author
Forward
0 new messages