Mcds distance sampling output and density estimates

336 views
Skip to first unread message

Nathalie Cavada

unread,
Nov 13, 2014, 10:24:17 AM11/13/14
to distance...@googlegroups.com
Hello,

I was able to fit a mcds model to my data using the available R package as follows

primates.cov2<-ddf(method="ds", dsmodel=~mcds(key="hn", formula=~as.factor(forest)+species+size+mba.scaled+climber_perc+altitude.scaled),
                   data=primates.covariate.fixed$data, meta.data=list(width=90))

Unfortunately most of the time the system will report a strange error, I still wasn't able to fix:

Error in ans.ret[meth, ] <- c(ans$par, ans$value, ans$fevals, ans$gevals,  : 
  number of items to replace is not a multiple of replacement length
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Error: $ operator is invalid for atomic vectors

The times the system worked, I was able to compare different models, choosing the one above, having the lowest AIC value

1.I'd be interested now in obtaining different density estimates for each species (which is included in the model as a covariate); how can I obtain those values?

Moreover when looking at the summary of the model I obtain the following output:

Summary for ds object

Number of observations :  313

Distance range         :  0  -  90

AIC                    :  2762.049

 

Detection function:

Half-normal key function

 

Detection function parameters

Scale Coefficients: 

                                                             estimate                                       se

(Intercept)                                         3.40248903                             0.45173188

as.factor(forest)Matundu              -0.48035026                            0.30569745

as.factor(forest)Mwanihana          -1.00862940                            0.34839431

as.factor(forest)UdzungwaScarp -0.98872684                             0.41770805

speciesRC                                        0.05048206                              0.30059879

speciesSY                                        0.29578219                               0.19145516

size                                                    0.01078181                               0.01927509

mba.scaled                                       0.22388617                               0.11117238

climber_perc                                    0.23988412                               0.52148662

altitude.scaled                                 0.43906444                               0.16526580

 

                      Estimate          SE         CV

Average p             0.633623  0.03419148 0.05396187

N in covered region 493.984564 32.12559120 0.06503359



2.How should I interpret the effect of each scale coefficient? Is there a way to plot a different detection function, showing each covariate effect?

3.Is there a way to predict the density of the animals, for example within a plot where I recorded the exact value of each covariate?

Thank you very much for your help

Nathalie

David Lawrence Miller

unread,
Nov 13, 2014, 9:34:45 PM11/13/14
to Nathalie Cavada, distance...@googlegroups.com
Hi Nathalie and other listfolk,

Regarding the model failing to fit, this may be down to the sheer number
of covariates in the model. If you would like to send a minimal
code/data example to me I can investigate further. It may be worth
investigating goodness of fit tests/qq plots for these models (see ?ddf.gof)

1. How to perform a stratified analysis.

First, it's probably easier to write your model in Distance rather than
mrds (they end up as the same thing anyway, just Distance is a little
easier to read (though I am biased)). You can write your model as:

primates.cov2 <- ds(primates.covariate.fixed$data, key="hn",
formula=~as.factor(forest) + species+size +
mba.scaled + climber_perc + altitude.scaled,
truncation=90)

You can then write you data in the flatfile format (see ?flatfile) and
perform a "stratified analysis" as in
http://distancesampling.org/R/vignettes/minke.html but here your
"Region.Label"s will be the species. Then when you call
summary(primates.cov2) you'll get the density/abundance estimates per
strata (ie per species).

This may or may not be biologically reasonable. (Others may want to
chime in on this...)


2. Interpretation of covariate effects.

This paper may be of use:
http://www.creem.st-and.ac.uk/len/papers/MarquesAuk2007.pdf pages 1234-1236.

Plots illustrated in the paper of covariate levels are not implemented
in mrds/Distance at the moment, though they are on my todo list.


3. Prediction outside of the sample from covariate values.

This is possible via the flatfile format by including rows where
distance is NA. However, if you think that environmental covariates (as
opposed to those that affect detectability) affect distribution, you may
want to consider density surface models (e.g.
http://onlinelibrary.wiley.com/doi/10.1111/2041-210X.12105/abstract),
though this approach requires a relatively large amount of spatially
explicit data.


I hope this helps!

best,
--dave



On 13/11/2014 10:24, Nathalie Cavada wrote:
> Hello,
>
> I was able to fit a mcds model to my data using the available R package
> as follows
>
> primates.cov2<-ddf(method="ds", dsmodel=~mcds(key="hn",
> formula=~as.factor(forest)+species+size+mba.scaled+climber_perc+altitude.scaled),
> data=primates.covariate.fixed$data,
> meta.data=list(width=90))
>
> Unfortunately most of the time the system will report a strange error, I
> still wasn't able to fix:
>
> Error in ans.ret[meth, ] <- c(ans$par, ans$value, ans$fevals,
> ans$gevals, :
> number of items to replace is not a multiple of replacement length
> In addition: There were 50 or more warnings (use warnings() to see the
> first 50)
> Error: $ operator is invalid for atomic vectors
>
> The times the system worked, I was able to compare different models,
> choosing the one above, having the lowest AIC value
>
> 1.I'd be interested now in obtaining different density estimates for
> each species (which is included in the model as a covariate); how can I
> obtain those values?
>
> Moreover when looking at the summary of the model I obtain the following
> output:
>
> Summary for ds object____
>
> Number of observations : 313____
>
> Distance range : 0 - 90____
>
> AIC : 2762.049____
>
> __ __
>
> Detection function:____
>
> Half-normal key function____
>
> __ __
>
> Detection function parameters____
>
> Scale Coefficients: ____
>
> estimate
> se____
>
> (Intercept) 3.40248903
> 0.45173188____
>
> as.factor(forest)Matundu -0.48035026
> 0.30569745____
>
> as.factor(forest)Mwanihana -1.00862940
> 0.34839431____
>
> as.factor(forest)UdzungwaScarp -0.98872684
> 0.41770805____
>
> speciesRC 0.05048206
> 0.30059879____
>
> speciesSY 0.29578219
> 0.19145516____
>
> size 0.01078181
> 0.01927509____
>
> mba.scaled 0.22388617
> 0.11117238____
>
> climber_perc 0.23988412
> 0.52148662____
>
> altitude.scaled 0.43906444
> 0.16526580____
>
> __ __
>
> Estimate SE CV____
>
> Average p 0.633623 0.03419148 0.05396187____
>
> N in covered region 493.984564 32.12559120 0.06503359
>
>
>
> 2.How should I interpret the effect of each scale coefficient? Is there
> a way to plot a different detection function, showing each covariate effect?
>
> 3.Is there a way to predict the density of the animals, for example
> within a plot where I recorded the exact value of each covariate?
>
> Thank you very much for your help
>
> Nathalie
>
> --
> 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 post to this group, send email to distance...@googlegroups.com
> <mailto:distance...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/distance-sampling/ca47dc7d-be73-4ebe-93b9-8b0ac0c9ecf6%40googlegroups.com
> <https://groups.google.com/d/msgid/distance-sampling/ca47dc7d-be73-4ebe-93b9-8b0ac0c9ecf6%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

David Lawrence Miller

unread,
Dec 1, 2014, 7:34:36 PM12/1/14
to Nathalie Cavada, distance...@googlegroups.com
Hi listfolk,

After an offlist discussion with Nathalie, I realised I misunderstood
her question and that the answer I gave below is not correct. If one
wants to obtain abundance estimates per *species* then one can use dht()
from mrds. You can use the "subset=" option to dht to select a subset of
the data to calculate the abundance estimates/densities.

[NB To do the subsetting need the Region.Label and Sample.Label columns
in the data, future versions of Distance for R will automatically do this.]

Having fitted your model (called my_model, say) one can now calculate
abundance estimates for a given species ("BW", say):

dht(my_model, my_region.table, my_sample.table, subset=species=="BW")

where the species column must exist in the data used to fit the model.

Hope this helps.


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