JeremyGelb/spNetwork

Does the spNetwork support the output of spatial & temporal bandwidth in tnkde?

bright1993ff66 opened this issue · 2 comments

Hi @JeremyGelb , I am recently using the tnkde function based on adaptive bandwidth to analyze the spatio-temporal distribution of accident records across the city.

I am wondering if the tnkde function can output the optimal spatial and temporal bandwidth values when computing the density values, based on the given arguments such as road network and point distribution? From a nkde example, you mentioned that the bandwidth is computed for each event. Is it possible to obtain a overall bandwidth value in density computation (e.g., mean bandwidth values based on all the events)?

The function I refer to is given below. Thank you for your time and help!

tnkde_densities <- tnkde(lines = mtl_network,
                   events = bike_accidents,
                   time_field = "Time",
                   w = rep(1, nrow(bike_accidents)), 
                   samples_loc = sample_points,
                   samples_time = sample_time, 
                   kernel_name = "quartic",
                   bw_net = 700, bw_time = 60,
                   adaptive = TRUE,
                   adaptive_separate = FALSE,
                   trim_bw_net = 900,
                   trim_bw_time = 80,
                   method = "discontinuous",
                   div = "bw", max_depth = 10,
                   digits = 2, tol = 0.01,
                   agg = 15, grid_shape = c(1,1), 
                   verbose  = FALSE)

Dear Bright,

Currently, it is possible to do bandwidth selection by likelihood cross validation for a TNKDE (see here). The function to use is : bw_tnkde_cv_likelihood_calc. However, it will only use global bandwidths and not local bandwidths. I am currently reworking the function to make it possible to use local bandwidths.

So, for the moment, you can select an optimal network and time global bandwidths with the function bw_tnkde_cv_likelihood_calc. Be sure to also check visually the results because likelihood cross validation tends to select large bandwidths for bivariate kernel density estimate.

Thanks @JeremyGelb for your prompt reply!

I will check the bandwidth selection method bw_tnkde_cv_likelihood_calc you mentioned.