Package: trafficCAR 0.1.1

Madison Ell

trafficCAR: Bayesian CAR Models for Road-Segment Traffic

Tools for simulating and modeling traffic flow on road networks using spatial conditional autoregressive (CAR) models. The package represents road systems as graphs derived from 'OpenStreetMap' data <https://www.openstreetmap.org/> and supports network-based spatial dependence, basic preprocessing, and visualization for spatial traffic analysis.

Authors:Madison Ell [aut, cre]

trafficCAR_0.1.1.tar.gz
trafficCAR_0.1.1.tar.gz(r-4.7-any)trafficCAR_0.1.1.tar.gz(r-4.6-any)
trafficCAR_0.1.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION
card.svg |card.png
trafficCAR/json (API)

# Install 'trafficCAR' in R:
install.packages('trafficCAR', repos = c('https://cran.r-universe.dev', 'https://cloud.r-project.org'))
Datasets:

On CRAN:

Conda:

This package does not link to any Github/Gitlab/R-forge repository. No issue tracker or development information is available.

3.90 score 487 downloads 23 exports 46 dependencies

Last updated from:a7809875d4. Checks:4 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK164
source / vignettesOK254
linux-release-x86_64OK160
wasm-releaseOK188

Exports:augment_roadsbuild_adjacencybuild_networkcar_precisionfetch_osm_roadsfit_carfit_trafficicar_sum_to_zerointrinsic_car_precisionmap_roads_interactivemap_roads_interactive_layersmoran_residualsplot_mcmc_diagnosticsplot_observed_fittedplot_predictedplot_relative_congestionplot_roads_staticplot_traffic_mapppc_summaryroads_to_segmentssample_proper_carsimplify_networkweights_from_adjacency

Dependencies:abindbackportscheckmateclassclassIntclicpp11DBIdistributionale1071farvergenericsggplot2gluegtableigraphisobandKernSmoothlabelinglatticelifecyclemagrittrMASSMatrixmatrixStatsnumDerivpillarpkgconfigposteriorproxyR6RColorBrewerRcpprlangs2S7scalessftensorAtibbleunitsutf8vctrsviridisLitewithrwk

CAR-models
Conditional autoregressive (CAR) models | ICAR model | Proper CAR model | Disconnected graphs and isolated nodes | Scaling (Sørbye–Rue)

Last update: 2026-01-27
Started: 2026-01-27

Creating Custom Road Datasets with trafficCAR
Overview | Step 1: Obtain road data for a city | Step 2: Clean, validate, and inspect geometries | Step 3: Write the dataset to GeoJSON (raw source) | Step 4A: Save as .rds (recommended for user projects) | Step 4B: Convert GeoJSON to .rda (recommended for R packages) | Step 5: Use the dataset in trafficCAR | Organizing multiple city datasets | Example directory layout (package development) | Example data-raw script | Using external GeoJSON files directly | Summary

Last update: 2026-01-27
Started: 2026-01-27

Fetching OSM roads
Overview | Fetch by place name | Fetch by bounding box | Filtering the OSM query

Last update: 2026-01-27
Started: 2026-01-27

Plotting model fit, diagnostics, and spatial patterns
Load data and build segment adjacency | Simulate an outcome and fit a CAR model | Prepare a plotting-ready fit object | Plot observed vs fitted values | Plot MCMC diagnostics | Plot spatial predictions | Tips for applied workflows

Last update: 2026-01-27
Started: 2026-01-27

Sampling from Gaussian CAR and ICAR Models
Purpose | CAR and ICAR precision matrices | A small graph example | Proper CAR | ICAR | Sampling from a sparse precision matrix | Zero-mean sampling | Nonzero mean (linear term) | Notes on ICAR sampling | A road-like graph example | Option 2: Synthetic road-like graph (fallback) | CAR/ICAR sampling on the road graph | Summary

Last update: 2026-01-27
Started: 2026-01-27

traffic-flow

Last update: 2026-01-27
Started: 2026-01-27

trafficCAR Model Diagnostics and Checking
Residual diagnostics | Moran’s I on residuals | Posterior predictive checks | Practical workflow | Limitations

Last update: 2026-01-27
Started: 2026-01-27

trafficCAR-intro
Introduction | Load the package and example data | Build a road network graph | Spatial weights from the adjacency matrix | CAR and ICAR precision matrices | Sampling from a CAR precision matrix | Interactive road visualizations | Takeaways | Further directions

Last update: 2026-01-27
Started: 2026-01-27

Readme and manuals

Help Manual

Help pageTopics
Augment roads with predicted traffic quantitiesaugment_roads
Build segment adjacency from segment geometriesbuild_adjacency
Build a road network graph from sf LINESTRING databuild_network
CAR precision matrix from an adjacency matrixcar_precision
Fetch road geometries from OpenStreetMapfetch_osm_roads
Fit Gaussian CAR / ICAR regression via Gibbs samplingfit_car
Fit a Gaussian CAR traffic model (speed or travel time)fit_traffic
Apply sum-to-zero constraint to ICAR precisionicar_sum_to_zero
Intrinsic CAR (ICAR) precision matrixintrinsic_car_precision
Interactive map of road-segment traffic measuresmap_roads_interactive
Interactive map with multiple standard traffic layersmap_roads_interactive_layers
Moran's I for trafficCAR residualsmoran_residuals
MCMC diagnostic plotsplot_mcmc_diagnostics
Plot observed vs predicted traffic valuesplot_observed_fitted
Plot predicted traffic outcome on road networkplot_predicted
Plot relative congestion on road networkplot_relative_congestion
Static map of road-segment traffic measuresplot_roads_static
Quick map helper for augmented roadsplot_traffic_map
Posterior predictive checks for trafficCAR fitsppc_summary
Residuals for trafficCAR fitsresiduals.traffic_fit
Example road network datasetsroads_cstat roads_datasets roads_small
Convert road geometries to modeling segmentsroads_to_segments
Gibbs sampler for a proper CAR latent Gaussian modelsample_proper_car
Simplify a built network object by removing parallel edges (and loops)simplify_network
Construct spatial weights matrixweights_from_adjacency