Package 'ggdemetra3'

Title: 'ggplot2' Extension for Seasonal and Trading Day Adjustment with 'JDemetra+' 3.0
Description: Provides 'ggplot2' extensions for seasonal and trading day adjustment based on the R interface to 'JDemetra+' version 3.0.
Authors: Alain Quartier-la-Tente [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-7890-3857>)
Maintainer: Alain Quartier-la-Tente <[email protected]>
License: EUPL
Version: 0.0.3
Built: 2026-10-18 14:55:56 UTC
Source: https://github.com/AQLT/ggdemetra3

Help Index


Plot Seasonal Adjustment Objects

Description

Plot Seasonal Adjustment Objects

Usage

## S3 method for class 'JD3_X13_OUTPUT'
autoplot(
  object,
  components = c("y", "sa", trend = "t", seasonal = "s", irregular = "i"),
  forecast = FALSE,
  ...
)

## S3 method for class 'JD3_TRAMOSEATS_OUTPUT'
autoplot(
  object,
  components = c("y", "sa", trend = "t", seasonal = "s", irregular = "i"),
  forecast = FALSE,
  ...
)

## S3 method for class 'JD3_X13_RSLTS'
autoplot(
  object,
  components = c("y", "sa", trend = "t", seasonal = "s", irregular = "i"),
  forecast = FALSE,
  ...
)

## S3 method for class 'JD3_TRAMOSEATS_RSLTS'
autoplot(
  object,
  components = c("y", "sa", trend = "t", seasonal = "s", irregular = "i"),
  forecast = FALSE,
  ...
)

## S3 method for class 'JD3_Object'
autoplot(
  object,
  components = c("y", "sa", trend = "t", seasonal = "s", irregular = "i"),
  forecast = FALSE,
  ...
)

## S3 method for class 'hf_decomposition'
autoplot(
  object,
  components = c("y", "sa", trend = "t", seasonal = "s", irregular = "i"),
  dates = NULL,
  ...
)

Arguments

object

A seasonal adjustment model (from rjd3x13, rjd3tramoseats, or rjd3highfreq).

components

Components to display. Can be "y" (input time series), "sa" (seasonally adjusted), "t" (trend-cycle), "y_cal" (calendar-adjusted), "s" (seasonal), "i" (irregular), and "cal" (calendar). The vector can be named to change the strip label.

forecast

Logical indicating whether the forecast series should be plotted (default is FALSE). Ignored for "hf_decomposition" objects (rjd3highfreq).

...

Additional arguments passed to methods.

dates

For "hf_decomposition" objects (rjd3highfreq), a numeric or date vector corresponding to the time series. If NULL, a sequence of integers is used. For models created with rjd3highfreq::fractional_airline_decomposition() or rjd3highfreq::multi_airline_decomposition(), the series_time parameter is used if available.

Value

A ggplot2 object representing the faceted components.

Examples

autoplot(rjd3x13::jx13(ipi_c_eu[, "FR"]))

hf_data <- usclaims[usclaims$date <= "2019-12-01",]
mod_hf <- rjd3highfreq::fractional_airline_decomposition(
  hf_data[, "Initial claims"], 
  period = 52,
  series_time = hf_data[, "date"]
)
autoplot(mod_hf, dates = usclaims$date[usclaims$date <= "2019-12-01"])

Extract Components from Seasonal Adjustment Objects

Description

Extract Components from Seasonal Adjustment Objects

Usage

seasonal(x, forecast = FALSE, calendar = FALSE, seas_freq = NULL, ...)

trendcycle(x, forecast = FALSE, ...)

irregular(x, forecast = FALSE, corrected = FALSE, ...)

seasonaladj(x, forecast = FALSE, corrected = FALSE, ...)

calendaradj(x, forecast = FALSE, spec = NULL, ...)

calendar(x, forecast = FALSE, spec = NULL, ...)

raw(x, forecast = FALSE, backcast = FALSE, spec = NULL, ...)

Arguments

x

A seasonal adjustment model (from rjd3x13, rjd3tramoseats, or rjd3highfreq).

forecast, backcast

Logicals indicating whether the forecast or backcast series should be returned. If forecast = TRUE and backcast = TRUE, the function only returns the forecast series. Default is FALSE. Ignored for rjd3highfreq objects.

