Skip to content

Commit

Permalink
Merge pull request #2 from AQLT/develop
Browse files Browse the repository at this point in the history
v0.1.4
  • Loading branch information
AQLT authored Mar 19, 2024
2 parents 6d93424 + 3ad09e4 commit 4ad84a2
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 17 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ TODO.R
^revdep$
^pkgdown$
^\.github$
^reconf.sh$
4 changes: 3 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ on:
branches:
- main
- master
- develop
pull_request:
branches:
- main
- develop
- master
- develop

name: R-CMD-check

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]
release:
types: [published]
workflow_dispatch:
Expand Down Expand Up @@ -44,3 +46,4 @@ jobs:
clean: false
branch: gh-pages
folder: docs
single-commit: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.Rhistory
.RData
.Ruserdata
.DS_Store
.DS_Store
cran-comments.md
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rjdqa
Type: Package
Title: Quality Assessment for Seasonal Adjustment
Version: 0.1.3
Version: 0.1.4
Authors@R: c(
person("Alain", "Quartier-la-Tente", role = c("aut", "cre"),
email = "[email protected]",
Expand All @@ -12,10 +12,10 @@ License: EUPL
SystemRequirements: Java (>= 8)
Depends:
R (>= 3.1.1),
RJDemetra,
RJDemetra (>= 0.2.5),
Imports:
plotrix,
ggdemetra,
ggdemetra (>= 0.2.5),
utils,
graphics,
stats
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# rjdqa 0.1.4

- Fix of minimum versions of dependencies.

- Correction of the orders of the outliers in `simple_dashboard2()`.

# rjdqa 0.1.3

- deprecated function `sa_dashboard()` removed.
Expand Down
2 changes: 1 addition & 1 deletion R/simple_dashboard.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ simple_dashboard <- function(x, digits = 2,
# Global info on model
arima_ord <- sprintf("ARIMA(%s)(%s)",
paste(unlist(RJDemetra::get_indicators(x, sprintf("preprocessing.arima.%s", c("p", "d", "q")))), collapse = ","),
paste(unlist(RJDemetra::get_indicators(x, sprintf("preprocessing.arima.%s", c("bp", "bd", "bd")))), collapse = ","))
paste(unlist(RJDemetra::get_indicators(x, sprintf("preprocessing.arima.%s", c("bp", "bd", "bq")))), collapse = ","))
ntd <- RJDemetra::get_indicators(x, "preprocessing.model.ntd")[[1]] # nombre de JO
nmh <- RJDemetra::get_indicators(x, "preprocessing.model.nmh")[[1]]
is_easter <- (! is.null(nmh)) &&
Expand Down
30 changes: 22 additions & 8 deletions R/simple_dashboard2.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' By default only the estimate coefficients and the t-statistics are printed
#' (`columns_outliers = c("Estimate", "T-stat")`).
#' @param n_last_outliers number of last outliers to be printed (by default `n_last_outliers = 4`).
#' @param order_outliers order of the outliers in case of several outliers at the same date.
#'
#'
#' @rdname simple_dashboard
Expand All @@ -19,7 +20,8 @@ simple_dashboard2 <- function(x, digits = 2,
remove_others_contrib = FALSE,
digits_outliers = digits,
columns_outliers = c("Estimate", "T-stat"),
n_last_outliers = 4) {
n_last_outliers = 4,
order_outliers = c("AO", "LS", "TC", "SO")) {
if (inherits(x, "TRAMO_SEATS")) {
x <- RJDemetra::jtramoseats(RJDemetra::get_ts(x), RJDemetra::tramoseats_spec(x))
} else if (inherits(x, "X13")) {
Expand Down Expand Up @@ -48,7 +50,7 @@ simple_dashboard2 <- function(x, digits = 2,
# Global info on model
arima_ord <- sprintf("ARIMA(%s)(%s)",
paste(unlist(RJDemetra::get_indicators(x, sprintf("preprocessing.arima.%s", c("p", "d", "q")))), collapse = ","),
paste(unlist(RJDemetra::get_indicators(x, sprintf("preprocessing.arima.%s", c("bp", "bd", "bd")))), collapse = ","))
paste(unlist(RJDemetra::get_indicators(x, sprintf("preprocessing.arima.%s", c("bp", "bd", "bq")))), collapse = ","))
ntd <- RJDemetra::get_indicators(x, "preprocessing.model.ntd")[[1]] # nombre de JO
nmh <- RJDemetra::get_indicators(x, "preprocessing.model.nmh")[[1]]
is_easter <- (! is.null(nmh)) &&
Expand All @@ -68,7 +70,8 @@ simple_dashboard2 <- function(x, digits = 2,
ifelse(is_easter, "easter effect",
"no easter effect"))
# nb outliers
out <- sprintf("%s detected outliers", RJDemetra::get_indicators(x, "preprocessing.model.nout")[[1]])
nout <- RJDemetra::get_indicators(x, "preprocessing.model.nout")[[1]]
out <- sprintf("%s detected outliers", nout)
summary_text <- c(est_span, transform, tde, out, arima_ord)


Expand Down Expand Up @@ -153,10 +156,14 @@ simple_dashboard2 <- function(x, digits = 2,
colnames(decomp_stats)[ncol(qstats)+1] <- " "
}

outliers <- do.call(rbind, RJDemetra::get_indicators(x, sprintf("preprocessing.model.out(%i)", seq_len(n_last_outliers))))
outliers_color <- NULL
if (!is.null(outliers)) {
outliers <- outliers[, columns_outliers, drop = FALSE]
outliers <- outliers_color <- NULL
if (nout > 0) {
outliers <- do.call(rbind, RJDemetra::get_indicators(x, sprintf("preprocessing.model.out(%i)", seq_len(nout))))
# sort outliers by dates
dates_out <- outliers_to_dates(rownames(outliers))
dates_out$type <- factor(dates_out$type, levels = order_outliers, ordered = TRUE)
outliers <- outliers[order(dates_out$year, dates_out$period, dates_out$type, decreasing = TRUE), , drop = FALSE]
outliers <- outliers[seq_len(min(n_last_outliers, nrow(outliers))), columns_outliers, drop = FALSE]
outliers <- round(outliers, digits_outliers)
outliers <- data.frame(rownames(outliers),
outliers)
Expand All @@ -181,7 +188,14 @@ simple_dashboard2 <- function(x, digits = 2,
class(res) <- c("simple_dashboard2")
res
}

outliers_to_dates <- function(name_out){
dates_out <- gsub("\\w. \\((.*)\\)", "\\1", name_out)
types <- gsub(" .*", "", name_out)
dates <- do.call(rbind, strsplit(dates_out, "-"))
periods <- as.numeric(as.roman(dates[,1]))
years <- as.numeric(dates[,2])
data.frame(year = years, period = periods, type = types)
}
#' @rdname plot.simple_dashboard
#' @export
plot.simple_dashboard2 <- function(x, main = "Simple Dashboard with outliers",
Expand Down
3 changes: 2 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ install.packages("rjdqa")
# Install development version from GitHub
# install.packages("devtools")
devtools::install_github("AQLT/rjdqa")
# devtools::install_github("AQLT/rjdqa")
install.packages("rjdqa", repos = c('https://aqlt.r-universe.dev', 'https://cloud.r-project.org'))
```

If you have troubles with the installation of RJDemetra or rjdqa, check the [installation manual](https://github.com/jdemetra/rjdemetra/wiki/Installation-manual).
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ install.packages("rjdqa")

# Install development version from GitHub
# install.packages("devtools")
devtools::install_github("AQLT/rjdqa")
# devtools::install_github("AQLT/rjdqa")
install.packages("rjdqa", repos = c('https://aqlt.r-universe.dev', 'https://cloud.r-project.org'))
```

If you have troubles with the installation of RJDemetra or rjdqa, check
Expand Down
5 changes: 4 additions & 1 deletion man/simple_dashboard.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4ad84a2

Please sign in to comment.