[R-sig-eco] R crashes while calculating BRB (Biased Random Bridge)

Nick van Doormaal nickvandoormaal26 at hotmail.com
Tue Jun 16 10:15:33 CEST 2015


Dear list members,

The past few weeks I've been troubled (and frustrated) about calculating the BRB in R, using adehabitatHR. For some reason, unknown to me, the program just crashes while calculating the BRB. However, this does not happen for all of them. The error occurs for about 10-20% of the data I used so far.

I've included a part of the dataset and the R-code, I hope it might be of use to you in helping me solving this problem. One interesting that I've found out so far is that the code works just fine using the first 1000 relocations. However, I don't think this is a data-size issue, as some other datasets are much larger and working without any problem.

Thank you for your time and effort. If there's anything I need to provide, please let me know.

Kind regards,

Nick


##R CODE FOR BRB 16-6-2015##
##LOADING ALL PACKAGES
library(ade4)
library(shapefiles)
library(adehabitatHS)
library(maptools)
library(rgdal)
library(raster)

##LOAD DATA
Dura <- readShapeSpatial("Dura, Jan 25 2013 (WGS 84).shp")

Dura$DateTime <- substr(Dura$Descriptio, 1, 19)
Dura$Date <- substr(Dura$Descriptio, 1, 10)
Dura$Time <- substr(Dura$Descriptio, 12, 19)

##SET COORDINATE SYSTEM
proj4string(Dura) = CRS("+init=epsg:4326") #4326 IS LAT LONG WGS84

##TRANSFORM COORDINATES
Dura <- spTransform(Dura, CRS("+init=epsg:32736")) #UTM36S

##CREATE A LTRAJ-CLASS
Dura2 <- Dura[!duplicated(Dura$DateTime), ]
Dura2$Descriptio <- NULL
Dura.da <- as.character(Dura2$DateTime)
Dura.da <- as.POSIXct(strptime(as.character(Dura2$DateTime),"%Y/%m/%d %H:%M:%S"))
Dura.df <- as.data.frame(Dura2)
Dura.xy <- coordinates(Dura2)
Dura.ltraj <- as.ltraj(xy =Dura.xy, date = Dura.da, id = Dura.df$Date)

plot(Dura.ltraj[1])

##RUN THE MODEL
Dura.vv = BRB.D(Dura.ltraj[1], Tmax = 60, Lmin = 0)
Dura.est = Dura.ltraj[1]

Dura.id <- BRB(Dura.est, D = Dura.vv, Tmax = 60, tau = 5, Lmin = 0, hmin=25, grid = 100, type=("ID"), same4all=TRUE, extent=0.2, maxt = 20, filtershort=TRUE)
Dura.rd <- BRB(Dura.est, D = Dura.vv, Tmax = 60, tau = 5, Lmin = 0, hmin=25, grid = 100, type=("RD"), same4all=TRUE, extent=0.2, maxt = 20, filtershort=TRUE)
Dura.ud <- BRB(Dura.est, D = Dura.vv, Tmax = 60, tau = 5, Lmin = 0, hmin=25, grid = 100, type=("UD"), same4all=TRUE, extent=0.2, maxt = 20, filtershort=TRUE)

##END
 		 	   		  


More information about the R-sig-ecology mailing list