Skip to contents

This family of functions reconstructs executable R code from a X13 specification object. the generated code uses only the packages {rjd3toolkit} and {rjd3x13}.

The main entry point is rev_spec(), which aggregates all reverse-generating helpers.

Usage

rev_spec(x)

Arguments

x

A JDemetra+ specification object

Value

Each rev_XXX() function returns a character string containing executable R code. rev_spec() returns a complete multi-line pipeline.

Details

The functions are taking a specification (argument x ) as input and returns A corresponding code that generates the object x.

rev_spec() is the main function and calls all other helper functions (rev_XXX). These helper functions (auxiliary functions) do NOT provide sufficient code to reproduce the specification, but only the part dedicated to them (outliers, trading days regressors, x11 filters, etc.).

The generated code is neither unique nor optimal.

That is, different codes (other than the one generated by rev_spec) can generate the same specification. It is not optimal because it does not use the default values of the functions but clearly redefines all the parameters.

Examples


spec_init <- rjd3x13::x13_spec("RSA3") |>
    rjd3toolkit::set_basic(type = "All") |>
    rjd3toolkit::set_automodel(enabled = FALSE)
code <- rev_spec(spec_init)
cat(code)
#> rjd3x13::x13_spec() |>
#> 	 rjd3x13::set_x11(
#> 		mode = "UNDEFINED",
#> 		bias = NA,
#> 		lsigma = 1.5,
#> 		usigma = 2.5,
#> 		fcasts = -1L,
#> 		bcasts = 0L,
#> 		seasonal.comp = TRUE,
#> 		henderson.filter = 0L,
#> 		seasonal.filter = "MSR",
#> 		calendar.sigma = "NONE",
#> 		exclude.forecast = FALSE
#> 	) |>
#> 	rjd3toolkit::set_automodel(
#> 		enabled = FALSE,
#> 		tsig = 1,
#> 		ubfinal = 1.05,
#> 		ub1 = 1.0309278350515465,
#> 		ub2 = 1.1363636363636365,
#> 		cancel = 0.1,
#> 		mixed = TRUE,
#> 		balanced = FALSE,
#> 		acceptdefault = FALSE,
#> 		ljungboxlimit = 0.95,
#> 		reducecv = 0.14286
#> 	) |>
#> 	rjd3toolkit::set_arima(
#> 		d = 1L,
#> 		bd = 1L,
#> 		q = 1L,
#> 		coef = c(0, 0),
#> 		coef.type = c("UNDEFINED", "UNDEFINED"),
#> 		bq = 1L
#> 	) |>
#> 	rjd3toolkit::set_transform(
#> 		adjust = "NONE",
#> 		aicdiff = -2,
#> 		outliers = FALSE,
#> 		fun = "AUTO"
#> 	) |>
#> 	rjd3toolkit::set_easter(
#> 		duration = 8L,
#> 		test = "NO",
#> 		enabled = FALSE
#> 	) |>
#> 	rjd3toolkit::set_basic(
#> 		preprocessing = TRUE,
#> 		preliminary.check = TRUE,
#> 		type = "ALL",
#> 		d0 = NULL,
#> 		d1 = NULL,
#> 		n0 = 0L,
#> 		n1 = 0L
#> 	) |>
#> 	rjd3toolkit::set_estimate(
#> 		tol = 1e-07,
#> 		type = "ALL",
#> 		d0 = NULL,
#> 		d1 = NULL,
#> 		n0 = 0L,
#> 		n1 = 0L
#> 	) |>
#> 	rjd3toolkit::set_outlier(
#> 		method = "ADDONE",
#> 		maxiter = 30L,
#> 		lsrun = 0L,
#> 		d0 = NULL,
#> 		d1 = NULL,
#> 		n0 = 0L,
#> 		n1 = 0L,
#> 		outliers.type = c("AO", "LS", "TC"),
#> 		critical.value = numeric(3),
#> 		tc.rate = 0.7,
#> 		span.type = "ALL"
#> 	) |>
#> 	rjd3toolkit::set_tradingdays(
#> 		test = "NO",
#> 		autoadjust = FALSE,
#> 		calendar.name = "",
#> 		automatic = "UNUSED",
#> 		option = "NONE",
#> 		leapyear = "NONE",
#> 		stocktd = 0L,
#> 		uservariable = character(0)
#> 	) |>
#> 	rjd3toolkit::set_benchmarking(
#> 		enabled = FALSE,
#> 		target = "CALENDARADJUSTED",
#> 		lambda = 1,
#> 		rho = 1,
#> 		bias = "NONE",
#> 		forecast = FALSE
#> 	)
spec_rebuilt <- eval(parse(text = code))