Title: | Validation checks on seasonally adjusted time series |
---|---|
Description: | Functions for running validation checks on a pair of time series, an unadjsuted (NSA) and seasonally adjusted (SA) series. |
Authors: | Duncan Elliott [aut, cre], Alain Quartier-la-Tente [aut] |
Maintainer: | Duncan Elliott <[email protected]> |
License: | EUPL+ file LICENSE |
Version: | 0.0.1.8 |
Built: | 2024-11-12 00:56:19 UTC |
Source: | https://github.com/SeasAdjwG/SAvalidation |
Plot adjustment factor
adjust_fact_plot( nsa, sa, title = NULL, easter_lag = 6, julian_easter = FALSE, default_type = "X13", default_spec_nsa = "RSA2c", add_mean = TRUE )
adjust_fact_plot( nsa, sa, title = NULL, easter_lag = 6, julian_easter = FALSE, default_type = "X13", default_spec_nsa = "RSA2c", add_mean = TRUE )
nsa |
ts object (usually unadjusted time series) |
sa |
ts object (usually seasonally adjusted time series) |
title |
optional title |
easter_lag |
integer defining the number of days before Easter Sunday to create the Easter window |
julian_easter |
logical, should EAster be a Julian Easter, default FALSE |
default_type |
values should be "X13" or "TS" to define whether X13 or TRAMO-SEATS is used to test for decomposition mode |
default_spec_nsa |
name of a default JDemetra+ specification to use for determining decomposition mode (default is "RSA2c") |
add_mean |
boolean indicating if the mean by quarter should be added |
A plot of derived adjustment factors
data(data_to_check, package = "SAvalidation") adjust_fact_plot(data_to_check$nsa,data_to_check$sa)
data(data_to_check, package = "SAvalidation") adjust_fact_plot(data_to_check$nsa,data_to_check$sa)
Plot of relative difference of annual totals
annual_totals_plot(nsa, sa, title = NULL)
annual_totals_plot(nsa, sa, title = NULL)
nsa |
ts object (usually unadjusted time series) |
sa |
ts object (usually seasonally adjusted time series) |
title |
optional title |
A plot of the relative difference of annual totals between nsa and sa
data(data_to_check, package = "SAvalidation") annual_totals_plot(data_to_check$nsa,data_to_check$sa)
data(data_to_check, package = "SAvalidation") annual_totals_plot(data_to_check$nsa,data_to_check$sa)
Plot of calendar effects
cal_effect_plot( nsa, sa, sa_mod, title = NULL, default_type = "X13", default_spec_nsa = "RSA2c" )
cal_effect_plot( nsa, sa, sa_mod, title = NULL, default_type = "X13", default_spec_nsa = "RSA2c" )
nsa |
ts object (usually unadjusted time series) |
sa |
ts object (usually seasonally adjusted time series) |
sa_mod |
An SA object from RJDemetra |
title |
optional title |
default_type |
values should be "X13" or "TS" to define whether X13 or TRAMO-SEATS is used to test for decomposition mode |
default_spec_nsa |
name of a default JDemetra+ specification to use for determining decomposition mode (default is "RSA2c") |
A plot of calendar effects and derived adjusted effects
test_sa_mod <- RJDemetra::x13(data_to_check$sa, spec="RSA2c", userdefined = RJDemetra::user_defined_variables("X13-ARIMA")) cal_effect_plot(data_to_check$nsa,data_to_check$sa,test_sa_mod)
test_sa_mod <- RJDemetra::x13(data_to_check$sa, spec="RSA2c", userdefined = RJDemetra::user_defined_variables("X13-ARIMA")) cal_effect_plot(data_to_check$nsa,data_to_check$sa,test_sa_mod)
Extract test for calendar effects
check_for_calendar_vars(sa_mod)
check_for_calendar_vars(sa_mod)
sa_mod |
An SA object from RJDemetra |
A logical indicating whether calendar regressors found in the SA model object
data(data_to_check) nsa <- data_to_check$nsa jd_mod <- RJDemetra::x13(nsa) check_for_calendar_vars(jd_mod)
data(data_to_check) nsa <- data_to_check$nsa jd_mod <- RJDemetra::x13(nsa) check_for_calendar_vars(jd_mod)
Check if two series are identical
check_identical(nsa, sa)
check_identical(nsa, sa)
nsa |
A ts object |
sa |
A ts object |
Logical TRUE if all(nsa==sa)
data(data_to_check) check_identical(data_to_check$nsa,data_to_check$sa)
data(data_to_check) check_identical(data_to_check$nsa,data_to_check$sa)
Check for negatives
check_negatives(series_to_check)
check_negatives(series_to_check)
series_to_check |
A numeric vector (or matrix) to check for any negative values |
Logical TRUE if any negative values exist
data(data_to_check) check_negatives(data_to_check$nsa)
data(data_to_check) check_negatives(data_to_check$nsa)
Check nsa and sa are univariate time series of same period
check_nsa_sa_ts(nsa, sa)
check_nsa_sa_ts(nsa, sa)
nsa |
ts object |
sa |
ts object |
stops if problem with nsa and sa time series
data(data_to_check) check_nsa_sa_ts(data_to_check$nsa,data_to_check$sa)
data(data_to_check) check_nsa_sa_ts(data_to_check$nsa,data_to_check$sa)
Tests null hypothesis that acf at lag 4 is greater or equal to zero
check_over_adjustment(sa_mod, pval = 0.05)
check_over_adjustment(sa_mod, pval = 0.05)
sa_mod |
An SA object from RJDemetra generated with userdefined="preprocessing.model.y_lin" |
pval |
numeric value used to define a p-value to use as a threshold for accepting/rejecting null hypothesis (default 0.05) |
Logical evidence of
data(data_to_check) sa <- data_to_check$sa jd_mod <- RJDemetra::x13(sa) check_over_adjustment(jd_mod)
data(data_to_check) sa <- data_to_check$sa jd_mod <- RJDemetra::x13(sa) check_over_adjustment(jd_mod)
Example data for validation
list object with name, nsa and sa time series
Extract combined test for seasonality on linearised series
get_combined_seasonality_test(sa_mod)
get_combined_seasonality_test(sa_mod)
sa_mod |
An SA object from RJDemetra |
A character vector stating the final result of the combined test for seasonality
data(data_to_check) nsa <- data_to_check$nsa jd_mod <- RJDemetra::jx13(nsa) get_combined_seasonality_test(jd_mod)
data(data_to_check) nsa <- data_to_check$nsa jd_mod <- RJDemetra::jx13(nsa) get_combined_seasonality_test(jd_mod)
Level 1 validation check
level1_validation( nsa, sa, default_type = "X13", default_spec_nsa = "RSA1", default_spec_sa = "RSA2c" )
level1_validation( nsa, sa, default_type = "X13", default_spec_nsa = "RSA1", default_spec_sa = "RSA2c" )
nsa |
A ts object |
sa |
A ts object |
default_type |
Character must be either "X13" (default) or "TS" determining whether X13 or TRAMO-SEATS is used for testing |
default_spec_nsa |
Character defining the JDemetra+ specification for tests on the nsa series (default="RSA1") |
default_spec_sa |
Character defining the JDemetra+ specification for tests on the sa series (default="RSA2c") |
Message about the level 1 validation (pass, pass with warnings or fail)
data(data_to_check) level1_validation(data_to_check$nsa,data_to_check$sa)
data(data_to_check) level1_validation(data_to_check$nsa,data_to_check$sa)
Level 2 validation
level2_validation( nsa, sa, series_name, dataset_name = "National Accounts Main Aggregates", title = series_name, output_directory = NULL, dashboard_template = "skeleton.qmd", start_date = "1999-01-01", default_type = "X13", default_spec_nsa = "RSA2c", default_spec_sa = "RSA2c", java_home = Sys.getenv("JAVA_HOME") )
level2_validation( nsa, sa, series_name, dataset_name = "National Accounts Main Aggregates", title = series_name, output_directory = NULL, dashboard_template = "skeleton.qmd", start_date = "1999-01-01", default_type = "X13", default_spec_nsa = "RSA2c", default_spec_sa = "RSA2c", java_home = Sys.getenv("JAVA_HOME") )
nsa |
ts object (usually unadjusted time series) |
sa |
ts object (usually seasonally adjusted time series) |
series_name |
a name for the time series to be analysed |
dataset_name |
a name for the dataset |
title |
title |
output_directory |
optional output directory for dashboard (default uses getwd()) |
dashboard_template |
name of dashboard template to use |
start_date |
Character defining start date in format "YYYY-MM-DD" |
default_type |
values should be "X13" or "TS" to define whether X13 or TRAMO-SEATS is used to test for decomposition mode |
default_spec_nsa |
name of a default JDemetra+ specification to use for tests on NSA series (default is "RSA2c") |
default_spec_sa |
name of a default JDemetra+ specification to use for tests on SA series (default is "RSA2c") |
java_home |
JAVA_HOME environment variable |
creates an html dashboard with series name in given output directory
data(data_to_check, package = "SAvalidation") level2_validation(data_to_check$nsa,data_to_check$sa,data_to_check$name)
data(data_to_check, package = "SAvalidation") level2_validation(data_to_check$nsa,data_to_check$sa,data_to_check$name)
Level 3 comparison plot
level3_comparisons_plot( nsa, sa, series_name, default_spec_nsa = "RSA1", test_level = 0.01, java_home = Sys.getenv("JAVA_HOME") )
level3_comparisons_plot( nsa, sa, series_name, default_spec_nsa = "RSA1", test_level = 0.01, java_home = Sys.getenv("JAVA_HOME") )
nsa |
ts object (usually unadjusted time series) |
sa |
ts object (usually seasonally adjusted time series) |
default_spec_nsa |
name of a default JDemetra+ specification to use for determining decomposition mode (default is "RSA1") |
test_level |
significance level for tests (default is 0.01) |
java_home |
|
sa_mod |
An SA object from RJDemetra |
a ggplot object showing the published SA series and some approximate confidence intervals
Level 3 validation
level3_validation( nsa, sa, series_name, vintages = NULL, dataset_name = NULL, title = series_name, output_directory = NULL, dashboard_template = "skeleton3.qmd", default_type = "X13", default_spec_nsa = "RSA2c", default_spec_sa = "RSA2c", java_home = Sys.getenv("JAVA_HOME") )
level3_validation( nsa, sa, series_name, vintages = NULL, dataset_name = NULL, title = series_name, output_directory = NULL, dashboard_template = "skeleton3.qmd", default_type = "X13", default_spec_nsa = "RSA2c", default_spec_sa = "RSA2c", java_home = Sys.getenv("JAVA_HOME") )
nsa |
ts object (usually unadjusted time series) |
sa |
ts object (usually seasonally adjusted time series) |
series_name |
a name for the time series to be analysed |
vintages |
a list object with two elements, nsa_vert and sa_vert, each of which is a matrix with columns as dates and rows as vintages |
dataset_name |
a name for the dataset |
title |
title |
output_directory |
optional output directory for dashboard (default uses getwd()) |
dashboard_template |
name of dashboard template to use |
default_type |
values should be "X13" or "TS" to define whether X13 or TRAMO-SEATS is used to test for decomposition mode |
default_spec_nsa |
name of a default JDemetra+ specification to use for tests on NSA series (default is "RSA2c") |
java_home |
JAVA_HOME environment variable |
creates an html document with series name in given output directory
data(vintages, package = "SAvalidation") nsa <- ts(vintages$nsa_vert[,"2024-01-01"], start=1999, frequency = 4) sa <- ts(vintages$sa_vert[,"2024-01-01"], start=1999, frequency = 4) level3_validation(nsa,sa,"test",vintages)
data(vintages, package = "SAvalidation") nsa <- ts(vintages$nsa_vert[,"2024-01-01"], start=1999, frequency = 4) sa <- ts(vintages$sa_vert[,"2024-01-01"], start=1999, frequency = 4) level3_validation(nsa,sa,"test",vintages)
Plot nsa and sa
nsa_sa_plot(nsa, sa, title = NULL)
nsa_sa_plot(nsa, sa, title = NULL)
nsa |
ts object (usually unadjusted time series) |
sa |
ts object (usually seasonally adjusted time series) |
title |
Optional title |
ggplot of nsa and sa series
data(data_to_check) nsa_sa_plot(data_to_check$nsa,data_to_check$sa)
data(data_to_check) nsa_sa_plot(data_to_check$nsa,data_to_check$sa)