calendar

If TRUE, seasonal() returns the seasonal and calendar components. Ignored for rjd3highfreq objects.

seas_freq

For methods with multiple seasonal frequencies (rjd3highfreq::multi_airline_decomposition(), rjd3highfreq::istl() or rjd3highfreq::mstl()), the seasonal frequency to extract. If NULL, the first seasonal frequency is returned.

...

Additional arguments passed to methods.

corrected

If TRUE, large extreme values are removed from the components. Ignored for rjd3tramoseats and rjd3highfreq objects.

spec

The specification used to estimate the model. Only used for "JD3_TRAMOSEATS_OUTPUT" objects for functions calendaradj(), calendar() and raw() (when forecast = FALSE and backast = TRUE) because the output doesn't contain the desired component and the specification.

Details

These functions are S3 generics supporting several classes from the rjdverse ecosystem:

  • X-13 models (rjd3x13): JD3_X13_OUTPUT, JD3_X13_RSLTS, JD3_Object;

  • TRAMO-SEATS models (rjd3tramoseats): JD3_TRAMOSEATS_OUTPUT, JD3_TRAMOSEATS_RSLTS;

  • High-frequency decompositions (rjd3highfreq): hf_decomposition (except for calendaradj() and calendar(), which are not supported for this class).

Value

A ts object (or a vector of numeric for "hf_decomposition" objects) containing the requested component.

A ts object with the requested component.

Examples

model <- rjd3x13::jx13(ipi_c_eu[, "FR"])
seasonal(model)
raw(model, forecast = TRUE)

Add ARIMA Model to Plots

Description

Function to directly add the ARIMA model used in the pre-adjustment process of seasonal adjustment to the plot. Only available for X-13 (rjd3x13::x13()) and TRAMO-SEATS (rjd3tramoseats::tramoseats()) methods.

Usage

