Skip to contents

To extract a quality report from the csv file containing the diagnostics matrix.

Usage

extract_QR(
  file,
  x,
  matrix_output_file,
  sep = ";",
  dec = ",",
  thresholds = getOption("jdc_thresholds")
)

Arguments

file

the csv file containing the diagnostics matrix. This argument supersedes the argument matrix_output_file.

x

data.frame containing the diagnostics matrix.

matrix_output_file

the csv file containing the diagnostics matrix.

sep

the separator used in the csv file (by default, sep = ";")

dec

the decimal separator used in the csv file (by default, dec = ",")

thresholds

list of numerical vectors. Thresholds applied to the various tests in order to classify into modalities Good, Uncertain, Bad and Severe. By default, the value of the "jdc_threshold" option is used. You can call the get_thresholds function to see what the thresholds object should look like.

Value

a QR_matrix object.

Details

This function generates a quality report from a csv file containing diagnostics (usually from the file demetra_m.csv). The demetra_m.csv file can be generated by launching the cruncher (functions cruncher or cruncher_and_param) with the default export parameters, having used the default option csv_layout = "vtable" to format the output tables of the functions cruncher_and_param and create_param_file when creating the parameters file.

This function returns a QR_matrix object, which is a list of 3 objects:

  • modalities, a data.frame containing several indicators and their categorical quality (Good, Uncertain, Bad, Severe).

  • values, a data.frame containing the same indicators and the values that lead to their quality category (i.e.: p-values, statistics, etc.) as well as additional variables that don't have a modality/quality (series frequency and arima model).

  • score_formula that will store the formula used to calculate the score (when relevant). Its initial value is NULL.

If x is supplied, the file and matrix_output_file arguments are ignored. The file argument also designates the path to the file containing the diagnostic matrix (which can be imported into R in parallel and used with the x argument).

Examples

# Path of matrix demetra_m
demetra_path <- file.path(
    system.file("extdata", package = "JDCruncheR"),
    "WS/ws_ipi/Output/SAProcessing-1",
    "demetra_m.csv"
)

# Extract the quality report from the demetra_m file
QR <- extract_QR(file = demetra_path)
#> Multiple column found for extraction of q statistic
#> first column selected

print(QR)
#> The quality report matrix has 13 observations
#> There are 18 indicators in the modalities matrix and 20 indicators in the values matrix
#> 
#> The quality report matrix contains the following variables:
#> series  residuals_homoskedasticity  residuals_skewness  residuals_kurtosis  residuals_normality  residuals_independency  qs_residual_sa_on_sa  f_residual_sa_on_sa  qs_residual_sa_on_i  f_residual_sa_on_i  f_residual_td_on_sa  f_residual_td_on_i  oos_mean  oos_mse  q  q_m2  m7  pct_outliers  frequency  arima_model
#> 
#> The variables exclusively found in the values matrix are:
#> frequency  arima_model
#> 
#> No score was calculated

