Using dsm.var.prop

69 views
Skip to first unread message

Jez Bird

unread,
Jul 12, 2020, 10:16:28 PM7/12/20
to distance-sampling
Hi Listerve team,

I'm testng DSMs that include a detection function with observer as a covariate. I can't see any reason why a spatial interaction might exist with observer-specific detection so I think dsm.var.gam (delta method) should be fine for estimating variance. But, I'm interested to try variance propogation to investigate this.

I'm confused as to why running dsm.var.prop returns the error "Variance propagation can only be used with count as the response." when the guidance for dsm says "Nhat, abundance.est ... This should be used when there are covariates in the detection function."

Should I be using count as the response even with observer as a covariate in the detection function?

Any advice gratefully received. Many thanks for all the hard work that goes into supporting this list.

Jez

Jez Bird

unread,
Jul 13, 2020, 12:43:37 AM7/13/20
to distance-sampling
As follow-up to this, I've run the DSM with count as response and dsm.var.prop is now returning an error:

Error in (1 - h) * qs[i] : non-numeric argument to binary operator

Do you know what might be causing that? Here is the code for my model:

dsm_whp_tw5 <- dsm(count~s(x,y, k=100) +
                    s (dem, k=10) +
                    s (ndvi, k=10) +
                    s (slope, k=10),
               ddf.obj=whp_detfc, segment.data=seg_whp, 
               observation.data=whp, family=tw(), 
               segment.area=seg_whp$area, keepData=TRUE, method="REML")

and the detection function is:
whp_detfc <- ds(whp, truncation=whpt10, key="hn", formula=~surveyor)

Also, this model gives a higher adj R-sq, lower REML and AIC than the same model with Nhat as response. Is there any issue with using count as response given "surveyor" is included in the detection function?

Many thanks,
Jez

David Lawrence Miller

unread,
Jul 13, 2020, 3:50:45 AM7/13/20
to Jez Bird, distance-sampling
Hi Jez, hi listfolk,

You might find this slide (and the following 4 or so) useful in this
situation:

http://workshops.distancesampling.org/online-dsm-2020/slides/dsm1-refresher-what_is_a_dsm.html#40

The basic rule is:

count can only be used when covariates only vary between segments/points
(not within). dsm.var.prop can only be used with count.

abundance.est/density.est can be used in any situation but must assume
independence and therefore use the delta method, as implemented in
dsm.var.gam.

I'll try to clear up the documentation to be more consistent between
pages for our next release.

best,
--dave
> --
> 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
> <mailto:distance-sampl...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/distance-sampling/dbca8324-936b-4053-96e9-a6dcf9366627o%40googlegroups.com
> <https://groups.google.com/d/msgid/distance-sampling/dbca8324-936b-4053-96e9-a6dcf9366627o%40googlegroups.com?utm_medium=email&utm_source=footer>.

David Lawrence Miller

unread,
Jul 13, 2020, 3:58:19 AM7/13/20
to Jez Bird, distance-sampling
Hi Jez, hi listfolk,

Not clear to me what's happening here unless surveyor varies within the
segments. Feel free to send me an RData file with dsm_whp_tw5, your
prediction grid and the code you are calling dsm.var.prop with and I
will take a look.

cheers,
--dave
> --
> 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
> <mailto:distance-sampl...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/distance-sampling/843caf45-1008-4060-bf76-7018bf6eaf5co%40googlegroups.com
> <https://groups.google.com/d/msgid/distance-sampling/843caf45-1008-4060-bf76-7018bf6eaf5co%40googlegroups.com?utm_medium=email&utm_source=footer>.

Jez Bird

unread,
Jul 14, 2020, 12:37:03 AM7/14/20
to David Lawrence Miller, distance-sampling
Hi Dave,

Many thanks for this - that clarifies things. I'll send through my var.prop example off list.

Much appreciated,
Jez

David Lawrence Miller

unread,
Jul 16, 2020, 5:08:08 AM7/16/20
to Jez Bird, distance-sampling
Hi listfolks,

Just to follow-up on this. Jez and I corresponded off-list to see what
was going on. It looks like the issue was that the covariate in the
detection function was a character variable, which was coerced into a
factor for fitting the detection function. Unfortunately it seems that
Distance/mrds doesn't currently save this conversion so when the
dsm.var.prop summary() function comes to look at the covariates it
doesn't know what to do with the factor.

Jez was able to solve this by refitting the detection function having
converted the character variable to factor (i.e., data$var <-
as.factor(data$var)) then refitting the dsm with this corrected
detection function.

I'll make some changes to mrds to get around this problem in future but
thought it was worth posting the work-around in case anyone else has
this issue.

cheers,
--dave
Reply all
Reply to author
Forward
0 new messages