plotting multiple covariates from a detection function model

52 views
Skip to first unread message

Jonathan Felis

unread,
Aug 31, 2023, 1:10:27 PM8/31/23
to distance-sampling
Hello,

I have a fitted detection function model for a bird from line transect data with two covariates: Year (a factor with 20 levels) and Behavior (a factor with two levels: Rest or Fly). For simplicity, I'd like to plot the model to show the overall detection function, as well as the mean/median of each Behavior for all Years. I see some information alluding to this in the description of add_df_covar_line(), but I'm not sure how to execute it. I'm able to plot the two Behaviors for any specific Year:

my.ddf <- ds(my.data, key="hr", formula = ~as.factor(Year)+as.factor(Behavior)....)
plot_year<-2021 #example year
plot(my.ddf, showpoints=FALSE)
add_df_covar_line(my.ddf, data.frame(Year=plot_year, Behavior="Rest"), lty=1,col="blue")
add_df_covar_line(my.ddf, data.frame(Year=plot_year, Behavior="Fly"), lty=1,col="red")

But how might I plot the median/mean value for each Behavior for all Years? Similarly, I'd be interested in generating an average probability of detection for each Behavior for all Years, for reporting. 

Thanks for any help!

-Jon

Eric Rexstad

unread,
Aug 31, 2023, 2:44:05 PM8/31/23
to Jonathan Felis, distance-sampling
Jon

I'm slightly surprised you were able to fit a model with >20 parameters to begin with.  I'd check the summary(my.ddf) to look for possible convergence problems (i.e. goofy standard errors on the beta parameters).

But back to your questions. I'm not certain this is what you want for your first question ("how might I plot the median/mean value for each Behavior for all Years?"), but what if you were to fit a model without the year effect, but with the behaviour effect, then plot the result of that fitted model?

Your second question ("generating an average probability of detection for each Behavior for all Years") would you also use the fitted model I described in the previous paragraph. You might need to do some calculation by hand, but P-hat = w x integral(detection function).

where w is truncation distance. You can evaluate the detection function for each of the two values of the behaviour covariate, then get R to calculate the integral of that detection function; giving you the two pieces (w, integral()) you need to compute your behaviour-specific detection function across years.

If that sounds like what you want and are nervous about doing the integration, we could discuss off-list.


From: distance...@googlegroups.com <distance...@googlegroups.com> on behalf of Jonathan Felis <jonatha...@gmail.com>
Sent: 31 August 2023 18:10
To: distance-sampling <distance...@googlegroups.com>
Subject: [distance-sampling] plotting multiple covariates from a detection function model
 
--
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/05af9031-7d36-4752-8cf3-9008885a8119n%40googlegroups.com.


From: distance...@googlegroups.com <distance...@googlegroups.com> on behalf of Jonathan Felis <jonatha...@gmail.com>
Sent: 31 August 2023 18:10
To: distance-sampling <distance...@googlegroups.com>
Subject: [distance-sampling] plotting multiple covariates from a detection function model
 
--
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/05af9031-7d36-4752-8cf3-9008885a8119n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages