brownian.bridge.dyn makes R crash
Good afternoon,
I have encountered a weird problem when while trying to create a dBBMM, for some individuals, it seems like the C script crashes (segfault?) and in turns this crashes the R session.
I have tried to understand what happens, played with parameters and sometimes crashes disappear, sometimes they appear in a new place. I have not been able to pinpoint the culprit and my C debugging skills are nonexistent. This seems to happen only when working with wide ranging species and a fixed grid, so I suspect the culprit might come from there, maybe an out of bounds problem of some sort.
It is just very frustrating to have to restart R everytime the script has a problem.
Here is an example of the problem (sorry for the weird mix of move and move2 objects, this was the easiest for me):
rm(list = ls())
library(tidyverse)
library(sf)
library(move)
library(move2)
MOVE_MARGIN <- 7
MOVE_WINDOW <- 21
burst_size <- 9
rast <-
raster(
extent(c(1702491, 3476491, -467898.7, 1429101)),
res = 1000,
crs = CRS(
"epsg:3978"
),
vals = 0
)
st_df <- read_csv("data.csv") %>% st_as_sf(coords = c("X", "Y"), crs = st_crs(3978))
df_move <-
to_move(mt_as_move2(st_df, time_column = "date", track_id_column = "id"))
median_tl <- median(timeLag(x = df_move, units = "mins"))
bursted <- move::burst(df_move, c('normal', 'long')[1 + (timeLag(df_move, units = 'mins') > median_tl * burst_size)])
dbbmm <-
brownian.bridge.dyn(
bursted,
burstType = 'normal',
location.error = bursted@data$error,
raster = rast,
window.size = MOVE_WINDOW,
margin = MOVE_MARGIN,
time.step = median_tl / 15
)
Maybe there is something I am not doing right here and I welcome any advice!
Thank you and have a nice day
data for the example: data.csv