problems with distance in R

21 views
Skip to first unread message

Ana Cañadas

unread,
Nov 12, 2021, 4:16:36 PM11/12/21
to distance-sampling
Hi,
I am trying to run some detection functions in R and I am finding some troubles:

1- dht is not giving summary for clusters, only individuals. I don´t understand why (in my previous models I go both):
image.png

2-For some reason it is not getting the right number of segments (k) and total effort (Effort), but much smaller, therefore creating a huge estimate. For more than I check, I can´t find why. Everything is in km:
> region.table$Area
[1] 129153
> sum(sample.table$Effort) *km on effort
[1] 18226.86
> nrow(sample.table) *number of segments
[1] 3717
> nrow(obs.table)
[1] 165
> range(obs.table$distance)
[1] 0.000000 2.178789
> trunc  *right truncation
[1] 0.734
> nrow(obs.table[obs.table$distance<=trunc,])  *number of observations after truncation
[1] 157

Compare this with the summary in dht:
image.png


Here n is correct (157) and so is Area (129153), but k is 135 when it should be 3717, and Effort is 677 when it should be 18227. There is no stratification in the study area or anything that could lead to confusion.

I´ve been investigating this for hours without reaching any conclusion or advancing at all. So at this stage, any help would be very welcome.  Hopefully it is just something stupid I am doing and which I cannot see now...and that some extra eyes may find!

Many thanks in advance
Ana

Eric Rexstad

unread,
Nov 13, 2021, 3:36:43 AM11/13/21
to Ana Cañadas, distance-sampling
Only a guess Ana.  I think the software identifies "k" by the number of unique values in the Sample.Label​ field.  You mention segments​ in one of your comments, are your transects broken into segments?  Are you treating segments as transects?  Have you correctly assigned unique Sample.Labels to what you are treating as segments?


From: distance...@googlegroups.com <distance...@googlegroups.com> on behalf of Ana Cañadas <anacan...@gmail.com>
Sent: 12 November 2021 21:16
To: distance-sampling <distance...@googlegroups.com>
Subject: {Suspected Spam} [distance-sampling] problems with distance in R
 
--
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/CAKfiqX1%3Dxaj-8c7-d1Xr%2BaiVE6ELDKqeQSrnHtV3kakA9P1kYA%40mail.gmail.com.

Ana Cañadas

unread,
Nov 13, 2021, 9:42:52 AM11/13/21
to Eric Rexstad, distance-sampling
Hi Eric,
yes, Sample.Label are unique identifiers for segments, which I am using as sampling unit. As you can see, there are 3717 segments (unique Sample.Label):

> length(unique(sample.table$Sample.Label))
[1] 3717

Actually I see that it is taking the number of unique segments from the obs.table:

> length(unique(obs.table$Sample.Label))
[1] 135

But even the Effort does not coincide with the total Effort from the obs.table (if it was taking it from that table too), which is the total length of the segments which have observations in it:
> sum(obs.table$Effort)
[1] 828.1076

But as I understand it, the k and the Effort should come from the sample.table, not the obs.table, to be able to get an abundance estimate.

If I look into dht directly, the numbers seem correct:

> dht(model$ddf, region.table, sample.table, obs.table)

Summary statistics:
    Region   Area CoveredArea   Effort   n    k          ER       se.ER      cv.ER
1 Adriatic 129153    26757.03 18226.86 157 3717 0.008613662 0.000810503 0.09409506

Abundance:
  Label Estimate       se        cv     lcl      ucl       df
1 Total 1587.917 187.7321 0.1182254 1260.16 2000.923 1031.718

Density:
  Label   Estimate          se        cv         lcl        ucl       df
1 Total 0.01229486 0.001453564 0.1182254 0.009757106 0.01549265 1031.718

But when I look at the result summary, it is not because somehow it is using the wrong Effort:

> model$dht$individuals$N
  Label Estimate       se         cv      lcl      ucl       df
1 Total 42728.13 3548.471 0.08304764 36291.01 50307.03 248.0888

Plus, it only gives dht$individuals, the clusters and the expected cluster size are not there (they were there before in previous projects using the same code).

