Learn R Programming

spNetwork (version 0.4.3)

tkde: Temporal Kernel density estimate

Description

Calculate the Temporal kernel density estimate based on sampling points in time and events

Usage

tkde(events, w, samples, bw, kernel_name, adaptive = FALSE)

Arguments

events

A numeric vector representing the moments of occurrence of events

w

The weight of the events

samples

A numeric vector representing the moments to sample

bw

A float, the bandwidth to use

kernel_name

The name of the kernel to use

adaptive

Boolean

Value

A numeric vector with the density values at the requested timestamps

Examples

Run this code
# NOT RUN {
eventsgpkg <- system.file("extdata", "events.gpkg", package = "spNetwork", mustWork = TRUE)
bike_accidents <- sf::st_read(eventsgpkg,layer="bike_accidents")
bike_accidents$Date <- as.POSIXct(bike_accidents$Date, format = "%Y/%m/%d")
start <- min(bike_accidents$Date)
diff <- as.integer(difftime(bike_accidents$Date , start, units = "days"))
density <- tkde(diff, rep(1,length(diff)), seq(0,max(diff),1), 2, "quartic")
# }

Run the code above in your browser using DataLab