Using ds function in R Distance package

385 views
Skip to first unread message

Gemma Veneruso

unread,
May 4, 2016, 7:04:11 AM5/4/16
to distance...@googlegroups.com

Hi Listers,

 

I am trying to calculate abundance estimates of harbour porpoises from line-transect survey data (CDS). I have only VERY BASIC R knowledge and have got stuck along the way! I am using the ‘Distance’ package. Using the ds function I successfully produced estimates using a flatfile at first. However, I have a number of samples where no detections were recorded. Since each row in the flatfile represents a detection I figure I cannot include effort and samples where there were no detections in this table. So I presume I need to use the separate tables region.table, sample.table and obs.table. I have created these in what I think is the correct format but have two queries:

1)      How do I input these into the function? I have tried to read the csv files of each table and then:

 

Abund<-ds(data, truncation=400, key="hr", order=0, region.table = region.table, sample.table = sample.table, obs.table = obs.table). I tried this to try to tell R that these tables are not NULL, I suspect this is not correct. Can you tell me how I should tell the function to use these tables? ‘Data’ refers to a table with object and distance columns. I would also like to include cluster size and eventually sea state to run MCDS (Can I include these in this table?)

 

I get the following error: Error in checkdata(data, region.table, sample.table, obs.table, formula) : 

  obs.table must have columns names 'Region.Label', 'Sample.Label' and 'object'

 

This brings me onto my second query:

2)      The error suggests that obs.table is incorrect. I have a table with the three requested columns so I am not sure why it will not accept this. My only uncertainty about this table is the object column, is this simply a column from 1 to ….. representing the detection number and linking to the data table?

 

Any guidance would be much appreciated. Apologies for my R ignorance!

 

Many thanks,

 

Gemma Veneruso

 

 

 

Rhif Elusen Gofrestredig 1141565 - Registered Charity No. 1141565

Gall y neges e-bost hon, ac unrhyw atodiadau a anfonwyd gyda hi, gynnwys deunydd cyfrinachol ac wedi eu bwriadu i'w defnyddio'n unig gan y sawl y cawsant eu cyfeirio ato (atynt). Os ydych wedi derbyn y neges e-bost hon trwy gamgymeriad, rhowch wybod i'r anfonwr ar unwaith a dilewch y neges. Os na fwriadwyd anfon y neges atoch chi, rhaid i chi beidio a defnyddio, cadw neu ddatgelu unrhyw wybodaeth a gynhwysir ynddi. Mae unrhyw farn neu safbwynt yn eiddo i'r sawl a'i hanfonodd yn unig ac nid yw o anghenraid yn cynrychioli barn Prifysgol Bangor. Nid yw Prifysgol Bangor yn gwarantu bod y neges e-bost hon neu unrhyw atodiadau yn rhydd rhag firysau neu 100% yn ddiogel. Oni bai fod hyn wedi ei ddatgan yn uniongyrchol yn nhestun yr e-bost, nid bwriad y neges e-bost hon yw ffurfio contract rhwymol - mae rhestr o lofnodwyr awdurdodedig ar gael o Swyddfa Cyllid Prifysgol Bangor.

This email and any attachments may contain confidential material and is solely for the use of the intended recipient(s). If you have received this email in error, please notify the sender immediately and delete this email. If you are not the intended recipient(s), you must not use, retain or disclose any information contained in this email. Any views or opinions are solely those of the sender and do not necessarily represent those of Bangor University. Bangor University does not guarantee that this email or any attachments are free from viruses or 100% secure. Unless expressly stated in the body of the text of the email, this email is not intended to form a binding contract - a list of authorised signatories is available from the Bangor University Finance Office.

Eric Rexstad

unread,
May 4, 2016, 8:13:05 AM5/4/16
to Gemma Veneruso, distance...@googlegroups.com

Gemma

Rather than answer your questions 1 and 2; I'll stop you at the point where you say

"Since each row in the flatfile represents a detection I figure I cannot include effort and samples where there were no detections in this table."

That is not an accurate statement, it is very common for there to be transects without detections, so there must be some way to accommodate that in the data files.  The answer lies by looking at an example data file associated with the Distance R package

http://distancesampling.org/R/vignettes/minke.csv

If you examine that comma-delimited text file, you will see that transect 5 in the South stratum as well as transect 6 in that stratum had no detections (lines 26 and 27 in the file).  The way to determine this is to note that those rows contain stratum name, stratum size, transect label, transect length, *but no distance*.  There is a comma after transect length but no value following the comma.

That is the way in which you construct a 'flatfile' for surveys that include transects with no sightings. If you are happy with the 'flatfile' format, then I will not answer your questions about region/sample/obs tables.  See if that works for you.

--
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 post to this group, send email to distance...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/distance-sampling/DB5PR03MB1829E589D5D5D65B913ED076BB7B0%40DB5PR03MB1829.eurprd03.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Eric Rexstad
Research Unit for Wildlife Population Assessment
Centre for Research into Ecological and Environmental Modelling
University of St. Andrews
St. Andrews Scotland KY16 9LZ
+44 (0)1334 461833
The University of St Andrews is a charity registered in Scotland : No SC013532
Reply all
Reply to author
Forward
0 new messages