Error while running "dsm"

44 views
Skip to first unread message

Ricardo Lima

unread,
Jan 21, 2015, 2:29:29 AM1/21/15
to distance...@googlegroups.com
Hi,

I've been following Miller et al. 2013 "Spatialmodels for distance sampling data: recent developments and future directions" (Meth Eco & Evo) to apply a DSM to my data on São Tomé dwarf olive ibis.

I've done my best to make sure my data fits the recquirements of "dsm", but when I try to run the model I get an error

"> mod1 <- dsm(N ~ s(x, y, k=4), hnmodel$ddf, sega, obsa)
Error in aggregate.data.frame(as.data.frame(x), ...) : 
  no rows to aggregate"

"sega" and "obsa" correspond to Miller's "segdata" and "obsdata", respectively, and have the following structure:
"> str(sega)
'data.frame': 146 obs. of  8 variables:
 $ code          : int  1 2 3 4 5 6 7 8 9 10 ...
 $ latitude      : num  0.146 0.147 0.148 0.15 0.151 ...
 $ longitude     : num  6.58 6.58 6.58 6.58 6.57 ...
 $ Effort        : num  3 3 3 3 3 3 3 3 3 3 ...
 $ Transect.Label: Factor w/ 5 levels "A","B","C","D",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ Sample.Label  : Factor w/ 146 levels "a1","a10","a11",..: 1 8 9 10 11 12 13 14 15 2 ...
 $ x             : num  -321 -433 -568 -720 -907 ...
 $ y             : num  -302.4 -139.5 13.2 188.3 262.6 ...
> str(obsa)
'data.frame': 47 obs. of  6 variables:
 $ code        : int  1 2 3 4 5 6 7 8 9 10 ...
 $ object      : Factor w/ 46 levels "A131","A132",..: 15 18 19 20 16 17 21 22 23 33 ...
 $ Sample.Label: Factor w/ 27 levels "ac10","ac16",..: 15 1 2 4 5 5 5 6 22 12 ...
 $ size        : num  2 1 1 1 2 3 1 1 2 1 ...
 $ distance    : num  0 11 0 15 0 22 10 23 5.5 5 ...
 $ Effort      : num  3 3 3 3 3 3 3 3 3 3 ..."


I wonder if this might have anything to do with the fact that I have multiple observations for the same segment (hence "obsa$Sample.Label" has only 27 levels instead of 47 ), or if that might in any other way create problems in the analysis.

Any help in how I might sort out this error would be greatly appreciated.

Best regards,
RICARDO.



-- 

Post-Doc Researcher
Animal Diversity and Conservation - http://cba.fc.ul.pt/members/ricardo_lima.php
Centre for Environmental Biology, Lisbon University Faculty of Sciences 
Office 2.5.15b, Campo Grande 1749-016 Lisboa, Portugal.

David Lawrence Miller

unread,
Jan 21, 2015, 7:51:49 AM1/21/15
to Ricardo Lima, distance...@googlegroups.com
Hi Ricardo and listfolk,

It's a little difficult to work out without seeing the data but it's
possible an issue is that the Sample.Label column is a factor.
aggregate() will try to match the observations to the segments using
their names but they may well not correspond as factors. You may want to
try calling

sega$Sample.Label <- as.character(sega$Sample.Label)
obsa$Sample.Label <- as.character(obsa$Sample.Label)

and see if that resolves the issue (worth inspecting that column to see
if the values are reasonable, NB for example that these labels are case
sensitive). If not please do got ahead and send me the data off-list and
I can take a look (and then we can post a solution to the list).


best,
--dave
> --
> Ricardo Faustino de Lima -
> http://sites.google.com/site/rfdelimasite/home
> <http://sites.google.com/site/rfdelimasite/home>
>
> Post-Doc Researcher
> Animal Diversity and Conservation -
> http://cba.fc.ul.pt/members/ricardo_lima.php
> <http://cba.fc.ul.pt/members/ricardo_lima.php>
> Centre for Environmental Biology, Lisbon University Faculty of Sciences
> Office 2.5.15b, Campo Grande 1749-016 Lisboa, Portugal.
>
> --
> 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/e082db5b-ea47-465d-99dc-0c4b9d67b3d7%40googlegroups.com
> <https://groups.google.com/d/msgid/distance-sampling/e082db5b-ea47-465d-99dc-0c4b9d67b3d7%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages