Package 'SAvalidation'

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

Help Index


Plot adjustment factor

Description

Plot adjustment factor

Usage

adjust_fact_plot(
  nsa,
  sa,
  title = NULL,
  easter_lag = 6,
  julian_easter = FALSE,
  default_type = "X13",
  default_spec_nsa = "RSA2c",
  add_mean = TRUE
)

Arguments

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

Value

A plot of derived adjustment factors

Examples

data(data_to_check, package = "SAvalidation")
adjust_fact_plot(data_to_check$nsa,data_to_check$sa)

Plot of relative difference of annual totals

Description

Plot of relative difference of annual totals

Usage

annual_totals_plot(nsa, sa, title = NULL)

Arguments

nsa

ts object (usually unadjusted time series)

sa

ts object (usually seasonally adjusted time series)

title

optional title

Value

A plot of the relative difference of annual totals between nsa and sa

Examples

data(data_to_check, package = "SAvalidation")
annual_totals_plot(data_to_check$nsa,data_to_check$sa)

Plot of calendar effects

Description

Plot of calendar effects

Usage

cal_effect_plot(
  nsa,
  sa,
  sa_mod,
  title = NULL,
  default_type = "X13",
  default_spec_nsa = "RSA2c"
)

Arguments

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

Value

A plot of calendar effects and derived adjusted effects

Examples

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

Description

Extract test for calendar effects

Usage

check_for_calendar_vars(sa_mod)

Arguments

sa_mod

An SA object from RJDemetra

Value

A logical indicating whether calendar regressors found in the SA model object

Examples

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

Description

Check if two series are identical

Usage

check_identical(nsa, sa)

Arguments

nsa

A ts object

sa

A ts object

Value

Logical TRUE if all(nsa==sa)

Examples

data(data_to_check)
check_identical(data_to_check$nsa,data_to_check$sa)

Check for negatives

Description

Check for negatives

Usage

check_negatives(series_to_check)

Arguments

series_to_check

A numeric vector (or matrix) to check for any negative values

Value

Logical TRUE if any negative values exist

Examples

data(data_to_check)
check_negatives(data_to_check$nsa)

Check nsa and sa are univariate time series of same period

Description

Check nsa and sa are univariate time series of same period

Usage

check_nsa_sa_ts(nsa, sa)

Arguments

nsa

ts object

sa

ts object

Value

stops if problem with nsa and sa time series

Examples

data(data_to_check)
check_nsa_sa_ts(data_to_check$nsa,data_to_check$sa)

Check for over adjustment

Description

Tests null hypothesis that acf at lag 4 is greater or equal to zero

Usage

check_over_adjustment(sa_mod, pval = 0.05)

Arguments

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)

Value

Logical evidence of

Examples

data(data_to_check)
sa <- data_to_check$sa
jd_mod <- RJDemetra::x13(sa)
check_over_adjustment(jd_mod)

Example data for validation

Description

Example data for validation

Format

list object with name, nsa and sa time series


Extract combined test for seasonality on linearised series

Description

Extract combined test for seasonality on linearised series

Usage

get_combined_seasonality_test(sa_mod)

Arguments

sa_mod

An SA object from RJDemetra

Value

A character vector stating the final result of the combined test for seasonality

Examples

data(data_to_check)
nsa <- data_to_check$nsa
jd_mod <- RJDemetra::jx13(nsa)
get_combined_seasonality_test(jd_mod)

Level 1 validation check

Description

Level 1 validation check

Usage

level1_validation(
  nsa,
  sa,
  default_type = "X13",
  default_spec_nsa = "RSA1",
  default_spec_sa = "RSA2c"
)

Arguments

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

Value

Message about the level 1 validation (pass, pass with warnings or fail)

Examples

data(data_to_check)
level1_validation(data_to_check$nsa,data_to_check$sa)

Level 2 validation

Description

Level 2 validation

Usage

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

Arguments

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

Value

creates an html dashboard with series name in given output directory

Examples

data(data_to_check, package = "SAvalidation")
level2_validation(data_to_check$nsa,data_to_check$sa,data_to_check$name)

Level 3 comparison plot

Description

Level 3 comparison plot

Usage

level3_comparisons_plot(
  nsa,
  sa,
  series_name,
  default_spec_nsa = "RSA1",
  test_level = 0.01,
  java_home = Sys.getenv("JAVA_HOME")
)

Arguments

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

Value

a ggplot object showing the published SA series and some approximate confidence intervals


Level 3 validation

Description

Level 3 validation

Usage

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

Arguments

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

Value

creates an html document with series name in given output directory

Examples

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

Description

Plot nsa and sa

Usage

nsa_sa_plot(nsa, sa, title = NULL)

Arguments

nsa

ts object (usually unadjusted time series)

sa

ts object (usually seasonally adjusted time series)

title

Optional title

Value

ggplot of nsa and sa series

Examples

data(data_to_check)
nsa_sa_plot(data_to_check$nsa,data_to_check$sa)