| Title: | Seasonal Adjustment via the CAMPLET Method |
|---|---|
| Description: | Seasonal adjustment with CAMPLET (Abeln and Jacobs (2023) <doi:10.1007/978-3-031-22845-2>), 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. |
| Authors: | Barend Abeln [aut] (CAMPLET method and original VBA implementation), Herbert Kruitbosch [aut, cre] |
| Maintainer: | Herbert Kruitbosch <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.0 |
| Built: | 2026-10-22 19:30:07 UTC |
| Source: | https://github.com/cran/camplet |
Coerce a 'camplet' result to a data frame
## S3 method for class 'camplet' as.data.frame(x, ..., diagnostics = TRUE)## S3 method for class 'camplet' as.data.frame(x, ..., diagnostics = TRUE)
x |
a 'camplet' object, as returned by [camplet()]. |
... |
unused. |
diagnostics |
if 'TRUE' (default), include the per-period adaptive diagnostic columns (see [camplet()]) alongside 'raw'/'sa'/'seasonal'. |
a 'data.frame' with one row per input observation: the columns of 'x$data', plus the diagnostic columns if 'diagnostics = TRUE'.
Seasonally adjusts a single time series with the CAMPLET algorithm: a transparent, adaptive method that corrects for seasonality and outliers via arithmetic-progression updates, without model identification or optimisation. See Abeln and Jacobs (2023) for the method.
camplet( x, dates = NULL, periodicity = NULL, ca = 0, mu = 50, pa = 1, le = 0, ti = 1 )camplet( x, dates = NULL, periodicity = NULL, ca = 0, mu = 50, pa = 1, le = 0, ti = 1 )
x |
a numeric vector or 'ts' object, without missing values. |
dates |
optional 'Date' or 'POSIXct' vector, same length as 'x'; required only when 'periodicity = 31' (calendar-aware, variable-month-length mode for daily data). If supplied, it is checked for regular spacing (see Input checks) and used as the 'time' column of the result. |
periodicity |
periods per year (e.g. '12', '4'), a cycle length in rows (e.g. '7' for day-of-week seasonality), or '31' for calendar-aware daily mode. If 'x' is a 'ts' object this defaults to 'frequency(x)'; otherwise it is required. |
ca, mu, pa, le, ti
|
CAMPLET tuning parameters; see Details. 'ca = 0' and ‘le = 0' mean "derive a default from 'periodicity'" (the algorithm’s own convention). |
The five tuning parameters are:
Common Adjustment: weight applied to normal (non-outlier) observations. '0' = derive from periodicity.
Multiplier: scales the correction applied to outliers.
Pattern-shift length in years.
Limit-to-Error: the percent threshold separating an outlier from a normal observation. '0' = derive from periodicity.
Times: number of successive same-direction outliers tolerated before a pattern shift is declared.
an object of class '"camplet"', a list with:
a 'data.frame' with one row per input observation: 'time' (if available), 'raw', 'sa' (seasonally adjusted) and 'seasonal'.
a 'data.frame', one row per input observation, with the per-period adaptive-parameter trace the original VBA tool wrote to its "Adj_" worksheets: 'n', 'x', 'ca', 'mu', 'pa', 'le', 'ti', 'expo_e', 'abs_pct_e', 'years', 'weight', 'growth'.
CAMPLET's own accuracy metric (0-100).
diagnostic summary scalars feeding into 'accuracy'.
character, the final effective '"ca / mu / pa / le / ti"'.
CAMPLET reads observations by position: the k-th value is taken to be the period after the (k-1)-th. 'camplet()' therefore stops with an error when
'x' contains 'NA', 'NaN' or infinite values;
'dates' contains duplicated or out-of-order timestamps, or is not regularly spaced (e.g. a missing month). Regular means a constant step (daily, weekly, ...), calendar months/quarters/years on a consistent day of the month, or business days (Monday to Friday) without holiday gaps.
It warns when an explicit 'periodicity' contradicts monthly or quarterly data, i.e. 'frequency(x)' or the spacing of 'dates', such as 'periodicity = 4' for a monthly series. A plain numeric 'x' without 'dates' cannot be checked: making sure it has no gaps is up to the caller.
Abeln, B. and Jacobs, J. P. A. M. (2023). *Seasonal Adjustment Without Revisions: A Real-Time Approach*. SpringerBriefs in Economics. Springer, Cham. doi:10.1007/978-3-031-22845-2
x <- AirPassengers res <- camplet(x) res$accuracy head(as.data.frame(res))x <- AirPassengers res <- camplet(x) res$accuracy head(as.data.frame(res))