This function updates a Demetra+ workspace (.xml) by assigning user-defined trading day regressors (CJO) to each seasonal adjustment model (SAI), based on an external classification (typically created with retrieve_cjo()).

The function modifies the domainSpec of each series by setting tradingdays to "UserDefined" with the appropriate regressors (REG1REG6, optionally with LY for leap year).

affect_cjo(cjo, ws_path)

Arguments

cjo

[data.frame] A data.frame with at least two columns:

  • series: names of the series in the workspace.

  • regs: the standard INSEE CJO set (REG1, REG2, …, REG6, with or without _LY).

Typically this table is produced by retrieve_cjo().

ws_path

[character] Path to a Demetra+ workspace file (usually with extension .xml).

Value

Invisibly returns NULL. The workspace file at ws_path is updated on disk with the new CJO regressors.

Details

For each series in the workspace:

  • the function looks up its assigned regs in the cjo table,

  • translates the label (REG1, REG2, …) into the corresponding user-defined regressors (e.g. r.REG1_Semaine, r.REG5_Lundi, …),

  • updates the domainSpec with set_tradingdays(option = "UserDefined", ...),

  • saves the modified workspace.

The file is overwritten in place (replace = TRUE).

Examples

if (FALSE) { # \dontrun{
# Load a workspace and apply INSEE CJO sets
cjo_table <- retrieve_cjo("workspace.xml")
affect_cjo(cjo = cjo_table, ws_path = "workspace.xml")
} # }