Package 'rjd3workspace'

Title: Interface to 'JDemetra+ 3.x' time series analysis software
Description: R Interface to 'JDemetra+ 3.x' (<https://github.com/jdemetra>). It offers several functions to manipulate 'JDemetra+' workspaces, which can be read by the software and can store several seasonal adjusted series along with user-defined calendars or regression variables.
Authors: Jean Palate [aut], Alain Quartier-la-Tente [aut] , Tanguy Barthelemy [aut, cre, art], Anna Smyk [aut]
Maintainer: Tanguy Barthelemy <[email protected]>
License: file LICENSE
Version: 3.2.4.9000
Built: 2025-02-14 15:25:43 UTC
Source: https://github.com/rjdverse/rjd3workspace

Help Index


Extract Java Metadata

Description

Extract specific metadata or time series metadata of a SA-item.

Usage

.jsai_metadata(jsa, key)

.jsai_ts_metadata(jsa, key)

Arguments

jsa

Java SA-item object.

key

key of the metadata.


Get the name of a SAProcessing or a Sa-item

Description

Functions to retrieve the name of a SAProcessing (.jsap_name()) or SaItem (.jsai_name()).

This function is used to retrieve the Java names of all the sa_items contained in a SA-Processing.

Usage

.jsai_name(jsa)

.jsap_name(jsap)

.jsap_sa_name(jsap)

Arguments

jsap, jsa

the object to retrieve the name from.

jsap

the java object representing the SA-Processing

Value

A vector character.

See Also

Other functions to retrieve the name of JDemetra+ objects (workspace, SA-Processing or SA-item): .jsai_name, .jsap_name.

Examples

y <- rjd3toolkit::ABS$X0.2.09.10.M

jws <- .jws_new()
jsap1 <- .jws_sap_new(jws, "sa1")

add_sa_item(jsap1, name = "x13", x = rjd3x13::x13(y))
add_sa_item(jsap1, name = "tramo", x = rjd3tramoseats::tramoseats(y))
add_sa_item(jsap1, name = "x13-2", x = y, rjd3x13::x13_spec())
add_sa_item(jsap1, name = "tramo-2", x = y, rjd3tramoseats::tramoseats_spec())

print(.jsap_sa_name(jsap1))

Create a Workspace or SA-Processing

Description

Functions creating a 'JDemetra+' Workspace (.jws_new()) and adding a new SA-Processing (.jws_sap_new()). A modelling context can be added to a workspace, it will be valid for all its SA-Processings.

Usage

.jws_new(modelling_context = NULL)

.jws_sap_new(jws, name)

Arguments

modelling_context

a list of variables and calendars

jws

Workspace object.

name

name of the new SA-Processing (character).

Details

A modelling context is a list of variables to be used as external regressors in modelling processes (Reg-Arima or Tramo) or calendars to be used to generate calendar regressors. It can be created with rjd3toolkit::modelling_context() function or retrieved from another workspace ((set_context))

Value

Returns a java object workspace or SA-Processing.

References

More information on workspaces in JDemetra+ Graphical User Interface: https://jdemetra-new-documentation.netlify.app/t-gui-sa-modelling-features/

See Also

read_workspace, read_sap

Examples

# Create an empty 'JDemetra+' Workspace
jws <- .jws_new()
# Add an empty SA-Processing
jsap <- .jws_sap_new(jws, "sap1")

Load a 'JDemetra+' Workspace

Description

.jws_open() or .jws_open() load an existing Workspace and .jws_compute() computes it (allowing to extract all the SA-Items as java objects).

Usage

.jws_open(file)

.jws_load(file)

Arguments

file

path to Workspace xml master file By default a dialog box opens.

See Also

read_workspace() to transform the workspace in a R list.

Examples

# Load a Workspace
# jws <- .jws_load(file= my_workspace.xml)
# Compute the workspace to enable access to its components
# .jws_compute(jws)

Extract a SA-Processing or a SA-Item

Description

Functions allowing to extract a SA-Processing from a Workspace using its order number (index) and a SA-Item from a SA-Processing its order number (index). The original object is unaltered.

Usage

.jsap_sai(jsap, idx)

.jws_sap(jws, idx)

Arguments

idx

index of the object to extract.

jws, jsap

Workspace or SA-Processing.

Value

Returns a java object SA-Processing or SA-Item.

Examples

# Load a Workspace
# jws <- .jws_load(file= my_workspace.xml)
# Compute the workspace to enable access to its components
# .jws_compute(jws)
# Extract 2nd SA-Processing
#jsap_2 <- .jws_sap(jws_ref,2)
# Extract 9th SA-item
#jsai_9 <- .jsap_sai(jsap_2,9)

Count SA-Processings or SA-Items

Description

Functions counting the SA-Processings in a Workspace (jws_sap_count) or the SA-Items in a SA-Processing (jsap_sa_count).

Usage

.jsap_sa_count(jsap)

.jws_sap_count(jws)

Arguments

jws, jsap

Workspace or SA-Processing.

Value

Returns an integer.

Examples

#' # Create a Workspace
jws <- .jws_new()
# Add an 2 SA-Processings
jsap1 <- .jws_sap_new(jws, "sap1")
jsap2 <- .jws_sap_new(jws, "sap2")
# Count the SA-Processings
.jws_sap_count(jws)

Add a Calendar to a Workspace

Description

Add a Calendar to a Workspace

Usage

add_calendar(jws, name, calendar)

Arguments

jws

Workspace object.

name

name of calendar to add.

calendar

calendar to add.


Add a SA-item to a SAProcessing

Description

Add a SA-item to a SAProcessing

Usage

add_sa_item(jsap, name, x, spec, ...)

Arguments

jsap

SAProcessing.

name

name of the SA-item to be added.

x

either a seasonal adjustment model (from rjd3x13::x13() or rjd3tramoseats::tramoseats()), a SA-item or a "ts" object.

spec

specification to use when x is a "ts" object.

...

other unused parameters.

Examples

dir <- tempdir()
y <- rjd3toolkit::ABS$X0.2.09.10.M
jws <- .jws_new()
jsap1 <- .jws_sap_new(jws, "sa1")
add_sa_item(jsap1, name = "x13", x = rjd3x13::x13(y))
add_sa_item(jsap1, name = "tramo", x = rjd3tramoseats::tramoseats(y))
add_sa_item(jsap1, name = "x13-2", x = y, rjd3x13::x13_spec())
add_sa_item(jsap1, name = "tramo-2", x = y, rjd3tramoseats::tramoseats_spec())
save_workspace(jws, file.path(dir, "workspace.xml"))

Add Variable to Workspace

Description

Add Variable to Workspace

Usage

add_variable(jws, group, name, y)

Arguments

jws

Workspace object.

group, name

group and name of the variable to add.

y

variable to add (a ts object).


Check existing JD+ object

Description

Check existing JD+ object

Usage

check_information(jws, idx_sap = NULL, idx_sai = NULL)

Arguments

jws

workspace object

idx_sap

index (or indices) of the SA-Processing (s) to check

idx_sai

index (or indices) of the SA-Item(s) to check.

Details

If the object idx_sai is NULL then the function will only check if the workspace contains a SA-Processing at the index idx_sap. If the object idx_sap is NULL then the function will check if every SA-Processing of the workspace contains a SA-Item at the index idx_sai. If the object idx_sap is NULL and idx_sai is NULL then the function won't do any check.

If the object idx_sap and / or idx_sai have a length > 1 then the checks are iterated over all the indices.

Value

This function returns either a boolean (TRUE) if the SAI and the SAP exist in the WS, or an error specifying the not found object.

Examples

# ws <- .jws_open(file = "ws_production.xml")
#
# # Check if the SA-Item 3 in the SA-Processing 1 exists
# check_information(jws = ws, idx_sap = 1, idx_sai = 3)

# # Check if the SA-Items 1, 2 and 5 in the SA-Processing 1 exist
# check_information(jws = ws, idx_sap = 1, idx_sai = c(1, 2, 5))

Deprecated functions

Description

Deprecated functions

Usage

.jmp_sa_count(jmp)

.jmp_name(jmp)

.jmp_sa(jmp, idx)

.jmp_sa_name(jmp)

.jmp_load(jmp)

.jws_multiprocessing(jws, idx)

.jws_multiprocessing_new(jws, name)

.jws_multiprocessing_count(jws)

.jsap_sa(jsap, idx)

.jsa_read(jsa)

.jsa_results(jsa, items = NULL)

.jsa_jresults(jsa)

.jsa_name(jsa)

.jsa_metadata(jsa, key)

.jsa_ts_metadata(jsa, key)

Arguments

jmp, idx, jws, name

Parameters.


Get Context from Workspace

Description

Get Context from Workspace

Usage

get_context(jws)

Arguments

jws

the Workspace.


Copy a Workspace or SA-Processing

Description

Copy a Workspace or SA-Processing

Usage

.jsap_make_copy(jsap)

.jws_make_copy(jws)

Arguments

jws, jsap

Java Workspace or SA-Processing

Details

The copy of a SA-processing will be made in the same workspace. The modelling context of the workspace is also copied.

Value

Returns a java object workspace or SA-Processing

References

More information on workspaces in JDemetra+ Graphical User Interface: https://jdemetra-new-documentation.netlify.app/t-gui-sa-modelling-features/

See Also

read_workspace, read_sap

Examples

# Create an empty 'JDemetra+' Workspace
jws <- .jws_new()
# Add an empty SA-Processing
jsap <- .jws_sap_new(jws, "sap1")
# Make a copy a the workspace
#jws2 <- .jws_make_copy(jws)
# Make a copy of sap1 in jws2
#jsap2 <- .jws_make_copy(jsap)

Read a Calendar file

Description

Read a Calendar file

Usage

read_calendars(file)

Arguments

file

Read an SA-item

Description

.jsai_results() extracts specific variables of the model of the SA-item while read_sai() extracts all the information of a SA-item (see details). .jsai_jresults() extracts the Java object of the results of a SA-item.

Usage

read_sai(jsa)

.jsai_results(jsa, items = NULL)

.jsai_jresults(jsa)

Arguments

jsa

Java SA-item object.

items

vector of characters containing the variables to extract. See rjd3x13::x13_dictionary() or rjd3tramoseats::tramoseats_dictionary(). By default, extracts all the possible variables.

Details

A SA-item contains more information than just the results of a model. All those informations are extracted with the read_sai() function that returns a list with 5 objects:

  • ts: the raw time series.

  • domainSpec: initial specification. Reference for any relaxing of some elements of the specification.

  • estimationSpec: specification used for the current estimation.

  • pointSpec: specification corresponding to the results of the current estimation (fully identified model).

  • results: the result of the model.


Read auxiliary variables (regressors) file

Description

Read auxiliary variables (regressors) file

Usage

read_variables(file)

Arguments

file

Read all SA-Items from a Workspace or SA-Processing

Description

Functions reading all SA-Items of a SA-Processing (read_sap()) or a Workspace (read_workspace()) and allowing to access them as R lists. Whereas functions .jread_sap() and .jread_workspace() only return corresponding Java objects

Usage

read_sap(jsap)

.jread_sap(jsap)

read_workspace(jws, compute = TRUE)

.jread_workspace(jws, compute = TRUE)

Arguments

jsap

java SA-Processing.

jws

java Workspace.

compute

compute or not the workspace.

Examples

file <- system.file("workspaces", "test.xml", package = "rjd3workspace")
jws <- .jws_load(file)
rws <- read_workspace(jws, FALSE)
# rws$Sap_3$SA-Item_43

Refresh a Workspace or SA-Processing

Description

Refresh a Workspace or SA-Processing

Usage

.jsap_refresh(
  jsap,
  policy = c("FreeParameters", "Complete", "Outliers_StochasticComponent", "Outliers",
    "FixedParameters", "FixedAutoRegressiveParameters", "Fixed"),
  period = 0,
  start = NULL,
  end = NULL,
  info = c("All", "Data", "None")
)

.jws_refresh(
  jws,
  policy = c("FreeParameters", "Complete", "Outliers_StochasticComponent", "Outliers",
    "FixedParameters", "FixedAutoRegressiveParameters", "Fixed"),
  period = 0,
  start = NULL,
  end = NULL,
  info = c("All", "Data", "None")
)

Arguments

policy

refresh policy to apply (see details).

period, start, end

to specify the span on which outliers will not be re-identified (i.e.: re-detected) when policy = "Outliers" or policy = "Outliers_StochasticComponent". Span definition: period: numeric, number of observations in a year (12, 4...). start and end: first and last date from which outliers will not be re-identified, defined as arrays of two elements: year and first period (for example, if period = 12, c(1980, 1) for January 1980). If they are not specified, the outliers will be re-identified on the whole series.

info

information to refresh.

jws, jsap

Java Workspace or SA-Processing

Details

Available refresh policies are:

Current: applying the current pre-adjustment reg-arima model and adding the new raw data points as Additive Outliers (defined as new intervention variables)

Fixed: applying the current pre-adjustment reg-arima model and replacing forecasts by new raw data points.

FixedParameters: pre-adjustment reg-arima model is partially modified: regression coefficients will be re-estimated but regression variables, Arima orders and coefficients are unchanged.

FixedAutoRegressiveParameters: same as FixedParameters but Arima Moving Average coefficients (MA) are also re-estimated, Auto-regressive (AR) coefficients are kept fixed.

FreeParameters: all regression and Arima model coefficients are re-estimated, regression variables and Arima orders are kept fixed.

Outliers: regression variables and Arima orders are kept fixed, but outliers will be re-detected on the defined span, thus all regression and Arima model coefficients are re-estimated

Outliers_StochasticComponent: same as "Outliers" but Arima model orders (p,d,q)(P,D,Q) can also be re-identified.


Read a Reg-Arima specification file

Description

Read a Reg-Arima specification file

Usage

regarima_read_spec(file)

Arguments

file

Write a Reg-Arima specification file

Description

Write a Reg-Arima specification file

Usage

regarima_write_spec(spec, file)

Arguments

file

Replace or Remove a SA-item

Description

replace_sa_item() replaces a SA-item in a SAProcessing and remove_sa_item() removes a SA-item from a SAProcessing

This functions clears a SA-Processing by removing all the SA-items contained.

Usage

replace_sa_item(jsap, idx, jsa)

remove_sa_item(jsap, idx)

remove_all_sa_item(jsap)

transfer_series(jsap_from, jsap_to, selected_series, print_indications = TRUE)

Arguments

jsap

SAProcessing to modify.

idx

index of the target SA-item.

jsa

new SA-item.

jsap_from

SA-Processing from which take the SA-items

jsap_to

SA-Processing to which paste the SA-items

selected_series

vector containing the SA-items names to be updated.

print_indications

A boolean to print indications on the processing status (optional)

Details

If selected_series is missing, all series from jsap_from will be copied. In this context, the word series refers to SA-item.

Value

NULL returned invisibly

NULL returned invisibly


Save Workspace

Description

Function allowing to write a workspace as a collection of xml files readable by JDemetra+ Graphical user interface.

Usage

save_workspace(jws, file, replace = FALSE)

Arguments

jws

Workspace object to export.

file

path where to export the 'JDemetra+' Workspace (.xml file).

replace

boolean indicating if the Workspace should be replaced if it already exists.

Examples

dir <- tempdir()
jws <- .jws_new()
jsap1 <- .jws_sap_new(jws, "sa1")
y <- rjd3toolkit::ABS$X0.2.09.10.M
add_sa_item(jsap1, name = "x13", x = y, rjd3x13::x13_spec())
save_workspace(jws, file.path(dir, "workspace.xml"))

Get/Set SaItem Comment

Description

Get/Set SaItem Comment

Usage

set_comment(jsap, idx, comment)

get_comment(jsa)

Arguments

jsap

SAProcessing to modify.

idx

index of the target SA-item.

comment

character containing the comment.

jsa

a SA-item.


Set Context of a Workspace

Description

Set Context of a Workspace

Usage

set_context(jws, modelling_context = NULL)

Arguments

jws

Workspace object.

modelling_context

a list of variables and calendars


Set the name associated to a SaItem Comment

Description

Set the name associated to a SaItem Comment

Usage

set_name(jsap, idx, name)

Arguments

jsap

SAProcessing to modify.

idx

index of the target SA-item.

name

character containing the name of the SAItem.

See Also

.jsai_name()


Get/Set SaItem Priority

Description

Get/Set SaItem Priority

Usage

set_priority(jsap, idx, priority = 0L)

get_priority(jsa)

Arguments

jsap

SAProcessing to modify.

idx

index of the target SA-item.

priority

integer containing the priority.

jsa

a SA-item.


Get/Set the Raw Data in a SA-item

Description

Get/Set the Raw Data in a SA-item

Usage

set_raw_data(jsap, idx, y)

get_raw_data(jsa)

Arguments

jsap

SAProcessing to modify.

idx

index of the target SA-item.

y

new raw time series.

jsa

a SA-item.


Set Specification or Raw Data in a SaItem

Description

Set Specification or Raw Data in a SaItem

Usage

set_specification(jsap, idx, spec)

set_domain_specification(jsap, idx, spec)

Arguments

jsap

SAProcessing to modify.

idx

index of the target SA-item.

spec

new specification.


Get/Set the time series of a SaItem

Description

Get/Set the time series of a SaItem

Usage

set_ts(jsap, idx, y)

get_ts(jsa)

Arguments

jsap

SAProcessing to modify.

idx

index of the target SA-item.

y

a "full" time series (jd3-like).

jsa

a SA-item.


Set Time Series Metadata of a SaItem

Description

Function to set the time series metadata of a SaItem (provider, source of the data...). set_ts_metadata() uses the metadata of another SaItem while put_ts_metadata() allows to update a specific key with a new information.

Usage

set_ts_metadata(jsap, idx, ref_jsa)

put_ts_metadata(jsap, idx, key, value)

Arguments

jsap

SAProcessing to modify.

idx

index of the target SA-item.

ref_jsa

a reference SaItem containing the metadata.

key

key of the metadata.

value

value of the metadata.

Examples

# Change the file of a given item
file <- system.file("workspaces", "test.xml", package = "rjd3workspace")
jws <- .jws_load(file)
jsap <- .jws_sap(jws, 1)
jsai <- .jsap_sai(jsap, 1)
nid <- rjd3providers::spreadsheet_change_file(.jsai_ts_metadata(jsai, "@id"), "test.xlsx")
put_ts_metadata(jsap, 1, "@id", nid)

jsai <- .jsap_sai(jsap, 1)
.jsai_ts_metadata(jsai, "@id")

Update the path to a spreadsheet specified in a workspace

Description

Update the path to a spreadsheet specified in a workspace

Usage

spreadsheet_update_path(jws, new_path, idx_sap = NULL, idx_sai = NULL)

Arguments

jws

workspace object

new_path

new path to the spreadsheet containing raw data

idx_sap

index (or indices) of the SA-Processing (s) to check

idx_sai

index (or indices) of the SA-Item(s) to check.

Details

The spreadsheet file must be a .xlsx file. .xls file are not accepted in JDemetra+ v3.x.

Value

This function returns either NULL if the update was successful, or an error.

Examples

# ws <- .jws_open(file = "ws_production.xml")
#
# # Update the entire second SA-Processing of the `ws` workspace with a new path
# spreadsheet_update_path(
#     jws = ws,
#     new_path = normalizePath("./data/IPI_nace4.xlsx", mustWork = TRUE),
#     idx_sap = 2L
# )

Read a Tramo specification file

Description

Read a Tramo specification file

Usage

tramo_read_spec(file)

Arguments

file

Write a Tramo specification file

Description

Write a Tramo specification file

Usage

tramo_write_spec(spec, file)

Arguments

file

Read a Tramo-Seats specification file

Description

Read a Tramo-Seats specification file

Usage

tramoseats_read_spec(file)

Arguments

file

Write a Tramo-Seats specification file

Description

Write a Tramo-Seats specification file

Usage

tramoseats_write_spec(spec, file)

Arguments

file

Update the path to a csv/txt file specified in a workspace

Description

Update the path to a csv/txt file specified in a workspace

Usage

txt_update_path(jws, new_path, idx_sap = NULL, idx_sai = NULL)

Arguments

jws

workspace object

new_path

new path to the csv/txt file containing raw data

idx_sap

index (or indices) of the SA-Processing (s) to check

idx_sai

index (or indices) of the SA-Item(s) to check.

Value

This function returns either NULL if the update was successful, or an error

Examples

# ws <- .jws_open(file = "ws_production.xml")
#
# # Update the entire second SA-Processing of the `ws` workspace with a new path
# txt_update_path(
#     jws = ws,
#     new_path = normalizePath("./data/IPI_nace4.csv", mustWork = TRUE),
#     idx_sap = 1L
# )

Write a Calendar file

Description

Write a Calendar file

Usage

write_calendars(calendars, file)

Arguments

file

Write auxiliary variables (regressors) file

Description

Write auxiliary variables (regressors) file

Usage

write_variables(vars, file)

Arguments

file

Read a X13 specification file

Description

Read a X13 specification file

Usage

x13_read_spec(file)

Arguments

file

Write a X13 specification file

Description

Write a X13 specification file

Usage

x13_write_spec(spec, file)

Arguments

file