Claire
I'm not sure it has been asked before, and it is a bit tricky to answer.
Your first stop will be the documentation for predict.ds()
, with special attention paid to this passage:
The predicted detection probability is the average probability which is simply the integral
divided by the distance range. Fitted detection probabilities are stored in the model object and these are returned unless compute=TRUE or newdata is specified. compute=TRUE is used to estimate numerical derivatives for use in delta method approximations to
the variance. Note that the ordering of the returned results when no new data is supplied (the "fitted" values) will not necessarily be the same as the data supplied to ddf, the data (and hence results from predict) will be sorted by object ID (object).
This tells us that these predicted average probabilities are stored in the object created
by ds
. However, the last sentence states that care needs to be taken to properly match the predicted probabilities with the detection after accounting for truncation, etc.. I demonstrate with a bit of code applied to the
amakihi
data set provided with the Distance
package.
library(Distance)
data(amakihi)
test <- ds(data=amakihi, key="hr", formula = ~OBs+MAS, truncation = 82.5)
within.trunc <- amakihi[amakihi$distance<82.5 & !is.na(amakihi$distance), ]
within.sort <- within.trunc[order(within.trunc$object), ]
m <- within.sort$MAS
o <- within.sort$OBs
plot(m, test$ddf$fitted)
plot(o, test$ddf$fitted)