# Extract the modalities matrix:
QR[["modalities"]]
#>    series residuals_homoskedasticity residuals_skewness residuals_kurtosis
#> 1  RF0610                  Uncertain               Good               Good
#> 2  RF0620                       Good                Bad                Bad
#> 3  RF0811                  Uncertain                Bad                Bad
#> 4  RF0812                        Bad               Good          Uncertain
#> 5  RF0893                       Good               Good               Good
#> 6  RF0899                       Good               Good               Good
#> 7  RF1011                       Good               Good               Good
#> 8  RF1012                       Good               Good               Good
#> 9  RF1013                        Bad                Bad                Bad
#> 10 RF1020                        Bad               Good          Uncertain
#> 11 RF1031                        Bad          Uncertain                Bad
#> 12 RF1032                       Good               Good               Good
#> 13 RF1039                        Bad          Uncertain                Bad
#>    residuals_normality residuals_independency qs_residual_sa_on_sa
#> 1                 Good                   Good                 Good
#> 2                  Bad                   Good                 Good
#> 3                  Bad                    Bad                 Good
#> 4                 Good                    Bad                 Good
#> 5                 Good              Uncertain                 Good
#> 6                 Good                    Bad                 Good
#> 7                 Good                    Bad               Severe
#> 8                 Good                    Bad               Severe
#> 9                  Bad                    Bad                  Bad
#> 10           Uncertain                    Bad               Severe
#> 11                 Bad                    Bad                  Bad
#> 12                Good                    Bad                 Good
#> 13                 Bad                    Bad               Severe
#>    f_residual_sa_on_sa qs_residual_sa_on_i f_residual_sa_on_i
#> 1                 Good                Good               Good
#> 2                 Good                Good               Good
#> 3                 Good                Good               Good
#> 4                 Good                Good               Good
#> 5                 Good                Good               Good
#> 6                 Good                Good               Good
#> 7                 Good              Severe               Good
#> 8                 Good              Severe               Good
#> 9                 Good                 Bad               Good
#> 10                Good                 Bad               Good
#> 11                Good           Uncertain               Good
#> 12                Good                Good               Good
#> 13                Good                 Bad               Good
#>    f_residual_td_on_sa f_residual_td_on_i oos_mean   oos_mse    q q_m2   m7
#> 1                  Bad          Uncertain     Good       Bad Good Good Good
#> 2                 Good               Good     Good       Bad Good Good Good
#> 3               Severe                Bad     Good Uncertain  Bad  Bad Good
#> 4               Severe             Severe     Good      Good Good Good Good
#> 5                 Good               Good     Good      Good  Bad  Bad Good
#> 6                  Bad                Bad     Good      Good Good Good Good
#> 7               Severe             Severe     Good      Good  Bad  Bad Good
#> 8               Severe             Severe     Good      Good  Bad  Bad Good
#> 9               Severe             Severe     Good      Good  Bad  Bad  Bad
#> 10              Severe             Severe     Good Uncertain Good  Bad Good
#> 11           Uncertain          Uncertain     Good       Bad Good Good Good
#> 12              Severe             Severe     Good      Good  Bad  Bad Good
#> 13              Severe             Severe     Good Uncertain Good Good Good
#>    pct_outliers
#> 1     Uncertain
#> 2           Bad
#> 3          Good
#> 4          Good
#> 5          Good
#> 6          Good
#> 7          Good
#> 8          Good
#> 9          Good
#> 10         Good
#> 11    Uncertain
#> 12         Good
#> 13         Good
# Or:
QR[["modalities"]]
#>    series residuals_homoskedasticity residuals_skewness residuals_kurtosis
#> 1  RF0610                  Uncertain               Good               Good
#> 2  RF0620                       Good                Bad                Bad
#> 3  RF0811                  Uncertain                Bad                Bad
#> 4  RF0812                        Bad               Good          Uncertain
#> 5  RF0893                       Good               Good               Good
#> 6  RF0899                       Good               Good               Good
#> 7  RF1011                       Good               Good               Good
#> 8  RF1012                       Good               Good               Good
#> 9  RF1013                        Bad                Bad                Bad
#> 10 RF1020                        Bad               Good          Uncertain
#> 11 RF1031                        Bad          Uncertain                Bad
#> 12 RF1032                       Good               Good               Good
#> 13 RF1039                        Bad          Uncertain                Bad
#>    residuals_normality residuals_independency qs_residual_sa_on_sa
#> 1                 Good                   Good                 Good
#> 2                  Bad                   Good                 Good
#> 3                  Bad                    Bad                 Good
#> 4                 Good                    Bad                 Good
#> 5                 Good              Uncertain                 Good
#> 6                 Good                    Bad                 Good
#> 7                 Good                    Bad               Severe
#> 8                 Good                    Bad               Severe
#> 9                  Bad                    Bad                  Bad
#> 10           Uncertain                    Bad               Severe
#> 11                 Bad                    Bad                  Bad
#> 12                Good                    Bad                 Good
#> 13                 Bad                    Bad               Severe
#>    f_residual_sa_on_sa qs_residual_sa_on_i f_residual_sa_on_i
#> 1                 Good                Good               Good
#> 2                 Good                Good               Good
#> 3                 Good                Good               Good
#> 4                 Good                Good               Good
#> 5                 Good                Good               Good
#> 6                 Good                Good               Good
#> 7                 Good              Severe               Good
#> 8                 Good              Severe               Good
#> 9                 Good                 Bad               Good
#> 10                Good                 Bad               Good
#> 11                Good           Uncertain               Good
#> 12                Good                Good               Good
#> 13                Good                 Bad               Good
#>    f_residual_td_on_sa f_residual_td_on_i oos_mean   oos_mse    q q_m2   m7
#> 1                  Bad          Uncertain     Good       Bad Good Good Good
#> 2                 Good               Good     Good       Bad Good Good Good
#> 3               Severe                Bad     Good Uncertain  Bad  Bad Good
#> 4               Severe             Severe     Good      Good Good Good Good
#> 5                 Good               Good     Good      Good  Bad  Bad Good
#> 6                  Bad                Bad     Good      Good Good Good Good
#> 7               Severe             Severe     Good      Good  Bad  Bad Good
#> 8               Severe             Severe     Good      Good  Bad  Bad Good
#> 9               Severe             Severe     Good      Good  Bad  Bad  Bad
#> 10              Severe             Severe     Good Uncertain Good  Bad Good
#> 11           Uncertain          Uncertain     Good       Bad Good Good Good
#> 12              Severe             Severe     Good      Good  Bad  Bad Good
#> 13              Severe             Severe     Good Uncertain Good Good Good
#>    pct_outliers
#> 1     Uncertain
#> 2           Bad
#> 3          Good
#> 4          Good
#> 5          Good
#> 6          Good
#> 7          Good
#> 8          Good
#> 9          Good
#> 10         Good
#> 11    Uncertain
#> 12         Good
#> 13         Good