# plotting multiple covariates from a detection function model

22 views

### Jonathan Felis

Aug 31, 2023, 1:10:27 PMAug 31
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)

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

Aug 31, 2023, 2:44:05 PMAug 31
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.

Sent: 31 August 2023 18:10
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.