# NOT RUN {
# loading the data
networkgpkg <- system.file("extdata", "networks.gpkg", package = "spNetwork", mustWork = TRUE)
eventsgpkg <- system.file("extdata", "events.gpkg", package = "spNetwork", mustWork = TRUE)
mtl_network <- sf::st_read(networkgpkg,layer="mtl_network")
bike_accidents <- sf::st_read(eventsgpkg,layer="bike_accidents")
# converting the Date field to a numeric field (counting days)
bike_accidents$Time <- as.POSIXct(bike_accidents$Date, format = "%Y/%m/%d")
bike_accidents$Time <- difftime(bike_accidents$Time, min(bike_accidents$Time), units = "days")
bike_accidents$Time <- as.numeric(bike_accidents$Time)
bike_accidents <- subset(bike_accidents, bike_accidents$Time>=89)
future::plan(future::multisession(workers=2))
# calculating the cross validation values
cv_scores <- bw_tnkde_cv_likelihood_calc.mc(
bw_net_range = c(100,1000),
bw_net_step = 100,
bw_time_range = c(10,60),
bw_time_step = 5,
lines = mtl_network,
events = bike_accidents,
time_field = "Time",
w = rep(1, nrow(bike_accidents)),
kernel_name = "quartic",
method = "discontinuous",
diggle_correction = FALSE,
study_area = NULL,
max_depth = 10,
digits = 2,
tol = 0.1,
agg = 15,
sparse=TRUE,
grid_shape=c(1,1),
sub_sample=1,
verbose = FALSE,
check = TRUE)
## make sure any open connections are closed afterward
if (!inherits(future::plan(), "sequential")) future::plan(future::sequential)
# }
Run the code above in your browser using DataLab