| Title: | 'JDemetra+' Quality Report Generator |
|---|---|
| Description: | Tool for generating quality reports from cruncher outputs (and calculating series scores). The latest version of the cruncher can be downloaded here: <https://github.com/jdemetra/jwsacruncher/releases>. |
| Authors: | Tanguy Barthelemy [aut, cre, art], Eulalie Delaune [aut], Alain Quartier-la-Tente [aut] (ORCID: <https://orcid.org/0000-0001-7890-3857>), Institut national de la statistique et des études économiques [cph] (https://www.insee.fr/), Anna Smyk [aut] |
| Maintainer: | Tanguy Barthelemy <[email protected]> |
| License: | EUPL |
| Version: | 0.4.1 |
| Built: | 2026-07-23 15:57:16 UTC |
| Source: | https://github.com/inseefr/rjd3qr |
To calculate a score for each series from a quality report
## S3 method for class 'QR_matrix' compute_score( x, score_pond = c(qs_residual_s_on_sa = 30L, f_residual_s_on_sa = 30L, qs_residual_sa_on_i = 20L, f_residual_sa_on_i = 20L, f_residual_td_on_sa = 30L, f_residual_td_on_i = 20L, oos_mean = 15L, oos_mse = 10L, residuals_independency = 15L, residuals_homoskedasticity = 5L, residuals_skewness = 5L, m7 = 5L, q_m2 = 5L), modalities = c("Good", "Uncertain", "", "Bad", "Severe"), normalize_score_value = NULL, na.rm = TRUE, n_contrib_score = NULL, conditional_indicator = NULL, thresholds = getOption("jdc_thresholds"), ... ) ## S3 method for class 'mQR_matrix' compute_score(x, ...)## S3 method for class 'QR_matrix' compute_score( x, score_pond = c(qs_residual_s_on_sa = 30L, f_residual_s_on_sa = 30L, qs_residual_sa_on_i = 20L, f_residual_sa_on_i = 20L, f_residual_td_on_sa = 30L, f_residual_td_on_i = 20L, oos_mean = 15L, oos_mse = 10L, residuals_independency = 15L, residuals_homoskedasticity = 5L, residuals_skewness = 5L, m7 = 5L, q_m2 = 5L), modalities = c("Good", "Uncertain", "", "Bad", "Severe"), normalize_score_value = NULL, na.rm = TRUE, n_contrib_score = NULL, conditional_indicator = NULL, thresholds = getOption("jdc_thresholds"), ... ) ## S3 method for class 'mQR_matrix' compute_score(x, ...)
x |
a |
score_pond |
the formula used to calculate the series score. |
modalities |
modalities ordered by importance in the score calculation (cf. details). |
normalize_score_value |
integer indicating the reference value for weights normalisation. If missing, weights will not be normalised. |
na.rm |
logical indicating whether missing values must be ignored when calculating the score. |
n_contrib_score |
integer indicating the number of variables to create
in the quality report's values matrix to store the |
conditional_indicator |
a |
thresholds |
|
... |
other unused parameters. |
The function compute_score calculates a score from the
modalities of a quality report: to each modality corresponds a weight that
depends on the parameter modalities. The default parameter is
c("Good", "Uncertain", "Bad","Severe"), and the associated weights are
respectively 0, 1, 2 and 3.
The score calculation is based on the score_pond parameter, which is a
named integer vector containing the weights to apply to the (modalities
matrix) variables. For example, with
score_pond = c(qs_residual_s_on_sa = 10, f_residual_td_on_sa = 5),
the score will be based on the variables qs_residual_s_on_sa and
f_residual_td_on_sa. The qs_residual_s_on_sa grades will be
multiplied by 10 and the f_residual_td_on_sa grades, by 5. To ignore
the missing values when calculating a score, use the parameter
na.rm = TRUE.
The parameter normalize_score_value can be used to normalise the
scores. For example, to have all scores between 0 and 20, specify
normalize_score_value = 20.
When using parameter n_contrib_score, n_contrib_score new
variables are added to the quality report's values matrix. These new
variables store the names of the variables that contribute the most to the
series score. For example, n_contrib_score = 3 will add to the values
matrix the three variables that contribute the most to the score. The new
variables' names are i_highest_score, with i being the rank in terms of
contribution to the score (1_highest_score contains the name of the greatest
contributor, 2_highest_score the second greatest, etc). Only the variables
that have a non-zero contribution to the score are taken into account: if a
series score is 0, all i_highest_score variables will be empty. And if a
series score is positive only because of the m7 statistic, 1_highest_score
will have a value of "m7" for this series and the other i_highest_score
will be empty.
Some indicators are only relevant under certain conditions. For example, the
homoscedasticity test is only valid when the residuals are independant, and
the normality tests, only when the residuals are both independant and
homoscedastic. In these cases, the parameter conditional_indicator can
be of use since it reduces the weight of some variables down to 1 when some
conditions are met. conditional_indicator is a list of
3-elements sub-lists:
"indicator": the variable whose weight will be conditionally changed
"conditions": the variables used to define the conditions
"conditions_modalities": modalities that must be verified to induce the
weight change For example,
conditional_indicator = list(list(indicator = "residuals_skewness",
conditions = c("residuals_independency", "residuals_homoskedasticity"),
conditions_modalities = c("Bad","Severe"))), reduces down to 1 the weight
of the variable "residuals_skewness" when the modalities of the
independancy test ("residuals_independency") or the homoscedasticity test
("residuals_homoskedasticity") are "Bad" or "Severe".
a QR_matrix or mQR_matrix object.
# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Calculer le score QR <- compute_score(QR, n_contrib_score = 2) print(QR) # Extract the modalities matrix: QR[["modalities"]][["score"]]# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Calculer le score QR <- compute_score(QR, n_contrib_score = 2) print(QR) # Extract the modalities matrix: QR[["modalities"]][["score"]]
Use write() instead of export_xslx().
export_xlsx(x, ...)export_xlsx(x, ...)
x |
a |
... |
other parameters of the function
|
"QR_matrix", "mQR_matrix" or "JVS_matrix"
object invisibly.
# Path leading to a demetra_m matrix demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Compute the scores QR1 <- compute_score(x = QR, n_contrib_score = 5) QR2 <- compute_score( x = QR, score_pond = c(qs_residual_s_on_sa = 5, qs_residual_sa_on_i = 30, f_residual_td_on_sa = 10, f_residual_td_on_i = 40, oos_mean = 30, residuals_skewness = 15, m7 = 25) ) mQR <- mQR_matrix(list(a = QR1, b = QR2)) # Export the Multiple Quality Report to an Excel file # `export_xlsx` is deprecated. # Use `write` instead: write(x = QR, file = tempfile(fileext = ".xlsx")) write(x = mQR, export_dir = tempdir())# Path leading to a demetra_m matrix demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Compute the scores QR1 <- compute_score(x = QR, n_contrib_score = 5) QR2 <- compute_score( x = QR, score_pond = c(qs_residual_s_on_sa = 5, qs_residual_sa_on_i = 30, f_residual_td_on_sa = 10, f_residual_td_on_i = 40, oos_mean = 30, residuals_skewness = 15, m7 = 25) ) mQR <- mQR_matrix(list(a = QR1, b = QR2)) # Export the Multiple Quality Report to an Excel file # `export_xlsx` is deprecated. # Use `write` instead: write(x = QR, file = tempfile(fileext = ".xlsx")) write(x = mQR, export_dir = tempdir())
Extract a JVS report from the output files of JDemetra+. The output files can be generated with the GUI or with the cruncher and are CSV files containing the diagnostics matrix and the output series.
extract_JVS( dir = NULL, demetra_m = NULL, y = NULL, sa = NULL, s = NULL, t = NULL, ... )extract_JVS( dir = NULL, demetra_m = NULL, y = NULL, sa = NULL, s = NULL, t = NULL, ... )
dir |
path to the directory containing the demetra_m.csv, series_decomposition_y_cmp.csv, series_decomposition_sa_cmp.csv, series_decomposition_s_cmp.csv and series_decomposition_t_cmp.csv files. |
demetra_m |
data.frame containing the diagnostics matrix.
If missing or |
y |
data.frame containing the initial series.
If missing or |
sa |
data.frame containing the seasonally adjusted series.
If missing or |
s |
data.frame containing the seasonal component of the series.
If missing or |
t |
data.frame containing the trend component series.
If missing or |
... |
Other parameters to pass to |
This function generates a JVS report from the output of JDemetra+. The output needed are the demetra_m diagnostics matrix (usually from the file demetra_m.csv) and the series y, sa, s and t (usually read from the series CSV files).
All this files can be generated by launching the cruncher (functions
cruncher_and_param).
For more information about the generation of the output, see the vignette:
browseVignettes(package = "JDCruncheR")
If the series are provided, they have to be data.frame with the dates in
the first column and the values of the series in the other columns.
This function returns a JVS_matrix object, which is a
data.frame containing several indications on the seasonal adjustment
of the series.
If all data frames (demetra_m, y, sa, s and i) are supplied,
the dir argument is ignored. Otherwise, dir should point to the
directory containing the corresponding CSV files.
a JVS_matrix object.
Other JVS_matrix functions:
write.JVS_matrix()
# Path leading to the directory containing the needed files dir_path <- system.file( "extdata", "WS/WS_world/Output/SAProcessing-1", package = "JDCruncheR" ) # Extract the JVS report from the directory JVS <- extract_JVS(dir = dir_path)# Path leading to the directory containing the needed files dir_path <- system.file( "extdata", "WS/WS_world/Output/SAProcessing-1", package = "JDCruncheR" ) # Extract the JVS report from the directory JVS <- extract_JVS(dir = dir_path)
To extract a quality report from the csv file containing the diagnostics matrix.
extract_QR(file, x, thresholds = getOption("jdc_thresholds"), ...)extract_QR(file, x, thresholds = getOption("jdc_thresholds"), ...)
file |
the csv file containing the diagnostics matrix. This argument
supersedes the argument |
x |
data.frame containing the diagnostics matrix. |
thresholds |
|
... |
Other paramemeter to pass to |
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).
a QR_matrix object.
Other QR_matrix functions:
QR_matrix(),
print.QR_matrix(),
rbind.QR_matrix(),
sort,
weighted_score(),
write.QR_matrix(),
write.mQR_matrix()
# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(file = demetra_path) print(QR) # Extract the modalities matrix: QR[["modalities"]] # Or: QR[["modalities"]]# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(file = demetra_path) print(QR) # Extract the modalities matrix: QR[["modalities"]] # Or: QR[["modalities"]]
To extract score variables from QR_matrix or
mQR_matrix objects.
extract_score( x, format_output = c("data.frame", "vector"), weighted_score = FALSE )extract_score( x, format_output = c("data.frame", "vector"), weighted_score = FALSE )
x |
a |
format_output |
string of characters indicating the output format:
either a |
weighted_score |
logical indicating whether to extract the weighted score (if previously calculated) or the unweighted one. By default, the unweighted score is extracted. |
For QR_matrix objects, the output is a vector or the
object NULL if no score was previously calculated.
For mQR_matrix objects, it is a list of scores (NULL
elements or vectors).
extract_score() returns a data.frame with two column: the
series name and their score.
# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Compute the score QR1 <- compute_score(x = QR, n_contrib_score = 5) QR2 <- compute_score( x = QR, score_pond = c(qs_residual_s_on_sa = 5, qs_residual_sa_on_i = 30, f_residual_td_on_sa = 10, f_residual_td_on_i = 40, oos_mean = 30, residuals_skewness = 15, m7 = 25) ) mQR <- mQR_matrix(list(a = QR1, b = QR2)) # Extract score extract_score(QR1) extract_score(mQR)# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Compute the score QR1 <- compute_score(x = QR, n_contrib_score = 5) QR2 <- compute_score( x = QR, score_pond = c(qs_residual_s_on_sa = 5, qs_residual_sa_on_i = 30, f_residual_td_on_sa = 10, f_residual_td_on_i = 40, oos_mean = 30, residuals_skewness = 15, m7 = 25) ) mQR <- mQR_matrix(list(a = QR1, b = QR2)) # Extract score extract_score(QR1) extract_score(mQR)
Get all (default) thresholds
get_thresholds(test_name, default = TRUE)get_thresholds(test_name, default = TRUE)
test_name |
String. The name of the test to get. |
default |
Boolean. (default is TRUE) If TRUE, the default threshold will be returned. If FALSE the current used thresholds. |
If test_name is missing, all threshold will be returned.
Returns invisibly the thresholds of the chosen item. If test_name is missing, it returns all the current thresholds.
# Get all default thresholds get_thresholds(default = TRUE) # Get all current thresholds get_thresholds(default = FALSE) # Get all current thresholds get_thresholds(test_name = "oos_mean", default = FALSE)# Get all default thresholds get_thresholds(default = TRUE) # Get all current thresholds get_thresholds(default = FALSE) # Get all current thresholds get_thresholds(test_name = "oos_mean", default = FALSE)
JVS_matrix() are creating a quality report based on the Eurostat JVS
Plug-In.
JVS_matrix(x = list()) ## S3 method for class 'data.frame' JVS_matrix(x) ## S3 method for class 'JVS_matrix' JVS_matrix(x) ## Default S3 method: JVS_matrix(x)JVS_matrix(x = list()) ## S3 method for class 'data.frame' JVS_matrix(x) ## S3 method for class 'JVS_matrix' JVS_matrix(x) ## Default S3 method: JVS_matrix(x)
x |
a |
AJVS_matrix object is a data.frame with 30 items:
Series
Method
Period
Nobs
Start
End
Adjustment
Presence of Seasonality in the Raw Series
Presence of TD effects
Log-Transformation
ARIMA Model
LeapYear
MovingHoliday
NbTD
Noutliers
Outlier1
Outlier2
Outlier3
Residual Seasonality in SA Series (F-test)
Residual TD Effect
Q-Stat (for X13)
Final Henderson Filter
Stage 2 Henderson Filter
Seasonal Filter
Quality
Autocorrelation of order 1 of the SA series
Ljung-Box Test (P-value)
Autocorrelation negative and significant
Irregular Standard-Deviation
Max-Adj
JVS_matrix() creates and returns a JVS_matrix object.
JVS_data <- data.frame( Series = "Series 1", Method = "X13", Period = 12L, Nobs = 300L, Start = "2000-01-01", End = "2024-12-01", Adjustment = "SA", `Presence of Seasonality in the Raw Series` = "Yes", `Presence of TD effects` = "No", `Log-Transformation` = "No", `ARIMA Model` = "(0,1,1)(0,1,1)", LeapYear = "Yes", MovingHoliday = "No", NbTD = 0L, Noutliers = 1L, Outlier1 = "AO (2020-01)", Outlier2 = "AO (2018-11)", Outlier3 = NA_character_, `Residual Seasonality in SA Series (F-test)` = "No", `Residual TD Effect` = "No", `Q-Stat (for X13)` = "Good", `Final Henderson Filter` = "H13", `Stage 2 Henderson Filter` = "H13", `Seasonal Filter` = "S3X5", Quality = "Good", `Autocorrelation of order 1 of the SA series` = 0.2, `Ljung-Box Test (P-value)` = 0.8, `Autocorrelation negative and significant` = "", `Irregular Standard-Deviation` = 0.8, `Max-Adj` = 2.5 ) # Create a JVS_matrix object JVS <- JVS_matrix(JVS_data) # Check the class of the object class(JVS)JVS_data <- data.frame( Series = "Series 1", Method = "X13", Period = 12L, Nobs = 300L, Start = "2000-01-01", End = "2024-12-01", Adjustment = "SA", `Presence of Seasonality in the Raw Series` = "Yes", `Presence of TD effects` = "No", `Log-Transformation` = "No", `ARIMA Model` = "(0,1,1)(0,1,1)", LeapYear = "Yes", MovingHoliday = "No", NbTD = 0L, Noutliers = 1L, Outlier1 = "AO (2020-01)", Outlier2 = "AO (2018-11)", Outlier3 = NA_character_, `Residual Seasonality in SA Series (F-test)` = "No", `Residual TD Effect` = "No", `Q-Stat (for X13)` = "Good", `Final Henderson Filter` = "H13", `Stage 2 Henderson Filter` = "H13", `Seasonal Filter` = "S3X5", Quality = "Good", `Autocorrelation of order 1 of the SA series` = 0.2, `Ljung-Box Test (P-value)` = 0.8, `Autocorrelation negative and significant` = "", `Irregular Standard-Deviation` = 0.8, `Max-Adj` = 2.5 ) # Create a JVS_matrix object JVS <- JVS_matrix(JVS_data) # Check the class of the object class(JVS)
To print information on a QR_matrix or mQR_matrix object.
## S3 method for class 'QR_matrix' print(x, print_variables = TRUE, print_score_formula = TRUE, ...) ## S3 method for class 'mQR_matrix' print(x, score_statistics = TRUE, ...)## S3 method for class 'QR_matrix' print(x, print_variables = TRUE, print_score_formula = TRUE, ...) ## S3 method for class 'mQR_matrix' print(x, score_statistics = TRUE, ...)
x |
a |
print_variables |
logical indicating whether to print the indicators' name (including additionnal variables). |
print_score_formula |
logical indicating whether to print the formula with which the score was calculated (when calculated). |
... |
other unused arguments. |
score_statistics |
logical indicating whether to print the statistics
in the |
the print method prints a mQR_matrix or
mQR_matrix object and returns it invisibly (via
invisible(x)).
Other QR_matrix functions:
QR_matrix(),
extract_QR(),
rbind.QR_matrix(),
sort,
weighted_score(),
write.QR_matrix(),
write.mQR_matrix()
mQR_matrix() and QR_matrix() are creating one (or several)
quality report. The function
is.QR_matrix() and is.mQR_matrix() are functions to test
whether an object is a quality report or a list of quality reports.
QR_matrix(modalities = NULL, values = NULL, score_formula = NULL) mQR_matrix(x = list(), ...) ## S3 method for class 'QR_matrix' mQR_matrix(x = QR_matrix(), ...) ## S3 method for class 'mQR_matrix' mQR_matrix(x = mQR_matrix.default(), ...) ## Default S3 method: mQR_matrix(x = list(), ...) is.QR_matrix(x) is.mQR_matrix(x)QR_matrix(modalities = NULL, values = NULL, score_formula = NULL) mQR_matrix(x = list(), ...) ## S3 method for class 'QR_matrix' mQR_matrix(x = QR_matrix(), ...) ## S3 method for class 'mQR_matrix' mQR_matrix(x = mQR_matrix.default(), ...) ## Default S3 method: mQR_matrix(x = list(), ...) is.QR_matrix(x) is.mQR_matrix(x)
modalities |
a |
values |
a |
score_formula |
the formula used to calculate the series score (if defined). |
x |
a |
... |
objects of the same type as |
AQR_matrix object is a list of three items:
modalities, a data.frame containing a set of categorical
variables (by default: Good, Uncertain, Bad, Severe).
values, a data.frame containing the values corresponding to
the modalities indicators (i.e. p-values, statistics, etc.), as well
as variables for which a modality cannot be defined (e.g. the series
frequency, the ARIMA model, etc).
score_formula contains the formula used to calculate the series
score (once the calculus is done).
QR_matrix() creates and returns a QR_matrix object.
mQR_matrix() creates and returns a mQR_matrix object
(ie. a list of QR_matrix objects). is.QR_matrix() and
is.mQR_matrix() return Boolean values (TRUE or FALSE).
Other QR_matrix functions:
extract_QR(),
print.QR_matrix(),
rbind.QR_matrix(),
sort,
weighted_score(),
write.QR_matrix(),
write.mQR_matrix()
modalities <- data.frame( Quality = c("Good", "Uncertain", "Bad"), Seasonality = c("Good", "Good", "Bad") ) values <- data.frame( Quality = c(0.95, 0.75, 0.02), Seasonality = c(0.80, 0.60, 0.01), Period = c(12L, 12L, 12L) ) # Create two quality report objects QR1 <- QR_matrix( modalities = modalities, values = values ) QR2 <- QR_matrix( modalities = modalities, values = values ) # Test whether an object is a quality report is.QR_matrix(QR1) # Create a list of quality reports mQR <- mQR_matrix(QR1, QR2) # Test whether an object is a list of quality reports is.mQR_matrix(mQR)modalities <- data.frame( Quality = c("Good", "Uncertain", "Bad"), Seasonality = c("Good", "Good", "Bad") ) values <- data.frame( Quality = c(0.95, 0.75, 0.02), Seasonality = c(0.80, 0.60, 0.01), Period = c(12L, 12L, 12L) ) # Create two quality report objects QR1 <- QR_matrix( modalities = modalities, values = values ) QR2 <- QR_matrix( modalities = modalities, values = values ) # Test whether an object is a quality report is.QR_matrix(QR1) # Create a list of quality reports mQR <- mQR_matrix(QR1, QR2) # Test whether an object is a list of quality reports is.mQR_matrix(mQR)
Functions to add indicator (add_indicator()), remove indicators
(remove_indicators()) or retrain some indicators only
(retain_indicators()) to and from QR_matrix or
mQR_matrix objects. The series names (column "series") cannot
be removed.
remove_indicators(x, ...) ## Default S3 method: remove_indicators(x, ...) ## S3 method for class 'QR_matrix' remove_indicators(x, ...) ## S3 method for class 'mQR_matrix' remove_indicators(x, ...) retain_indicators(x, ...) ## Default S3 method: retain_indicators(x, ...) ## S3 method for class 'QR_matrix' retain_indicators(x, ...) ## S3 method for class 'mQR_matrix' retain_indicators(x, ...) add_indicator(x, indicator, variable_name, ...) ## Default S3 method: add_indicator(x, indicator, variable_name, ...) ## S3 method for class 'QR_matrix' add_indicator(x, indicator, variable_name, ...) ## S3 method for class 'mQR_matrix' add_indicator(x, indicator, variable_name, ...)remove_indicators(x, ...) ## Default S3 method: remove_indicators(x, ...) ## S3 method for class 'QR_matrix' remove_indicators(x, ...) ## S3 method for class 'mQR_matrix' remove_indicators(x, ...) retain_indicators(x, ...) ## Default S3 method: retain_indicators(x, ...) ## S3 method for class 'QR_matrix' retain_indicators(x, ...) ## S3 method for class 'mQR_matrix' retain_indicators(x, ...) add_indicator(x, indicator, variable_name, ...) ## Default S3 method: add_indicator(x, indicator, variable_name, ...) ## S3 method for class 'QR_matrix' add_indicator(x, indicator, variable_name, ...) ## S3 method for class 'mQR_matrix' add_indicator(x, indicator, variable_name, ...)
x |
a |
... |
other parameters of the function |
indicator |
a |
variable_name |
a string containing the name of the variables to add. |
The function add_indicator() adds the chosen indicator to the
values matrix of a quality report. Therefore, because said indicator isn't
added in the modalities matrix, it cannot be used to calculate a score
(except for weighting). Before using the added variable for score
calculation, it will have to be coded with the function
recode_indicator_num.
The new indicator can be a vector or a data.frame. In both
cases, its format must allow for pairing:
a vector's elements must be named and these names must match those
of the quality report (variable "series");
a data.frame must contain a "series" column that matches with the
quality report's series.
remove_indicators() returns the same object x reduced by the
flags and variables used as arguments ...
So if the input x is a QR_matrix, an object of class QR_matrix
is returned. If the input x is a mQR_matrix, an object of class
mQR_matrix is returned.
retains_indicators() returns the same object, with only the chosen
indicators.
add_indicators() returns the same object, enhanced with the chosen
indicator.
So if the input x is a QR_matrix, an object of class
QR_matrix is returned. If the input x is a mQR_matrix, an
object of class mQR_matrix is returned.
Other var QR_matrix manipulation:
recode_indicator_num()
# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Add a new indicator my_alea <- rnorm(nrow(QR$modalities)) names(my_alea) <- QR$modalities$series QR <- add_indicator(QR, indicator = my_alea, variable_name = "alea") # Retains indicators retain_indicators(QR, "alea", "m7") # retaining "alea" and "m7" retain_indicators(QR, c("alea", "m7")) # Same # Remove indicators QR <- remove_indicators(QR, "alea") # Remove "alea" retain_indicators(QR, "alea") # is empty because we removed the alea indicator# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Add a new indicator my_alea <- rnorm(nrow(QR$modalities)) names(my_alea) <- QR$modalities$series QR <- add_indicator(QR, indicator = my_alea, variable_name = "alea") # Retains indicators retain_indicators(QR, "alea", "m7") # retaining "alea" and "m7" retain_indicators(QR, c("alea", "m7")) # Same # Remove indicators QR <- remove_indicators(QR, "alea") # Remove "alea" retain_indicators(QR, "alea") # is empty because we removed the alea indicator
Function to combine multiple QR_matrix objects: line by line,
both for the modalities and the values table.
## S3 method for class 'QR_matrix' rbind(..., check_formula = TRUE)## S3 method for class 'QR_matrix' rbind(..., check_formula = TRUE)
... |
|
check_formula |
logical indicating whether to check the score formulas'
coherency.
By default, |
rbind.QR_matrix() returns a QR_matrix object.
Other QR_matrix functions:
QR_matrix(),
extract_QR(),
print.QR_matrix(),
sort,
weighted_score(),
write.QR_matrix(),
write.mQR_matrix()
# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Compute differents scores QR1 <- compute_score(QR, score_pond = c(m7 = 2, q = 3, qs_residual_s_on_sa = 5)) QR2 <- compute_score(QR, score_pond = c(m7 = 2, qs_residual_s_on_sa = 5)) # Merge two quality report try(rbind(QR1, QR2)) # Une erreur est renvoyée rbind(QR1, QR2, check_formula = FALSE)# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Compute differents scores QR1 <- compute_score(QR, score_pond = c(m7 = 2, q = 3, qs_residual_s_on_sa = 5)) QR2 <- compute_score(QR, score_pond = c(m7 = 2, qs_residual_s_on_sa = 5)) # Merge two quality report try(rbind(QR1, QR2)) # Une erreur est renvoyée rbind(QR1, QR2, check_formula = FALSE)
To transform variables from the values matrix into categorical variables that can be added into the modalities matrix.
recode_indicator_num( x, variable_name, breaks = c(0, 0.01, 0.05, 0.1, 1), labels = c("Good", "Uncertain", "Bad", "Severe"), ... ) ## S3 method for class 'QR_matrix' recode_indicator_num( x, variable_name, breaks = c(0, 0.01, 0.05, 0.1, 1), labels = c("Good", "Uncertain", "Bad", "Severe"), ... ) ## S3 method for class 'mQR_matrix' recode_indicator_num( x, variable_name, breaks = c(0, 0.01, 0.05, 0.1, 1), labels = c("Good", "Uncertain", "Bad", "Severe"), ... )recode_indicator_num( x, variable_name, breaks = c(0, 0.01, 0.05, 0.1, 1), labels = c("Good", "Uncertain", "Bad", "Severe"), ... ) ## S3 method for class 'QR_matrix' recode_indicator_num( x, variable_name, breaks = c(0, 0.01, 0.05, 0.1, 1), labels = c("Good", "Uncertain", "Bad", "Severe"), ... ) ## S3 method for class 'mQR_matrix' recode_indicator_num( x, variable_name, breaks = c(0, 0.01, 0.05, 0.1, 1), labels = c("Good", "Uncertain", "Bad", "Severe"), ... )
x |
a |
variable_name |
a vector of strings containing the names of the variables to convert. |
breaks |
see function |
labels |
see function |
... |
other parameters of the |
The function recode_indicator_num() returns the same object,
enhanced with the chosen indicator. So if the input x is a QR_matrix,
an object of class QR_matrix is returned. If the input x is a
mQR_matrix, an object of class mQR_matrix is returned.
Other var QR_matrix manipulation:
QR_var_manipulation
# Path to the demetra_m.csv file demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Recode residuals_skewness QR2 <- recode_indicator_num(QR, variable_name = "residuals_skewness", breaks = c(0.0, 0.01, 0.05, 0.1, 1.0), labels = c("Good", "Uncertain", "Bad", "Severe") ) QR$modalities$residuals_skewness QR2$modalities$residuals_skewness# Path to the demetra_m.csv file demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Recode residuals_skewness QR2 <- recode_indicator_num(QR, variable_name = "residuals_skewness", breaks = c(0.0, 0.01, 0.05, 0.1, 1.0), labels = c("Good", "Uncertain", "Bad", "Severe") ) QR$modalities$residuals_skewness QR2$modalities$residuals_skewness
Set values for thresholds
set_thresholds(test_name, thresholds)set_thresholds(test_name, thresholds)
test_name |
String. The name of the test to update. |
thresholds |
Named vector of numerics. The upper values of each break of a threshold. |
If test_name is missing, the argument thresholds is not used
and all thresholds will be updated to their default values.
If test_name is not missing, but if the argument thresholds is
missing then only the thresholds of the test test_name will be updated
to its default values.
Finally, if test_name and thresholds are not missing, then only
the thresholds of the test test_name are updated with the value
thresholds.
Returns invisibly all the current (updated) thresholds. It's a list of item with grade ("Good", "Uncertain", "Bad", "Severe", "Poor"...).
# Set "m7" set_thresholds( test_name = "m7", thresholds = c(Good = 0.8, Bad = 1.4, Severe = Inf) ) # Set "oos_mean" to default set_thresholds(test_name = "oos_mean") # Set all thresholds to default set_thresholds()# Set "m7" set_thresholds( test_name = "m7", thresholds = c(Good = 0.8, Bad = 1.4, Severe = Inf) ) # Set "oos_mean" to default set_thresholds(test_name = "oos_mean") # Set all thresholds to default set_thresholds()
To sort the quality reports on one or several variables
## S3 method for class 'QR_matrix' sort(x, decreasing = FALSE, sort_variables = "score", ...) ## S3 method for class 'mQR_matrix' sort(x, decreasing = FALSE, sort_variables = "score", ...)## S3 method for class 'QR_matrix' sort(x, decreasing = FALSE, sort_variables = "score", ...) ## S3 method for class 'mQR_matrix' sort(x, decreasing = FALSE, sort_variables = "score", ...)
x |
a |
decreasing |
logical indicating whether the quality reports must be sorted in ascending or decreasing order. By default, the sorting is done in ascending order. |
sort_variables |
They must be present in the modalities table. |
... |
other parameters of the function |
the input with sorted quality reports
Other QR_matrix functions:
QR_matrix(),
extract_QR(),
print.QR_matrix(),
rbind.QR_matrix(),
weighted_score(),
write.QR_matrix(),
write.mQR_matrix()
# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Compute the score QR <- compute_score(QR, n_contrib_score = 2) print(QR[["modalities"]][["score"]]) # Sort the scores # To sort by ascending scores QR <- sort(QR, sort_variables = "score") print(QR[["modalities"]][["score"]])# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Compute the score QR <- compute_score(QR, n_contrib_score = 2) print(QR[["modalities"]][["score"]]) # Sort the scores # To sort by ascending scores QR <- sort(QR, sort_variables = "score") print(QR[["modalities"]][["score"]])
Function to weight a pre-calculated score
weighted_score(x, pond = 1L) ## Default S3 method: weighted_score(x, pond = 1L) ## S3 method for class 'QR_matrix' weighted_score(x, pond = 1L) ## S3 method for class 'mQR_matrix' weighted_score(x, pond = 1L)weighted_score(x, pond = 1L) ## Default S3 method: weighted_score(x, pond = 1L) ## S3 method for class 'QR_matrix' weighted_score(x, pond = 1L) ## S3 method for class 'mQR_matrix' weighted_score(x, pond = 1L)
x |
a |
pond |
the weights to use. Can be an integer, a vector of integers, the
name of one of the quality report variables or a list of weights for the
|
the input with an additionnal weighted score
Other QR_matrix functions:
QR_matrix(),
extract_QR(),
print.QR_matrix(),
rbind.QR_matrix(),
sort,
write.QR_matrix(),
write.mQR_matrix()
# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Compute the score QR <- compute_score(QR, n_contrib_score = 2) # Weighted score QR <- weighted_score(QR, 2) print(QR) # Extract the weighted score QR[["modalities"]][["score_pond"]]# Path of matrix demetra_m demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Compute the score QR <- compute_score(QR, n_contrib_score = 2) # Weighted score QR <- weighted_score(QR, 2) print(QR) # Extract the weighted score QR[["modalities"]][["score_pond"]]
Writing QR to files
write(x, ...)write(x, ...)
x |
a |
... |
other parameters of the function
|
If x is a JVS_matrix or a mQR_matrix, the
function returns invisibly (via invisible(x)) the same object as
x.
Else if x is a QR_matrix, the function returns
invisibly (via invisible()) a workbook object created by
openxlsx::loadWorkbook() for further manipulation.
To export several quality reports in CSV or Excel files
## S3 method for class 'JVS_matrix' write( x, format = c("csv", "xlsx"), export_dir = tempdir(), overwrite = TRUE, ... )## S3 method for class 'JVS_matrix' write( x, format = c("csv", "xlsx"), export_dir = tempdir(), overwrite = TRUE, ... )
x |
a |
format |
output format. One of |
export_dir |
export directory. |
overwrite |
logical indicating whether to create a CSV or Excel file if
it doesn't exist yet ( |
... |
other unused arguments |
xlsx files will be exported with the package 'openxlsx'.
csv files will be exported with the package 'utils'.
Returns invisibly (via invisible(x)) the same
JVS_matrix object as x.
Other JVS_matrix functions:
extract_JVS()
# Path leading to the needed CSV files demetra_m and series dir_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1" ) # Extract the JVS report from the CSV files JVS <- extract_JVS(dir = dir_path) # Export of the JVS report in an Excel file write(JVS, format = "xlsx", export_dir = tempdir(), overwrite = TRUE) # Export of the JVS report in a CSV file write(JVS, format = "csv", export_dir = tempdir(), overwrite = TRUE)# Path leading to the needed CSV files demetra_m and series dir_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1" ) # Extract the JVS report from the CSV files JVS <- extract_JVS(dir = dir_path) # Export of the JVS report in an Excel file write(JVS, format = "xlsx", export_dir = tempdir(), overwrite = TRUE) # Export of the JVS report in a CSV file write(JVS, format = "csv", export_dir = tempdir(), overwrite = TRUE)
To export several quality reports in Excel files
## S3 method for class 'mQR_matrix' write( x, export_dir, layout_file = c("ByComponent", "ByQRMatrix", "AllTogether"), auto_format = TRUE, overwrite = TRUE, ... )## S3 method for class 'mQR_matrix' write( x, export_dir, layout_file = c("ByComponent", "ByQRMatrix", "AllTogether"), auto_format = TRUE, overwrite = TRUE, ... )
x |
a |
export_dir |
export directory. |
layout_file |
export parameter. By default, ( |
auto_format |
logical indicating whether to format the output
( |
overwrite |
logical indicating whether to create an Excel file if it
doesn't exist yet ( |
... |
other unused arguments |
Returns invisibly (via invisible(x)) the same
mQR_matrix object as x.
Other QR_matrix functions:
QR_matrix(),
extract_QR(),
print.QR_matrix(),
rbind.QR_matrix(),
sort,
weighted_score(),
write.QR_matrix()
# Path leading to the demetra_m.csv file demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extraction of the QR from the demetra_m.csv file QR <- extract_QR(demetra_path) # Compute the scores QR1 <- compute_score(x = QR, n_contrib_score = 5) QR2 <- compute_score( x = QR, score_pond = c(qs_residual_s_on_sa = 5, qs_residual_sa_on_i = 30, f_residual_td_on_sa = 10, f_residual_td_on_i = 40, oos_mean = 30, residuals_skewness = 15, m7 = 25) ) mQR <- mQR_matrix(list(a = QR1, b = QR2)) # Export the Multiple Quality Report to an Excel file write(x = mQR, export_dir = tempdir())# Path leading to the demetra_m.csv file demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extraction of the QR from the demetra_m.csv file QR <- extract_QR(demetra_path) # Compute the scores QR1 <- compute_score(x = QR, n_contrib_score = 5) QR2 <- compute_score( x = QR, score_pond = c(qs_residual_s_on_sa = 5, qs_residual_sa_on_i = 30, f_residual_td_on_sa = 10, f_residual_td_on_i = 40, oos_mean = 30, residuals_skewness = 15, m7 = 25) ) mQR <- mQR_matrix(list(a = QR1, b = QR2)) # Export the Multiple Quality Report to an Excel file write(x = mQR, export_dir = tempdir())
To export a quality report in an Excel file.
## S3 method for class 'QR_matrix' write(x, file, auto_format = TRUE, overwrite = TRUE, ...)## S3 method for class 'QR_matrix' write(x, file, auto_format = TRUE, overwrite = TRUE, ...)
x |
a |
file |
a |
auto_format |
logical indicating whether to format the output
( |
overwrite |
logical indicating whether to create an Excel file if it
doesn't exist yet ( |
... |
other unused arguments |
Returns invisibly (via invisible()) a workbook object
created by openxlsx::loadWorkbook() for further manipulation.
Other QR_matrix functions:
QR_matrix(),
extract_QR(),
print.QR_matrix(),
rbind.QR_matrix(),
sort,
weighted_score(),
write.mQR_matrix()
# Path leading to a demetra_m matrix demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Export the Quality Report to an Excel file write(x = QR, file = tempfile(fileext = ".xlsx"))# Path leading to a demetra_m matrix demetra_path <- file.path( system.file("extdata", package = "JDCruncheR"), "WS/WS_world/Output/SAProcessing-1", "demetra_m.csv" ) # Extract the quality report from the demetra_m file QR <- extract_QR(demetra_path) # Export the Quality Report to an Excel file write(x = QR, file = tempfile(fileext = ".xlsx"))