Seasonal Adjustment via the CAMPLET Method

Seasonal adjustment with CAMPLET (Abeln and Jacobs (2023) ), a transparent, adaptive method that corrects for seasonality and outliers via arithmetic-progression updates, without model identification or optimisation, and without revising earlier adjusted values when new observations arrive. A pure R port of the original 'Excel' 'VBA' implementation, validated against its output.


camplet

A pure R implementation of CAMPLET, a transparent, adaptive seasonal adjustment method that corrects for seasonality and outliers via arithmetic-progression updates, without model identification or optimisation, and without revising earlier adjusted values when new observations arrive. The method is described in Abeln & Jacobs (2023), Seasonal Adjustment Without Revisions.

Ported from the original VBA macro (D200603-CampletExcel-v4.2, basCBFherzien.bas) and validated against its own output (see tests/testthat/test-camplet.R). A Java port for JDemetra+ v3 lives at jdplus-camplet; this package has no dependency on it or on Java.

Installation

install.packages("camplet")

# development version
# install.packages("remotes")
remotes::install_git("https://gitrepo.service.rug.nl/team-data-science/camplet-r.git")

Usage

library(camplet)

res <- camplet(AirPassengers)
res$accuracy
head(as.data.frame(res))

camplet() is univariate: one series in, one result out. To adjust many series, loop over them yourself (e.g. lapply()/purrr::map() over a list of series, or dplyr::group_by() |> group_modify() on a long data frame) - the same way you would with seasonal::seas() or stats::stl().

The returned object's $data has raw/sa/seasonal columns; $diagnostics (or as.data.frame(res, diagnostics = TRUE), the default) adds the per-period adaptive-parameter trace that the original VBA tool wrote to its "Adj_" worksheets (ca, mu, pa, le, ti, expo_e, abs_pct_e, years, weight, growth).

Input requirements

CAMPLET reads observations by position: the k-th value is taken to be the period after the (k-1)-th. A skipped period therefore shifts every later observation into the wrong season while still producing plausible-looking output. To catch this, camplet():

  • stops if x contains NA, NaN or Inf (fill or trim the gaps first);
  • stops if dates has duplicated, out-of-order or irregularly spaced timestamps, e.g. a missing month;
  • warns if an explicit periodicity contradicts monthly or quarterly data, e.g. camplet(AirPassengers, periodicity = 4).

A plain numeric vector without dates can't be checked, so making sure it has no gaps is up to you. See ?camplet, section "Input checks".

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("camplet")

1.0.0 by Herbert Kruitbosch, 7 hours ago


https://gitrepo.service.rug.nl/team-data-science/camplet-r


Browse source code at https://github.com/cran/camplet


Authors: Barend Abeln [aut] (CAMPLET method and original VBA implementation) , Herbert Kruitbosch [aut, cre]


Documentation:   PDF Manual  


GPL-3 license


Suggests testthat, readxl


See at CRAN