Abstract
Likelihood-based methods for model fitting and assessment, prediction and intervention analysis of count time series following generalized linear models are provided. Models with the identity and with the logarithmic link function are allowed. The conditional distribution can be Poisson or Negative Binomial.
Introduction
Standard time series analysis often relies on ARIMA models, which assume data is continuous and normally distributed. However, many real-world datasets—such as daily hospital admissions, weekly crime reports, or monthly equipment failures—consist of non-negative integers (counts). Applying Gaussian models to low-count data leads to biased estimates and impossible predictions, such as negative counts.
While models like INGARCH (Integer-valued GARCH) exist to handle these cases, researchers often lacked a cohesive, user-friendly toolset that combined flexible link functions, handled overdispersion, and provided rigorous methods to detect "interventions" or sudden external shifts. The R package tscount fills this gap by providing a robust likelihood-based framework for these specific challenges.
Methodology
The package centers on the tsglm function, which fits a Generalized Linear Model (GLM) to a count time series $Z_t$. The core methodology includes several key components:
Model Specification
It supports two primary link functions: the Identity Link, useful for additive effects (often referred to as INGARCH models), and the Logarithmic Link, which is useful for multiplicative effects and ensures predicted means remain positive without strict parameter constraints. The model allows for regression on previous observations and previous conditional means.
Distributions
Users can choose between the Poisson distribution or the Negative Binomial distribution. The latter is crucial for "overdispersed" data where the variance is significantly larger than the mean.
Intervention Analysis
A standout feature is the ability to test for and detect interventions (shocks). The package can identify three types of effects: level shifts (permanent changes), transient effects (decaying shocks), and outliers (single-point spikes). It uses score tests and an iterative detection procedure to find these events at unknown time points.
Model Assessment
Beyond standard metrics like AIC and BIC, the package implements Proper Scoring Rules (logarithmic, quadratic, spherical, and ranked probability scores) and Probability Integral Transform (PIT) histograms. These tools evaluate the quality of the entire predictive distribution, not just the point forecast.
Datasets
The package includes several real-world longitudinal datasets, primarily from the field of epidemiology, which serve as benchmarks for count time series analysis:
campy: 140 observations of Campylobacter infections in Quebec.- Infectious Disease Series: Weekly reports from North Rhine-Westphalia, Germany, for
ecoli,ehec,influenza, andmeasles. polio: A classic dataset of monthly polio cases.
Key Insights and Results
- Link Function Trade-offs: The package highlights the trade-off between the identity and log links. While the identity link is more intuitive for additive growth, the log link is often more stable in practice because it naturally prevents negative count predictions.
- Probabilistic Forecasting: A key philosophy of
tscountis that for count data, a single "predicted number" is rarely enough. By providing PIT histograms and marginal calibration plots, the package allows users to validate if the model's predicted probability distribution matches observed frequencies. - Automated Forensics: The intervention detection functions act as a forensic tool, using statistical score tests to scan the timeline and pinpoint the most likely moment of impact for policy changes or environmental shifts.
Limitations and Future Work
Currently, tscount is primarily designed for univariate time series. While it allows for external covariates, it does not natively handle multivariate count systems where multiple series influence each other. Additionally, bootstrap-based intervention detection can be computationally intensive for long series. Future iterations could potentially include Zero-Inflated models to better handle datasets with an excessive number of zeros.
Summary updated