'ggplot2' Extension for Seasonal and Trading Day Adjustment with 'RJDemetra'

Provides 'ggplot2' functions to return the results of seasonal and trading day adjustment made by 'RJDemetra'. 'RJDemetra' is an 'R' interface around 'JDemetra+' (< https://github.com/jdemetra/jdemetra-app>), the seasonal adjustment software officially recommended to the members of the European Statistical System and the European System of Central Banks.


BuildStatus CRAN_Status_Badge

Overview

ggdemetra is an extension of ggplot2 to add seasonal adjustment statistics to your plots. The seasonal adjustment process is done with RJDemetra that is an R interface to JDemetra+, the seasonal adjustment software officially recommended to the members of the European Statistical System (ESS) and the European System of Central Banks. RJDemetra implements the two leading seasonal adjustment methods TRAMO/SEATS+ and X-12ARIMA/X-13ARIMA-SEATS.

There are 4 main functionnalities in ggdemetra depending of what you want to add in the graphic:

  • geom_sa(): to add a time series compute during the seasonal adjustment (the trend, the seasonal adjusted time series, etc.).
  • geom_outliers(): to add the outliers used in the pre-adjustment process of the seasonal adjustment.
  • geom_arima(): to add the ARIMA model used in the pre-adjustment process of the seasonal adjustment.
  • geom_diagnostics(): to add a table containing some diagnostics on the seasonal adjustment process.

Installation

Since RJDemetra requires Java SE 8 or later version, the same requirements are also needed for ggdemetra.

ggdemetra is not on CRAN for the moment. To use it you need to install the GitHub version:

# install.packages("devtools")
devtools::install_github("AQLT/ggdemetra")

Usage

To add the seasonal adjusted series and the forecasts of the input data and of the seasonal adjusted series:

library(ggplot2)
library(ggdemetra)
 
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)
p_sa <- p_ipi_fr +
    geom_sa(component = "y_f", linetype = 2, message = TRUE) + 
    geom_sa(component = "sa", color = "red", message = FALSE) +
    geom_sa(component = "sa_f", color = "red", linetype = 2, message = FALSE)
p_sa

To add the outliers at the bottom of the plot with an arrow to the data point and the estimate coefficient:

p_sa + 
    geom_outlier(geom = "label_repel",
                 coefficients = TRUE,
                 message = FALSE,
                 vjust = 4,
                 ylim = c(NA, 65), force = 10,
                 arrow = arrow(length = unit(0.03, "npc"),
                               type = "closed", ends = "last"))
#> Frenquency used: 12

To add the ARIMA model:

p_sa + 
    geom_arima(geom = "label",
               x_arima = -Inf, y_arima = -Inf, 
               vjust = -1, hjust = -0.1,
               message = FALSE)
#> Frenquency used: 12

To add a table of diagnostics below the plot:

diagnostics <- c(`Combined test` = "diagnostics.combined.all.summary",
                 `Residual qs-test (p-value)` = "diagnostics.qs",
                 `Residual f-test (p-value)` = "diagnostics.ftest")
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, p_diag,
             nrow = 2, heights  = c(4, 1))
#> Frenquency used: 12

News

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("ggdemetra")

0.1.0 by Alain Quartier-la-Tente, a month ago


https://github.com/AQLT/ggdemetra


Report a bug at https://github.com/AQLT/ggdemetra/issues


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


Authors: Alain Quartier-la-Tente [aut, cre]


Documentation:   PDF Manual  


Task views: Time Series Analysis


EUPL license


Imports RJDemetra, ggrepel, gridExtra

Depends on ggplot2

Suggests knitr, rmarkdown

System requirements: Java SE 8 or higher


See at CRAN