Traffic Counts at Sonnenberg in the Harz Region

Description

This dataset contains daily traffic counts near Sonnenberg in the Harz region of Germany. It covers nearly three years, from 2021-01-01 to 2023-11-30, and combines traffic counts with weather covariates. The data are useful for illustrating seasonal count regression models, for example with cyclic smoothers over the day of the year.

Usage

data("HarzTraffic", package = "gamlss2")

Format

A data frame containing 1057 observations on 16 variables.

date
Date, the date of the record.
yday
Integer, the day of the year extracted from date. This is convenient for modeling within-year seasonality.
bikes
Integer, the number of motorcycles on that day.
cars
Integer, the number of cars on that day.
trucks
Integer, the number of trucks on that day.
others
Integer, the number of other vehicles on that day.
tempmin
Numeric, minimum temperature in \(^{\circ}C\).
tempmax
Numeric, maximum temperature in \(^{\circ}C\).
temp
Numeric, mean temperature in \(^{\circ}C\).
humidity
Numeric, mean relative humidity in percent.
tempdew
Numeric, average dewpoint temperature in \(^{\circ}C\).
cloudiness
Numeric, average cloud cover in percent.
rain
Numeric, amount of precipitation in mm (snow and rain).
sunshine
Numeric, sunshine duration in minutes.
wind
Numeric, mean wind speed in m/s.
windmax
Numeric, maximum wind speed in m/s.

Details

The traffic variables record daily counts by vehicle type. The weather variables summarize daily conditions measured at a nearby station. In package examples, bikes is often modeled as a seasonal response because motorcycle traffic shows a pronounced annual cycle and substantial variation across weather conditions.

Source

Weather Data:

Data Source:
Deutscher Wetterdienst (DWD), Climate Data Center (CDC).
Licence:
CC BY 4.0
URL:
https://opendata.dwd.de/climate_environment/CDC/
Station:
Wernigerode (5490; Sachsen-Anhalt)
Position:
10.7686/51.8454/233 (lon, lat, alt, EPSG 4326)

Traffic Data:

Data Source:
Bundesanstalt für Strassenwesen (BASt)
Licence:
CC BY 4.0
URL:
https://www.bast.de

Examples

library("gamlss2")

## seasonal variation of motorcycle counts at Sonnenberg/Harz
data("HarzTraffic", package = "gamlss2")
plot(bikes ~ yday, data = HarzTraffic)

## count distribution
barplot(table(HarzTraffic$bikes))

## negative binomial seasonal model using cyclic splines
m <- gamlss2(bikes ~ s(yday, bs = "cc") | s(yday, bs = "cc"),
  data = HarzTraffic, family = NBI)
GAMLSS-RS iteration  1: Global Deviance = 10151.1432 eps = 0.149402     
GAMLSS-RS iteration  2: Global Deviance = 10150.8948 eps = 0.000024     
GAMLSS-RS iteration  3: Global Deviance = 10150.8818 eps = 0.000001     
## visualize effects
plot(m)

## residual diagnostics
plot(m, which = "resid")

## fitted parameters for each day of the year
nd <- data.frame(yday = 1:365)

## corresponding quantiles
p <- quantile(m, newdata = nd, probs = c(0.05, 0.5, 0.95))

## visualization
plot(bikes ~ yday, data = HarzTraffic, pch = 19, col = gray(0.1, alpha = 0.3))
matplot(nd$yday, p, type = "l", lty = c(2, 1, 2), lwd = 2, col = 4, add = TRUE)