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)

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  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  residuals_independency  residuals_normality  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                       Good               Good               Good
#> 2  RF0620                        Bad                Bad                Bad
#> 3  RF0811                        Bad                Bad                Bad
#> 4  RF0812                       Good               Good               Good
#> 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                       Good               Good               Good
#> 11 RF1031                  Uncertain          Uncertain          Uncertain
#> 12 RF1032                       Good               Good               Good
#> 13 RF1039                  Uncertain          Uncertain          Uncertain
#>    qs_residual_sa_on_sa f_residual_sa_on_sa qs_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              Severe                Good
#> 11                 Good                 Bad                Good
#> 12                 Good                Good                Good
#> 13                 Good              Severe                Good
#>    f_residual_sa_on_i f_residual_td_on_sa f_residual_td_on_i
#> 1                Good           Uncertain               Good
#> 2                Good                Good               Good
#> 3                Good              Severe             Severe
#> 4                Good              Severe             Severe
#> 5                Good                Good               Good
#> 6                Good              Severe             Severe
#> 7              Severe              Severe             Severe
#> 8              Severe              Severe             Severe
#> 9                 Bad              Severe             Severe
#> 10                Bad              Severe             Severe
#> 11          Uncertain              Severe             Severe
#> 12               Good              Severe             Severe
#> 13                Bad              Severe                Bad
#>    residuals_independency residuals_normality  oos_mean   oos_mse    q q_m2
#> 1                    Good                Good      Good       Bad Good Good
#> 2                    Good                 Bad       Bad       Bad Good Good
#> 3                     Bad                 Bad      Good Uncertain  Bad  Bad
#> 4                     Bad                Good      Good      Good Good Good
#> 5               Uncertain                Good       Bad      Good  Bad  Bad
#> 6                     Bad                Good       Bad      Good Good Good
#> 7                     Bad                Good      Good      Good  Bad  Bad
#> 8                     Bad                Good       Bad      Good  Bad  Bad
#> 9                     Bad                 Bad       Bad      Good  Bad  Bad
#> 10                    Bad           Uncertain       Bad Uncertain Good  Bad
#> 11                    Bad                 Bad Uncertain       Bad Good Good
#> 12                    Bad                Good       Bad      Good  Bad  Bad
#> 13                    Bad                 Bad       Bad Uncertain Good Good
#>      m7 pct_outliers
#> 1  Good    Uncertain
#> 2  Good          Bad
#> 3  Good         Good
#> 4  Good         Good
#> 5  Good         Good
#> 6  Good         Good
#> 7  Good         Good
#> 8  Good         Good
#> 9   Bad         Good
#> 10 Good         Good
#> 11 Good    Uncertain
#> 12 Good         Good
#> 13 Good         Good
# Or:
QR[["modalities"]]
#>    series residuals_homoskedasticity residuals_skewness residuals_kurtosis
#> 1  RF0610                       Good               Good               Good
#> 2  RF0620                        Bad                Bad                Bad
#> 3  RF0811                        Bad                Bad                Bad
#> 4  RF0812                       Good               Good               Good
#> 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                       Good               Good               Good
#> 11 RF1031                  Uncertain          Uncertain          Uncertain
#> 12 RF1032                       Good               Good               Good
#> 13 RF1039                  Uncertain          Uncertain          Uncertain
#>    qs_residual_sa_on_sa f_residual_sa_on_sa qs_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              Severe                Good
#> 11                 Good                 Bad                Good
#> 12                 Good                Good                Good
#> 13                 Good              Severe                Good
#>    f_residual_sa_on_i f_residual_td_on_sa f_residual_td_on_i
#> 1                Good           Uncertain               Good
#> 2                Good                Good               Good
#> 3                Good              Severe             Severe
#> 4                Good              Severe             Severe
#> 5                Good                Good               Good
#> 6                Good              Severe             Severe
#> 7              Severe              Severe             Severe
#> 8              Severe              Severe             Severe
#> 9                 Bad              Severe             Severe
#> 10                Bad              Severe             Severe
#> 11          Uncertain              Severe             Severe
#> 12               Good              Severe             Severe
#> 13                Bad              Severe                Bad
#>    residuals_independency residuals_normality  oos_mean   oos_mse    q q_m2
#> 1                    Good                Good      Good       Bad Good Good
#> 2                    Good                 Bad       Bad       Bad Good Good
#> 3                     Bad                 Bad      Good Uncertain  Bad  Bad
#> 4                     Bad                Good      Good      Good Good Good
#> 5               Uncertain                Good       Bad      Good  Bad  Bad
#> 6                     Bad                Good       Bad      Good Good Good
#> 7                     Bad                Good      Good      Good  Bad  Bad
#> 8                     Bad                Good       Bad      Good  Bad  Bad
#> 9                     Bad                 Bad       Bad      Good  Bad  Bad
#> 10                    Bad           Uncertain       Bad Uncertain Good  Bad
#> 11                    Bad                 Bad Uncertain       Bad Good Good
#> 12                    Bad                Good       Bad      Good  Bad  Bad
#> 13                    Bad                 Bad       Bad Uncertain Good Good
#>      m7 pct_outliers
#> 1  Good    Uncertain
#> 2  Good          Bad
#> 3  Good         Good
#> 4  Good         Good
#> 5  Good         Good
#> 6  Good         Good
#> 7  Good         Good
#> 8  Good         Good
#> 9   Bad         Good
#> 10 Good         Good
#> 11 Good    Uncertain
#> 12 Good         Good
#> 13 Good         Good