geom_arima(
  mapping = NULL,
  data = NULL,
  stat = "arima",
  geom = c("text", "label"),
  position = "identity",
  ...,
  method = c("x13", "tramoseats"),
  spec = NULL,
  frequency = NULL,
  message = TRUE,
  x_arima = NULL,
  y_arima = NULL,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping

Set of aesthetic mappings created by ggplot2::aes(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

A data.frame that contains the data used for the seasonal adjustment.

stat

The statistical transformation to use on the data for this layer, as a string.

geom

Character. The geometric object to use to display the data: GeomText (geom = "text", the default, see ggplot2::geom_text()) or GeomLabel (geom = "label", see ggplot2::geom_label()).

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

...

Other arguments passed on to ggplot2::layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3.

method

The method used for the seasonal adjustment. "x13" (by default) for the X-13 method (using rjd3x13::jx13()) and "tramoseats" for TRAMO-SEATS (using rjd3tramoseats::.jtramoseats()). Both methods are only compatible with series of frequency 12 (monthly), 6 (bimonthly), 4 (quarterly), and 2 (semi-annual). For other frequencies, the following methods are available: "x11-extended" (see rjd3highfreq::x11plus()), "fractionalairline" (see rjd3highfreq::fractional_airline_decomposition()), "multiairline" (see rjd3highfreq::multi_airline_decomposition()), "stl" (see rjd3highfreq::stlplus()), "istl" (see rjd3highfreq::istl()), and "mstl" (see rjd3highfreq::mstl()).

spec

the specification used for the seasonal adjustment. For "x13" and "tramoseats" methods, it can be the name of a pre-defined specification or a user-defined specification created with rjd3x13::spec_x13() or rjd3tramoseats::spec_tramoseats().

frequency

The frequency of the time series. By default (frequency = NULL), the frequency is computed automatically.

message

A logical value indicating whether a message is printed with the frequency used.

x_arima, y_arima

Position of the ARIMA model text. By default, the first position of the data is used.

show.legend

Logical. Should this layer be included in the legends? NA, the default, includes it if any aesthetics are mapped. FALSE never includes it, and TRUE always includes it. It can also be a named logical vector to finely select the aesthetics to display.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them.

Details

With geom = "text", the ARIMA model used in the pre-adjustment process of seasonal adjustment is directly added to the plot. With geom = "label", a rectangle is drawn behind the ARIMA model text, making it easier to read.

Value

A ggplot2 layer object to be added to a plot.

Examples

p_sa_ipi_fr <- ggplot(data = ipi_c_eu_df, mapping = aes(x = date, y = FR)) +
    geom_line() +
    labs(
        title = "Seasonal adjustment of the French industrial production index",
        x = "time", y = NULL
    ) +
    geom_sa(color = "red", message = FALSE)
         
# To add the ARIMA model
p_sa_ipi_fr + 
    geom_arima(
        geom = "label",
        x_arima = -Inf, y_arima = -Inf, 
        vjust = -1, hjust = -0.1,
        message = FALSE
    )

Table of Diagnostics

Description

Adds a table of diagnostics to the plot. Only available for X-13 (rjd3x13::x13()) and TRAMO-SEATS (rjd3tramoseats::tramoseats()) methods.

Usage

geom_diagnostics(
  mapping = NULL,
  data = NULL,
  position = "identity",
  ...,
  method = c("x13", "tramoseats"),
  spec = NULL,
  frequency = NULL,
  message = TRUE,
  diagnostics = NULL,
  digits = 2,
  xmin = -Inf,
  xmax = Inf,
  ymin = -Inf,
  ymax = Inf,
  table_theme = ttheme_default(),
  inherit.aes = TRUE
)

Arguments

mapping

Set of aesthetic mappings created by ggplot2::aes(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

A data.frame that contains the data used for the seasonal adjustment.

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

...

Other arguments passed on to ggplot2::layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3.

method

The method used for the seasonal adjustment. "x13" (by default) for the X-13 method (using rjd3x13::jx13()) and "tramoseats" for TRAMO-SEATS (using rjd3tramoseats::.jtramoseats()). Both methods are only compatible with series of frequency 12 (monthly), 6 (bimonthly), 4 (quarterly), and 2 (semi-annual). For other frequencies, the following methods are available: "x11-extended" (see rjd3highfreq::x11plus()), "fractionalairline" (see rjd3highfreq::fractional_airline_decomposition()), "multiairline" (see rjd3highfreq::multi_airline_decomposition()), "stl" (see rjd3highfreq::stlplus()), "istl" (see rjd3highfreq::istl()), and "mstl" (see rjd3highfreq::mstl()).

spec

The specification used for the seasonal adjustment. For "x13" and "tramoseats" methods, it can be the name of a pre-defined specification or a user-defined specification created with rjd3x13::spec_x13() or rjd3tramoseats::spec_tramoseats(). For other methods, it can be a list of parameters used in the associated seasonal adjustment function.

frequency

The frequency of the time series. By default (frequency = NULL), the frequency is computed automatically.

message

A logical value indicating whether a message is printed with the frequency used.

diagnostics

Character vector containing the names of the diagnostics to plot. See rjd3x13::userdefined_variables_x13() or rjd3tramoseats::userdefined_variables_tramoseats() for the available parameters.

digits

Integer indicating the number of decimal places to be used for numeric diagnostics (default is 2).

xmin, xmax

Horizontal location of the raster in data coordinates.

ymin, ymax

Vertical location of the raster in data coordinates.

table_theme

List of theme parameters for the table of diagnostics (see gridExtra::ttheme_default()).

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them.

Value

A ggplot2 layer object to be added to a plot.

Examples

p_sa_ipi_fr <- ggplot(data = ipi_c_eu_df, mapping = aes(x = date, y = FR)) +
    geom_line() +
    labs(
        title = "Seasonal adjustment of the French industrial production index",
        x = "time", y = NULL
    ) +
    geom_sa(color = "red", message = FALSE)

# To add a table of diagnostics with the result of the X-11 combined test 
# and the p-values of the residual seasonality QS and F-tests:
diagnostics <- c("diagnostics.seas-sa-combined", "diagnostics.seas-sa-qs", "diagnostics.seas-sa-f")
p_sa_ipi_fr + 
    geom_diagnostics(
        diagnostics = diagnostics,
        ymin = 58, ymax = 72, xmin = 2010,
        table_theme = gridExtra::ttheme_default(base_size = 8),
        message = FALSE
    )

# To customize the names of the diagnostics in the plot:
diagnostics <- c(
    `Combined test` = "diagnostics.seas-sa-combined",
    `Residual qs-test (p-value)` = "diagnostics.seas-sa-qs",
    `Residual f-test (p-value)` = "diagnostics.seas-sa-f"
)
p_sa_ipi_fr + 
    geom_diagnostics(
        diagnostics = diagnostics,
        ymin = 58, ymax = 72, xmin = 2010,
        table_theme = gridExtra::ttheme_default(base_size = 8),
        message = FALSE
    )

# To add the table below the plot: 
p_diag <- ggplot(data = ipi_c_eu_df, mapping = aes(x = date, y = FR)) +
    geom_diagnostics(
        diagnostics = diagnostics,
        table_theme = gridExtra::ttheme_default(base_size = 8),
        message = FALSE
    ) + 
    theme_void()

gridExtra::grid.arrange(
    p_sa_ipi_fr, p_diag,
    nrow = 2, heights = c(4, 1)
)

Outliers Texts

Description

Function to directly add the outliers used in the pre-adjustment process of the seasonal adjustment to the plot. Only available for X-13 (rjd3x13::x13()) and TRAMO-SEATS (rjd3tramoseats::tramoseats()) methods.

Usage

geom_outlier(
  mapping = NULL,
  data = NULL,
  stat = "outlier",
  geom = c("text", "label", "text_repel", "label_repel"),
  position = "identity",
  ...,
  method = c("x13", "tramoseats"),
  spec = NULL,
  frequency = NULL,
  message = TRUE,
  first_date = NULL,
  last_date = NULL,
  coefficients = FALSE,
  digits = 1,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping

Set of aesthetic mappings created by ggplot2::aes(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

A data.frame that contains the data used for the seasonal adjustment.

stat

The statistical transformation to use on the data for this layer, as a string.

geom

Character. The geometry to use to display the data: GeomText (geom = "text", see ggplot2::geom_text()); GeomLabel (geom = "label", see ggplot2::geom_label()); GeomTextRepel (geom = "text_repel", the default, see ggrepel::geom_text_repel()); GeomLabelRepel (geom = "label_repel", see ggrepel::geom_label_repel()).

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

...

Other arguments passed on to ggplot2::layer(). They may be parameters of ggplot2::geom_text() (if geom = "text"), ggplot2::geom_label() (if geom = "label"), ggrepel::geom_text_repel() (if geom = "text_repel") or ggrepel::geom_label_repel() (if geom = "label_repel").

method

The method used for the seasonal adjustment. "x13" (by default) for the X-13 method (using rjd3x13::jx13()) and "tramoseats" for TRAMO-SEATS (using rjd3tramoseats::.jtramoseats()). Both methods are only compatible with series of frequency 12 (monthly), 6 (bimonthly), 4 (quarterly), and 2 (semi-annual). For other frequencies, the following methods are available: "x11-extended" (see rjd3highfreq::x11plus()), "fractionalairline" (see rjd3highfreq::fractional_airline_decomposition()), "multiairline" (see rjd3highfreq::multi_airline_decomposition()), "stl" (see rjd3highfreq::stlplus()), "istl" (see rjd3highfreq::istl()), and "mstl" (see rjd3highfreq::mstl()).

spec

The specification used for the seasonal adjustment. For "x13" and "tramoseats" methods, it can be the name of a pre-defined specification or a user-defined specification created with rjd3x13::spec_x13() or rjd3tramoseats::spec_tramoseats(). For other methods, it can be a list of parameters used in the associated seasonal adjustment function.

frequency

The frequency of the time series. By default (frequency = NULL), the frequency is computed automatically.

message

A logical value indicating whether a message is printed with the frequency used.

first_date

A numeric specifying the first date from which the outliers are plotted. By default (first_date = NULL), the outliers are plotted from the beginning of the time series.

last_date

A numeric specifying the last date up to which the outliers are plotted. By default (last_date = NULL), the outliers are plotted until the end of the time series.

coefficients

Logical indicating whether the estimated coefficients are printed. By default coefficients = FALSE.

digits

Integer indicating the number of decimal places to be used for the estimated coefficients of the outliers. By default digits = 1.

show.legend

Logical. Should this layer be included in the legends? NA, the default, includes it if any aesthetics are mapped. FALSE never includes it, and TRUE always includes it. It can also be a named logical vector to finely select the aesthetics to display.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them.

Details

With geom = "text", the outliers used in the pre-adjustment process of the seasonal adjustment are directly added to the plot. With geom = "label", a rectangle is drawn behind the names of the outliers, making them easier to read. The same applies to geom = "text_repel" or geom = "label_repel", but text labels are also repelled away from each other and away from the data points (see ggrepel::geom_label_repel()).

Value

A ggplot2 layer object to be added to a plot.

Examples

p_sa_ipi_fr <- ggplot(data = ipi_c_eu_df, mapping = aes(x = date, y = FR)) +
    geom_line() +
    labs(
        title = "Seasonal adjustment of the French industrial production index",
        x = "time", y = NULL
    ) +
    geom_sa(color = "red", message = FALSE)
         
# To add the outliers:
p_sa_ipi_fr + geom_outlier(
    geom = "label",
    message = FALSE
)

# To have a more readable plot with outlier names repelled away from each other 
# and from the data points:
p_sa_ipi_fr + 
    geom_outlier(
        geom = "label_repel",
        message = FALSE,
        vjust = 4,
        ylim = c(NA, 65), force = 10,
        arrow = arrow(
            length = unit(0.03, "npc"),
            type = "closed", ends = "last"
        )
    )

# To only plot the outliers from a specific date (2009):
p_sa_ipi_fr + 
    geom_outlier(
        geom = "label_repel",
        message = FALSE,
        first_date = 2009,
        vjust = 4,
        ylim = c(NA, 65), force = 10,
        arrow = arrow(
            length = unit(0.03, "npc"),
            type = "closed", ends = "last"
        )
    )

Seasonal Adjustment Time Series

Description

Performs a seasonal adjustment and plots a specific component of the decomposition. geom_sa() and stat_sa() are aliases: they both use the same arguments. Use stat_sa() if you want to display the results with a non-standard geom.

Usage

geom_sa(
  mapping = NULL,
  data = NULL,
  stat = "sa",
  position = "identity",
  ...,
  method = c("x13", "tramoseats", "x11-extended", "fractionalairline", "multiairline",
    "stl", "istl", "mstl"),
  spec = NULL,
  frequency = NULL,
  message = TRUE,
  component = "sa",
  show.legend = NA,
  inherit.aes = TRUE
)

stat_sa(
  mapping = NULL,
  data = NULL,
  geom = "line",
  position = "identity",
  ...,
  method = c("x13", "tramoseats", "x11-extended", "fractionalairline",
    "fractionalairlineestimation", "multiairline", "stl", "istl", "mstl"),
  spec = NULL,
  frequency = NULL,
  message = TRUE,
  component = "sa",
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping

Set of aesthetic mappings created by ggplot2::aes(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

A data.frame that contains the data used for the seasonal adjustment.

stat

The statistical transformation to use on the data for this layer, as a string.

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

...

Other arguments passed on to ggplot2::layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3.

method

The method used for the seasonal adjustment. "x13" (by default) for the X-13 method (using rjd3x13::jx13()) and "tramoseats" for TRAMO-SEATS (using rjd3tramoseats::.jtramoseats()). Both methods are only compatible with series of frequency 12 (monthly), 6 (bimonthly), 4 (quarterly), and 2 (semi-annual). For other frequencies, the following methods are available: "x11-extended" (see rjd3highfreq::x11plus()), "fractionalairline" (see rjd3highfreq::fractional_airline_decomposition()), "multiairline" (see rjd3highfreq::multi_airline_decomposition()), "stl" (see rjd3highfreq::stlplus()), "istl" (see rjd3highfreq::istl()), and "mstl" (see rjd3highfreq::mstl()).

spec

The specification used for the seasonal adjustment. For "x13" and "tramoseats" methods, it can be the name of a pre-defined specification or a user-defined specification created with rjd3x13::spec_x13() or rjd3tramoseats::spec_tramoseats(). For other methods, it can be a list of parameters used in the associated seasonal adjustment function.

frequency

The frequency of the time series. By default (frequency = NULL), the frequency is computed automatically.

message

A logical value indicating whether a message is printed with the frequency used.

component

A character string specifying the component to plot. The result must be a time series. See rjd3x13::userdefined_variables_x13() and rjd3tramoseats::userdefined_variables_tramoseats() for the available parameters for "x13" and "tramoseats". For other methods, the available components are the columns of the decomposition element of the result of the seasonal adjustment function (see documentation of the associated function for more details). By default (component = "sa"), the seasonally adjusted component is plotted.

show.legend

Logical. Should this layer be included in the legends? NA, the default, includes it if any aesthetics are mapped. FALSE never includes it, and TRUE always includes it. It can also be a named logical vector to finely select the aesthetics to display.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them.

geom

The geometric object to use to display the data.

Value

A ggplot2 layer object to be added to a plot.

Examples

p_ipi_fr <- ggplot(data = ipi_c_eu_df, mapping = aes(x = date, y = FR)) +
    geom_line() +
    labs(
        title = "Seasonal adjustment of the French industrial production index",
        x = "time", y = NULL
    )

# To add the seasonally adjusted series:
p_ipi_fr +
    geom_sa(color = "red")

# To add the forecasts of the input data and the seasonally adjusted series:
p_sa <- p_ipi_fr +
    geom_sa(component = "y_f", linetype = 2, message = FALSE) + 
    geom_sa(component = "sa", color = "red", message = FALSE) +
    geom_sa(component = "sa_f", color = "red", linetype = 2, message = FALSE)
p_sa

'ggplot2' Functions for 'rjd3filters' plots

Description

Set of ggplot2 plotting functions for filters and moving averages generated by the rjd3filters package.

Usage

ggplot_coef(x, zero_as_na = TRUE, ylab = "Coefficients", ...)

## S3 method for class 'finite_filters'
ggplot_coef(x, zero_as_na = TRUE, ylab = "Coefficients", q = 0, ...)

## S3 method for class 'moving_average'
ggplot_coef(x, zero_as_na = TRUE, ylab = "Coefficients", ...)

ggplot_gain(x, nxlab = 7, xlim = c(0, pi), ..., n = 101)

## S3 method for class 'finite_filters'
ggplot_gain(x, nxlab = 7, xlim = c(0, pi), q = 0, ..., n = 101)

## S3 method for class 'moving_average'
ggplot_gain(x, nxlab = 7, xlim = c(0, pi), ..., n = 101)

ggplot_phase(x, nxlab = 7, xlim = c(0, pi), normalized = FALSE, ..., n = 101)

## S3 method for class 'finite_filters'
ggplot_phase(
  x,
  nxlab = 7,
  xlim = c(0, pi),
  normalized = FALSE,
  q = 0,
  ...,
  n = 101
)

## S3 method for class 'moving_average'
ggplot_phase(x, nxlab = 7, xlim = c(0, pi), normalized = FALSE, ..., n = 101)

Arguments

x

coefficients, gain or phase.

zero_as_na

boolean indicating if the trailing zero of the coefficients should be plotted (FALSE) or removed (TRUE).

ylab

A character string specifying the y-axis label.

...

other arguments to matplot.

q

q.

nxlab

number of xlab.

xlim

vector containing x limits.

n

number of points used to plot the functions.

normalized

boolean indicatif if the phase function is normalized by the frequency.

Value

A ggplot2 object representing the coefficients, gain or phase of the filter.

Examples

filter <- rjd3filters::lp_filter(6, endpoints = "DAF", kernel = "Henderson")
ggplot_coef(filter, q = c(0,3))
ggplot_gain(filter, q = c(0,3))
ggplot_phase(filter, q = c(0,3))

Initialise a 'ggplot2' Object with an SA Model

Description

Initialise a 'ggplot2' Object with an SA Model

Usage

init_ggplot(x, ...)

## S3 method for class 'JD3_X13_OUTPUT'
init_ggplot(x, context = NULL, ...)

## S3 method for class 'JD3_TRAMOSEATS_OUTPUT'
init_ggplot(x, context = NULL, ...)

## S3 method for class 'JD3_Object'
init_ggplot(x, ...)

## S3 method for class 'hf_decomposition'
init_ggplot(x, dates = NULL, ...)

Arguments

x

A seasonally adjusted model.

...

Other parameters passed to ggplot2::ggplot().

context

The optional context used to estimate the model.

dates

Parameters used to re-estimate the model (see details).

Details

init_ggplot() initializes a ggplot2 object by storing the seasonal adjustment model used.

Value

A ggplot2 object that can be further customized.

Examples

mod <- rjd3x13::jx13(window(rjd3toolkit::ABS$X0.2.20.10.M, start = 2000))
init_ggplot(mod) +
    geom_line(color = "#F0B400") +
    geom_sa(component = "sa", color = "#155692")

Industrial Production Indices in manufacturing in the European Union

Description

A dataset containing on monthly industrial production indices in manufacturing in the European Union (from sts_inpr_m dataset of Eurostat). Data are based 100 in 2015 and are unadjusted, i.e. neither seasonally adjusted nor calendar adjusted.

Usage

ipi_c_eu

ipi_c_eu_df

Format

A monthly ts object from january 1990 to december 2017 with 34 variables for ipi_c_eu and a data.frame for ipi_c_eu_df.

An object of class data.frame with 360 rows and 35 columns.

Details

The dataset contains 34 time series corresponding to the following geographical area

BE Belgium
BG Bulgaria
CZ Czechia
DK Denmark
DE Germany (until 1990 former territory of the FRG)
EE Estonia
IE Ireland
EL Greece
ES Spain
FR France
HR Croatia
IT Italy
CY Cyprus
LV Latvia
LT Lithuania
LU Luxembourg
HU Hungary
MT Malta
NL Netherlands
AT Austria
PL Poland
PT Portugal
RO Romania
SI Slovenia
SK Slovakia
FI Finland
SE Sweden
UK United Kingdom
NO Norway
CH Switzerland
ME Montenegro
MK Former Yugoslav Republic of Macedonia, the
RS Serbia
TR Turkey
BA Bosnia and Herzegovina

Source

Eurostat


SI-Ratio Calculation and Plotting

Description

Computes and visualizes the Seasonal-Irregular (SI) ratio from a seasonal adjustment model (X-13 or TRAMO-SEATS).

Usage

siratio(x, ...)

siratioplot(
  x,
  labels = NULL,
  add = FALSE,
  box = TRUE,
  col.s = "darkblue",
  col.i = "gray",
  col.mean = "red",
  cex.i = 0.1,
  lwd.s = par("lwd"),
  lwd.mean = lwd.s,
  main = "SI ratio",
  xlab = NULL,
  ylab = NULL,
  xlim = NULL,
  ylim = NULL,
  ...
)

ggsiratioplot(
  x,
  labels = NULL,
  col.s = "darkblue",
  col.i = "gray",
  col.mean = "red",
  cex.i = 0.5,
  lwd.s = 1,
  lwd.mean = lwd.s,
  main = "SI ratio",
  xlab = NULL,
  ylab = NULL,
  ...
)

Arguments

x

An input model (X-13 or TRAMO-SEATS) or data object.

...

Additional arguments passed to methods or low-level plotting functions.

labels

Character vector of labels for the periods (e.g., months or quarters).

add

Logical indicating whether the plot should be added to an existing one.

box

Logical indicating whether a box should be drawn around the plot.

col.s, col.i, col.mean

Colors for the seasonal component, the SI points, and the mean lines.

cex.i, lwd.s, lwd.mean

Graphical parameters for point size and line widths.

main, xlab, ylab

Character strings for the main title, X-axis label, and Y-axis label.

xlim, ylim

Numeric vectors of length 2 specifying the X and Y axis limits.

Value

  • For siratio(): A ts object containing the SI ratio and the seasonal component.

  • For siratioplot(): Called for its side effects (base 'R' plot).

  • For ggsiratioplot(): A ggplot2 object representing the SI ratio chart.

Examples

x <- rjd3x13::x13(ipi_c_eu[, "FR"])
siratioplot(x)
ggsiratioplot(x)

Convert a 'ts' or 'mts' Object to a 'data.frame'

Description

Converts a ts or mts object into a data.frame that can be directly used in plotting functions.

Usage

ts2df(x)

## S3 method for class 'ts'
ts2df(x)

## S3 method for class 'mts'
ts2df(x)

Arguments

x

A ts or mts object.

Value

A data.frame object.

Examples

# To get the ipi_c_eu_df object:
ts2df(ipi_c_eu)

US Claims

Description

Weekly US claims

Usage

usclaims

Format

An object of class data.frame with 2868 rows and 3 columns.