TThanks
Ana


Len Thomas

unread,
Nov 13, 2021, 6:04:19 PM11/13/21
to distance-sampling, Ana Cañadas, Eric Rexstad
Hi All,

Having corresponded offline with Ana, we've concluded the issues were
due to irregularities in the inputs (for example, a missing "size"
column in the data frame containing the observation distances). Anyway,
it's all resolved now. If anyone is experiencing similar issues, please
feel free to post to the list, or contact Eric or me directly.

Cheers, Len Thomas
> (<Eric.R...@st-andrews.ac.uk <mailto:Eric.R...@st-andrews.ac.uk>>)
> escribió:
>
> Only a guess Ana.  I think the software identifies "k" by the number
> of unique values in the|Sample.Label|​ field.  You mention
> |segments|​ in one of your comments, are your transects broken into
> segments?  Are you treating segments as transects?  Have you
> correctly assigned unique Sample.Labels to what you are treating as
> segments?
>
> ------------------------------------------------------------------------
> *From:* distance...@googlegroups.com
> <mailto:distance...@googlegroups.com>
> <distance...@googlegroups.com
> <mailto:distance...@googlegroups.com>> on behalf of Ana
> Cañadas <anacan...@gmail.com <mailto:anacan...@gmail.com>>
> *Sent:* 12 November 2021 21:16
> *To:* distance-sampling <distance...@googlegroups.com
> <mailto:distance...@googlegroups.com>>
> *Subject:* {Suspected Spam} [distance-sampling] problems with
> distance in R
> Hi,
> I am trying to run some detection functions in R and I am finding
> some troubles:
>
> 1- dht is not giving summary for clusters, only individuals. I don´t
> understand why (in my previous models I go both):
> image.png
>
> 2-For some reason it is not getting the right number of segments (k)
> and total effort (Effort), but much smaller, therefore creating a
> huge estimate. For more than I check, I can´t find why. Everything
> is in km:
> > region.table$Area
> [1] 129153
> > sum(sample.table$Effort) *km on effort
> [1] 18226.86
> > nrow(sample.table) *number of segments
> [1] 3717
> > nrow(obs.table)
> [1] 165
> > range(obs.table$distance)
> [1] 0.000000 2.178789
> > trunc  *right truncation
> [1] 0.734
> > nrow(obs.table[obs.table$distance<=trunc,])  *number of
> observations after truncation
> [1] 157
>
> Compare this with the summary in dht:
> image.png
>
>
> Here n is correct (157) and so is Area (129153), but k is 135 when
> it should be 3717, and Effort is 677 when it should be 18227. There
> is no stratification in the study area or anything that could lead
> to confusion.
>
> I´ve been investigating this for hours without reaching any
> conclusion or advancing at all. So at this stage, any help would be
> very welcome.  Hopefully it is just something stupid I am doing and
> which I cannot see now...and that some extra eyes may find!
>
> Many thanks in advance
> Ana
>
> --
> 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>.
> <https://groups.google.com/d/msgid/distance-sampling/CAKfiqX1%3Dxaj-8c7-d1Xr%2BaiVE6ELDKqeQSrnHtV3kakA9P1kYA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> 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/CAKfiqX0w_6HaGK0h1V-f-%2BVXpLVJ2-R8K0CrMZZtiKeF9yaLBg%40mail.gmail.com
> <https://groups.google.com/d/msgid/distance-sampling/CAKfiqX0w_6HaGK0h1V-f-%2BVXpLVJ2-R8K0CrMZZtiKeF9yaLBg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

--
Len Thomas (he/him) len.t...@st-andrews.ac.uk lenthomas.org @len_thom
Centre for Research into Ecological and Environmental Modelling
and School of Mathematics and Statistics
The Observatory, University of St Andrews, Scotland KY16 9LZ
Office: UK+1334-461801 Admin: UK+1334-461842

While I may be sending this email outside of my normal office hours,
I have no expectation to receive a reply outside of yours.

The University of St Andrews is a charity
registered in Scotland, No SC013532.
Reply all
Reply to author
Forward
0 new messages