The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
trafficCAR provides tools for constructing
conditional autoregressive (CAR) precision matrices on
graphs derived from road networks. The package supports network creation
from spatial linework, basic spatial weight construction, and
proper/ICAR precision matrices that can be used in Gaussian hierarchical
models.
This vignette walks through a minimal workflow that uses the bundled example roads data to build a network, create spatial weights, and construct CAR/ICAR precision matrices suitable for simulation or modeling.
Q_car <- car_precision(net$A, type = "proper", rho = 0.25, tau = 1)
Q_icar <- intrinsic_car_precision(net$A, tau = 1, scale = FALSE)
Q_car[1:6, 1:6]
#> 6 x 6 sparse Matrix of class "dsCMatrix"
#>
#> [1,] 1.00 . . -0.25 . .
#> [2,] . 1 . . . .
#> [3,] . . 1.00 -0.25 . .
#> [4,] -0.25 . -0.25 3.00 . .
#> [5,] . . . . 2 .
#> [6,] . . . . . 1
dim(Q_icar)
#> [1] 1754 1754trafficCAR includes lightweight interactive mapping
helpers built on leaflet. They visualize segment-level
traffic quantities such as predicted traffic levels or relative
congestion on the bundled example road network.
The example below fabricates simple segment-level quantities so the
map can be rendered without fitting a full model. In applied workflows,
these values are produced automatically by
augment_roads().
roads_sf <- roads_small
# mock traffic quantities (stand-in for augment_roads() output)
set.seed(123)
# many mapping helpers expect these standard columns
roads_sf$predicted_mean <- runif(nrow(roads_sf), min = 20, max = 60)
roads_sf$relative_congestion <- as.numeric(scale(runif(nrow(roads_sf))))
has_leaflet <- requireNamespace("leaflet", quietly = TRUE) &&
requireNamespace("viridisLite", quietly = TRUE)
if (has_leaflet) {
map_roads_interactive(roads_sf, value = "predicted_speed")
} else {
message("Install 'leaflet' and 'viridisLite' to view the interactive map.")
}You can also expose multiple standard traffic layers using
map_roads_interactive_layers().
build_network() converts road linework to a graph with
adjacency and edge metadata.weights_from_adjacency() can produce binary or
row-standardized weights.car_precision() and
intrinsic_car_precision() create sparse CAR/ICAR precision
matrices.Planned extensions include:
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.