| Title: | Tools to Help to Publish the Trend-Cycle Component |
|---|---|
| Description: | This package provides several functions to facilitate the computation of trend-cycle component. In particular, the computation can be done: using the Cascade Linear Filter (CLF) Dagum, E. B., & Luati, A. (2008); using the classical Henderson symmetric filter and the surrogate Musgrave asymmetric filters; using a local Parametrization of the Musgrave asymmetric filters (Quartier-la-Tente 2024); extending the Henderson symmetric fiter and the surrogate Musgrave asymmetric filters to take into account additive outliers and level shifts (Quartier-la-Tente 2025). Confidence intervals can be computed and several plots are available. |
| Authors: | Alain Quartier-la-Tente [aut, cre] (ORCID: <https://orcid.org/0000-0001-7890-3857>) |
| Maintainer: | Alain Quartier-la-Tente <[email protected]> |
| License: | EUPL |
| Version: | 0.2.2 |
| Built: | 2026-05-26 06:22:06 UTC |
| Source: | https://github.com/AQLT/publishTC |
Get the bandwidth of a "tc_estimates" object.
The length of the filter is then equal to .
bandwidth(x)bandwidth(x)
x |
a |
Classical moving average for trend-cycle extraction.
henderson CLF CLF_CN local_param_esthenderson CLF CLF_CN local_param_est
henderson is list() of "moving_average".
CLF is a "finite_filters".
CLF_CN is a "finite_filters".
local_param_est is list() of "finite_filters".
henderson contains the Henderson moving average of length 5, 7, 9, 13 and 23.
CLF contains the Cascade Linear Filter (CLF) of length 13 and the associated Asymmetric Linear Filters (ALF).
CLF_CN contains the Cascade Linear Filter (CLF) of length 13 and the associated cut and normalise asymetric filters.
Dagum, E. B., & Luati, A. (2008). A Cascade Linear Filter to Reduce Revisions and False Turning Points for Real Time Trend-Cycle Estimation. Econometric Reviews 28 (1-3): 40‑59. https://doi.org/10.1080/07474930802387837.
Henderson, R. (1916). Note on graduation by adjusted average. Transactions of the actuarial society of America 17: 43‑48.
Quartier-la-Tente, A. (2024). Improving Real-Time Trend Estimates Using Local Parametrization of Polynomial Regression Filters. Journal of Official Statistics, 40(4), 685-715. https://doi.org/10.1177/0282423X241283207.
Smoothing using the Cascade Linear Filter
clf_smoothing(x, endpoints = c("cut-and-normalize", "ALF"), ...)clf_smoothing(x, endpoints = c("cut-and-normalize", "ALF"), ...)
x |
input time-series. |
endpoints |
Method used for the asymmetric filter.
If |
... |
other unused parameters. |
Dagum, E. B., & Luati, A. (2008). A Cascade Linear Filter to Reduce Revisions and False Turning Points for Real Time Trend-Cycle Estimation. Econometric Reviews 28 (1-3): 40‑59. https://doi.org/10.1080/07474930802387837
Confidence Intervals plot
confint_plot( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", col_confint = "grey", xlab = "", ylab = "", level = 0.95, ... ) ggconfint_plot( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", col_confint = "grey", legend_tc = "Trend-cycle", legend_sa = "Seasonally adjusted", legend_confint = "Confidence interval", level = 0.95, ... )confint_plot( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", col_confint = "grey", xlab = "", ylab = "", level = 0.95, ... ) ggconfint_plot( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", col_confint = "grey", legend_tc = "Trend-cycle", legend_sa = "Seasonally adjusted", legend_confint = "Confidence interval", level = 0.95, ... )
object |
|
xlim, ylim
|
x and y limits of the plot.
If |
col_sa, col_tc
|
color of the seasonally adjusted and trend-cycle components. |
col_confint |
color of the confidence interval. |
xlab, ylab
|
x and y axis labels. |
level |
the confidence level required. |
... |
other parameters. |
legend_tc, legend_sa, legend_confint
|
legend of the trend-cycle and seasonally adjusted components and for the confidence intervals. |
tc_mod <- henderson_smoothing(french_ipi[, "manufacturing"]) confint_plot(tc_mod, xlim = c(2022, 2024.5))tc_mod <- henderson_smoothing(french_ipi[, "manufacturing"]) confint_plot(tc_mod, xlim = c(2022, 2024.5))
"tc_estimates"
Confidence Intervals for "tc_estimates"
## S3 method for class 'henderson' confint(object, parm, level = 0.95, asymmetric_var = TRUE, ...) ## S3 method for class 'clf' confint(object, parm, level = 0.95, asymmetric_var = TRUE, ...) ## S3 method for class 'robust_henderson' confint(object, parm, level = 0.95, asymmetric_var = TRUE, ...)## S3 method for class 'henderson' confint(object, parm, level = 0.95, asymmetric_var = TRUE, ...) ## S3 method for class 'clf' confint(object, parm, level = 0.95, asymmetric_var = TRUE, ...) ## S3 method for class 'robust_henderson' confint(object, parm, level = 0.95, asymmetric_var = TRUE, ...)
object |
a |
parm |
unused parameter. |
level |
the confidence level required. |
asymmetric_var |
if |
... |
other (unused) parameters. |
Produce several plots
ggsmoothing_plot( object, plots = c("normal", "confint", "lollypop", "implicit_forecasts"), level = 0.95, ... )ggsmoothing_plot( object, plots = c("normal", "confint", "lollypop", "implicit_forecasts"), level = 0.95, ... )
object |
|
plots |
list of plots to use. |
level |
the confidence level required. |
... |
other unused parameters. |
Plots the growth rate of the trend-cycle (solid lines) and the seasonally adjusted series (bar-line).
growthplot( object, pct = TRUE, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", xlab = "", ylab = "", sa_bar_line = TRUE, ..., lag = -1 ) gggrowthplot( object, pct = TRUE, xlim = NULL, ylim = NULL, sa_bar_line = TRUE, col_tc = "#E69F00", col_sa = "black", col_sa_fill = "grey", legend_tc = "Trend-cycle", legend_sa = "Seasonally adjusted", ..., lag = -1 )growthplot( object, pct = TRUE, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", xlab = "", ylab = "", sa_bar_line = TRUE, ..., lag = -1 ) gggrowthplot( object, pct = TRUE, xlim = NULL, ylim = NULL, sa_bar_line = TRUE, col_tc = "#E69F00", col_sa = "black", col_sa_fill = "grey", legend_tc = "Trend-cycle", legend_sa = "Seasonally adjusted", ..., lag = -1 )
object |
|
pct |
logical. If |
xlim, ylim
|
x and y limits of the plot.
If |
col_sa, col_tc
|
color of the seasonally adjusted and trend-cycle components. |
xlab, ylab
|
x and y axis labels. |
sa_bar_line |
logical. If |
... |
other (unused) parameters. |
lag |
lag used for the growth rate.
By default, |
col_sa_fill |
fill color of the bar of the seasonally adjusted series. |
legend_tc, legend_sa
|
legend of the trend-cycle and seasonally adjusted components. |
tc_mod <- henderson_smoothing(french_ipi[, "manufacturing"]) growthplot(tc_mod, xlim = c(2022, 2024.5))tc_mod <- henderson_smoothing(french_ipi[, "manufacturing"]) growthplot(tc_mod, xlim = c(2022, 2024.5))
Smoothing using the Henderson filter
henderson_robust_smoothing( x, endpoints = c("Musgrave", "QL", "CQ", "DAF"), length = NULL, ao = NULL, ao_tc = NULL, ls = NULL, icr = NULL, local_icr = FALSE, asymmetric_var = FALSE, degree = 3, ... )henderson_robust_smoothing( x, endpoints = c("Musgrave", "QL", "CQ", "DAF"), length = NULL, ao = NULL, ao_tc = NULL, ls = NULL, icr = NULL, local_icr = FALSE, asymmetric_var = FALSE, degree = 3, ... )
x |
input time-series. |
endpoints |
Method used for the asymmetric filter. By default the Musgrave method is used |
length |
the length of the |
ao |
Dates of the Additive Outliers (AO) which effects are associated to the irregular component. |
ao_tc |
Dates of the Additive Outliers (AO) which effects are associated to the trend-cycle component. |
ls |
Dates of the Level Shifts (LS) which effects are associated to the trend-cycle component. |
icr |
I/C ratio used for the asymmetric filter. |
local_icr |
if |
asymmetric_var |
when |
degree |
if |
... |
other parameters passed to |
Smoothing using the Henderson filter
henderson_smoothing( x, endpoints = c("Musgrave", "QL", "CQ", "CC", "DAF", "CN"), length = NULL, icr = NULL, local_icr = FALSE, asymmetric_var = FALSE, degree = 3, ... )henderson_smoothing( x, endpoints = c("Musgrave", "QL", "CQ", "CC", "DAF", "CN"), length = NULL, icr = NULL, local_icr = FALSE, asymmetric_var = FALSE, degree = 3, ... )
x |
input time-series. |
endpoints |
Method used for the asymmetric filter. By default the Musgrave method is used |
length |
the length of the |
icr |
I/C ratio used for the asymmetric filter. |
local_icr |
if |
asymmetric_var |
when |
degree |
if |
... |
other parameters passed to |
Quartier-la-Tente, A. (2024). Improving Real-Time Trend Estimates Using Local Parametrization of Polynomial Regression Filters. Journal of Official Statistics, 40(4), 685-715. https://doi.org/10.1177/0282423X241283207.
icr() compute the overall I/C ratio, while icrs() compute the I/C ratios for each period.
icr(x, tc, mul = FALSE) icrs(x, tc, mul = FALSE)icr(x, tc, mul = FALSE) icrs(x, tc, mul = FALSE)
x, tc
|
seasonally adjusted and trend-cycle components.
If |
mul |
boolean indicating if the decomposition is multiplicative or additive. |
x <- cars_registrations tc <- henderson_smoothing(x)x <- cars_registrations tc <- henderson_smoothing(x)
Compute Implicit Forecasts
implicit_forecasts(x, ...)implicit_forecasts(x, ...)
x |
a |
... |
other unused parameters. |
Implicit Forecasts plot
implicit_forecasts_plot( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", col_i_f = col_sa, xlab = "", ylab = "", lty_last_tc = 2, lty_i_f = 3, n_last_tc = 4, ... ) ggimplicit_forecasts_plot( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", col_i_f = col_sa, lty_last_tc = 2, lty_i_f = 3, n_last_tc = 4, legend_tc = "Trend-cycle", legend_sa = "Seasonally adjusted", legend_i_f = "Implicit forecasts", ... )implicit_forecasts_plot( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", col_i_f = col_sa, xlab = "", ylab = "", lty_last_tc = 2, lty_i_f = 3, n_last_tc = 4, ... ) ggimplicit_forecasts_plot( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", col_i_f = col_sa, lty_last_tc = 2, lty_i_f = 3, n_last_tc = 4, legend_tc = "Trend-cycle", legend_sa = "Seasonally adjusted", legend_i_f = "Implicit forecasts", ... )
object |
|
xlim, ylim
|
x and y limits of the plot.
If |
col_sa, col_tc
|
color of the seasonally adjusted and trend-cycle components. |
col_i_f |
color of the implicit forecasts. |
xlab, ylab
|
x and y axis labels. |
lty_last_tc, lty_i_f
|
line type of the last values of the trend-cycle component and for the implicit forecasts. |
n_last_tc |
number of last values of the trend-cycle component to be plotted with a different line type
(to emphasize that there is higher variability for the last estimates).
If |
... |
other parameters. |
legend_tc, legend_sa, legend_i_f
|
legend of the trend-cycle and seasonally adjusted components and for implicit forecasts. |
tc_mod <- henderson_smoothing(french_ipi[, "manufacturing"]) implicit_forecasts_plot(tc_mod, xlim = c(2022, 2025))tc_mod <- henderson_smoothing(french_ipi[, "manufacturing"]) implicit_forecasts_plot(tc_mod, xlim = c(2022, 2025))
Lollypop plot
lollypop( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", color_points = col_sa, cex_points = 1, pch_points = 16, xlab = "", ylab = "", lty_last_tc = 2, n_last_tc = 4, ... ) gglollypop( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", color_points = col_sa, cex_points = 1, pch_points = 16, legend_tc = "Trend-cycle", legend_sa = "Seasonally adjusted", lty_last_tc = 2, n_last_tc = 4, ... )lollypop( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", color_points = col_sa, cex_points = 1, pch_points = 16, xlab = "", ylab = "", lty_last_tc = 2, n_last_tc = 4, ... ) gglollypop( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", color_points = col_sa, cex_points = 1, pch_points = 16, legend_tc = "Trend-cycle", legend_sa = "Seasonally adjusted", lty_last_tc = 2, n_last_tc = 4, ... )
object |
|
xlim, ylim
|
x and y limits of the plot.
If |
col_sa, col_tc
|
color of the seasonally adjusted and trend-cycle components. |
color_points, cex_points
|
color and size of the points associated to the seasonnaly adjusted component. |
pch_points |
point type of the seasonally adjusted component. |
xlab, ylab
|
x and y axis labels. |
lty_last_tc |
line type of the last values of the trend-cycle component. |
n_last_tc |
number of last values of the trend-cycle component to be plotted with a different line type
(to emphasize that there is higher variability for the last estimates).
If |
... |
other parameters. |
legend_tc, legend_sa
|
legend of the trend-cycle and seasonally adjusted components. |
tc_mod <- henderson_smoothing(french_ipi[, "manufacturing"]) lollypop(tc_mod, xlim = c(2022, 2024.5))tc_mod <- henderson_smoothing(french_ipi[, "manufacturing"]) lollypop(tc_mod, xlim = c(2022, 2024.5))
Month of Cyclical Dominance
mcd(x, tc, mul = FALSE)mcd(x, tc, mul = FALSE)
x, tc
|
seasonally adjusted and trend-cycle components.
If |
mul |
boolean indicating if the decomposition is multiplicative or additive. |
"tc_estimates" plotDefault "tc_estimates" plot
## S3 method for class 'tc_estimates' plot( x, y = NULL, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", xlab = "", ylab = "", lty_last_tc = 2, n_last_tc = 4, ... ) ## S3 method for class 'tc_estimates' autoplot( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", legend_tc = "Trend-cycle", legend_sa = "Seasonally adjusted", lty_last_tc = 2, n_last_tc = 4, ... )## S3 method for class 'tc_estimates' plot( x, y = NULL, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", xlab = "", ylab = "", lty_last_tc = 2, n_last_tc = 4, ... ) ## S3 method for class 'tc_estimates' autoplot( object, xlim = NULL, ylim = NULL, col_tc = "#E69F00", col_sa = "black", legend_tc = "Trend-cycle", legend_sa = "Seasonally adjusted", lty_last_tc = 2, n_last_tc = 4, ... )
y |
unused parameter. |
xlim, ylim
|
x and y limits of the plot.
If |
col_sa, col_tc
|
color of the seasonally adjusted and trend-cycle components. |
xlab, ylab
|
x and y axis labels. |
lty_last_tc |
line type of the last values of the trend-cycle component. |
n_last_tc |
number of last values of the trend-cycle component to be plotted with a different line type
(to emphasize that there is higher variability for the last estimates).
If |
... |
other (unused) parameters. |
object, x
|
|
legend_tc, legend_sa
|
legend of the trend-cycle and seasonally adjusted components. |
tc_mod <- henderson_smoothing(french_ipi[, "manufacturing"]) plot(tc_mod, xlim = c(2022, 2024.5))tc_mod <- henderson_smoothing(french_ipi[, "manufacturing"]) plot(tc_mod, xlim = c(2022, 2024.5))
Segmented Smoothing around Breakpoints
segmented_smoothing( x, breaks = NULL, break_method = c("one-side", "two-sides"), smoothing_method = c("henderson_smoothing", "clf_smoothing"), ... )segmented_smoothing( x, breaks = NULL, break_method = c("one-side", "two-sides"), smoothing_method = c("henderson_smoothing", "clf_smoothing"), ... )
x |
input time-series. |
breaks |
A list of breakpoints (dates) where the series should be split for smoothing. |
break_method |
Method to split the series (see details). |
smoothing_method |
Smoothing method to use on each segment : |
... |
Other parameters passed to the smoothing method. |
Two methods are available to estimate the trend-cycle around breakpoints:
"one-side": The trend-cycle is estimated on the all data and the estimates are overwritten after each breakpoint with the estimates obtained by smoothing only the data after the breakpoint.
"two-sides": The trend-cycle is estimated on each segment defined by the breakpoints and the estimates are combined to form the final trend-cycle.
The "parameters" field of the returned object corresponds to the parameters of the last segment (used to build confidence intervals and implicit forecasts).
x <- window(publishTC::french_ipi[, "manufacturing"], start = 2015) tc_h <- henderson_smoothing(x, length = 13)$tc breaks <- list(c(2020, 3)) tc_h_2s <- segmented_smoothing(x, breaks = breaks, break_method = "two-sides", length = 13)$tc tc_h_rob <- henderson_robust_smoothing(x, ls = c(2020+ (3-1)/12, 2020+ (4-1)/12))$tc plot(window(x, start = 2019.5, end = 2021), main = "Smoothing around COVID-19", xlab = NULL, ylab = NULL, lty = 3 ) lines(tc_h, col = "purple") lines(tc_h_2s, col = "lightblue") lines(tc_h_rob, col = "orange") legend( "bottomright", legend = c("y", "Henderson", "Two-Sides Segmented", "Robust H. (2 LS)"), col= c("black", "purple", "lightblue", "orange"), lty = c(3, 1, 1, 1, 1), cex = 0.7 )x <- window(publishTC::french_ipi[, "manufacturing"], start = 2015) tc_h <- henderson_smoothing(x, length = 13)$tc breaks <- list(c(2020, 3)) tc_h_2s <- segmented_smoothing(x, breaks = breaks, break_method = "two-sides", length = 13)$tc tc_h_rob <- henderson_robust_smoothing(x, ls = c(2020+ (3-1)/12, 2020+ (4-1)/12))$tc plot(window(x, start = 2019.5, end = 2021), main = "Smoothing around COVID-19", xlab = NULL, ylab = NULL, lty = 3 ) lines(tc_h, col = "purple") lines(tc_h_2s, col = "lightblue") lines(tc_h_rob, col = "orange") legend( "bottomright", legend = c("y", "Henderson", "Two-Sides Segmented", "Robust H. (2 LS)"), col= c("black", "purple", "lightblue", "orange"), lty = c(3, 1, 1, 1, 1), cex = 0.7 )
Smoothing using several methods
smoothing( x, methods = c("henderson", "henderson_localic", "henderson_robust", "henderson_robust_localic", "clf_cn", "clf_alf"), endpoints = "Musgrave", length = NULL, icr = NULL, asymmetric_var = FALSE, degree = 3, ao = NULL, ao_tc = NULL, ls = NULL, ... )smoothing( x, methods = c("henderson", "henderson_localic", "henderson_robust", "henderson_robust_localic", "clf_cn", "clf_alf"), endpoints = "Musgrave", length = NULL, icr = NULL, asymmetric_var = FALSE, degree = 3, ao = NULL, ao_tc = NULL, ls = NULL, ... )
x |
input time-series. |
methods |
list of methods to use. |
endpoints |
Method used for the asymmetric filter. By default the Musgrave method is used |
length |
the length of the |
icr |
I/C ratio used for the asymmetric filter. |
asymmetric_var |
when |
degree |
if |
ao |
Dates of the Additive Outliers (AO) which effects are associated to the irregular component. |
ao_tc |
Dates of the Additive Outliers (AO) which effects are associated to the trend-cycle component. |
ls |
Dates of the Level Shifts (LS) which effects are associated to the trend-cycle component. |
... |
other unused parameters. |
Compute the smoothness of trend-cycle estimates using Picard and Matthews (2006) definition.
smoothness(x)smoothness(x)
x |
a |
There are several definitions or criteria of smoothness. The measure of smoothness used here is defined as:
This represents a measure of the month-to-month percentage change in the trend-cycle. The smaller the smoothness number is, the smoother the trend-cycle.
Picard, Frédéric et Steve Matthews (2016). The Addition of Trend-Cycle Estimates to Selected Publications at Statistics Canada. Proceedings of the Survey Methods Section, Statistical Society of Canada (SSC) Annual Meeting. <https://ssc.ca/sites/default/files/imce/pdf/p icard_ssc2016.pdf>.
All data sets examples used in the paper Quartier-la-Tente (2025).
cars_registrations french_ipi fred simulated_data etipcars_registrations french_ipi fred simulated_data etip
An object of class ts of length 177.
An object of class mts (inherits from ts, matrix, array) with 416 rows and 3 columns.
An object of class mts (inherits from ts, matrix, array) with 766 rows and 2 columns.
An object of class mts (inherits from ts, matrix, array) with 84 rows and 6 columns.
An object of class ts of length 590.
cars_registrations: monthly new passenger cars registrations in France, published in October 2024.
french_ipi: monthly industrial production index in France for Crude Petroleum, Motor Vehicles and Manufacturing published in October 2024.
fred: the series CE16OV (Civilian Employment Level) and RETAILx (Retail and Food Services Sales) from the FRED-MD database published in November 2022.
simulated_data: simulated trends of degree 0, 1 and 2 with an Additive Outlier (AO) or Level Shift (LS) in January 2022
etip corresponds to the Expected trend in production (balance of opinion) in the French Manufacturing industry, published in May 2025 in
the monthly business survey in goods-producing industries by the INSEE.
Quartier-la-Tente, A. (2025). Estimation de la tendance-cycle avec des méthodes robustes aux points atypiques. https://github.com/AQLT/robustMA. McCracken, Michael W., et Serena Ng. 2016. FRED-MD: A Monthly Database for Macroeconomic Research. Journal of Business & Economic Statistics 34 (4): 574‑89. https://doi.org/10.1080/07350015.2015.1086655.
turning_points() returns the number of downturns (downturn()) and upturns (upturn()) in a time series.
unwanted_ripples() returns the number of unwanted ripples in a time series.
turning_points(x, start = NULL, end = NULL, digits = 6, k = 3, m = 1) upturn(x, start = NULL, end = NULL, digits = 6, k = 3, m = 1) downturn(x, start = NULL, end = NULL, digits = 6, k = 3, m = 1) unwanted_ripples(x, start = NULL, end = NULL, digits = 6, k = 3, m = 1)turning_points(x, start = NULL, end = NULL, digits = 6, k = 3, m = 1) upturn(x, start = NULL, end = NULL, digits = 6, k = 3, m = 1) downturn(x, start = NULL, end = NULL, digits = 6, k = 3, m = 1) unwanted_ripples(x, start = NULL, end = NULL, digits = 6, k = 3, m = 1)
x |
the input time series. |
start, end
|
the interval where to find turning points. |
digits |
number of digits used for the comparison of the values. |
k, m
|
number of observation before and after the turning point (see details). |
Zellner, Hong, et Min (1991) definition is used , :
we have an upturn at date when
we have a downturn at date when
An unwanted ripple is defined whenever two downturns or upturns occur within a 10 month period (i.e.: small cycles of less than 11 months).
Export and Import time series object to/from CSV
write.ts(x, file) read.ts(file, frequency = NULL, list = FALSE)write.ts(x, file) read.ts(file, frequency = NULL, list = FALSE)
x |
a time series object |
file |
a character string giving the name of the file to write to. |
frequency |
an integer giving the number of observations per unit of time. By default it is guessed from the data. |
list |
boolean, if |
Perform X-11 selection of the length of Henderson (x11_trend_selection()) and
compute the associated I/C ratio used to build Musgrave fuilters (find_icr()).
x11_trend_selection(x) find_icr(length, freq = 12)x11_trend_selection(x) find_icr(length, freq = 12)
x |
a |
length |
length of the filter. |
freq |
frequency of the time series used to compute the I/C ratio. |
The following procedure is used in X-11 to select the length of the trend filter:
Computes the I/C ratio, with an Henderson filter of length the frequency plus 1.
The length depends on the value or :
if then the selected length is 9 for monthly data and 5 otherwise;
if then the selected length is where is the frequency of data (12 for monthly data, 4 for quarterly data...).
if then the selected length is 23 for monthly data and 7 otherwise.
The value of is then fixed to build Musgrave filters (find_icr()) :
for quarterly data, if the length is 5 then , otherwide ;
if the length if less or equal to 9 then ;
else if the length if less or equal to 13 then ;
else .
Wrapper around rjd3x13::regarima_outliers() to detect Additive Outliers (AO) or
Level Shifts (LS) in a seasonnally adjusted series.
x13_regarima_outliers( y, order = c(0, 1, 1), mean = FALSE, ao = TRUE, ls = TRUE )x13_regarima_outliers( y, order = c(0, 1, 1), mean = FALSE, ao = TRUE, ls = TRUE )
y |
A |
order |
Orders of the ARIMA model. |
mean |
Logical, if |
ao, ls
|
Boolean to indicate if additive outliers (AO) or level shifts (LS) should be detected. |
A list with two elements: ao and ls, which are vectors of time points where the respective outliers were detected. If no outliers were detected, the corresponding element will be NULL.