Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New jars + likelihood (df) #51

Merged
merged 5 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
^.*\.Rproj$
^\.Rproj\.user$

^\.git$
^\.github$

^README\.Rmd$
^README-.*\.png$

^Meta$
^appveyor\.yml$
^docs$
^doc$
^pkgdown$
^_pkgdown\.yml$

^\.lintr$

^appveyor\.yml$
^.*\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
^README-.*\.png$
.travis.yml

^pkgdown$
^doc$
cran-comments.md

^\.DS_Store$

TODO.R
TO_DO
^revdep$
^\.github$
.DS_Store
^reconf\.sh$
^pom\.xml$
5 changes: 4 additions & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
workflow_dispatch
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

name: test-coverage

Expand Down
42 changes: 17 additions & 25 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
Package: rjd3toolkit
Type: Package
Title: Utility Functions around 'JDemetra+ 3.0'
Title: Toolkit Functions Around 'JDemetra+ 3.0'
Version: 3.2.3
Authors@R: c(
person(given = "Jean",
family = "Palate", role = c("aut"),
email = "[email protected]"),
person(given = "Alain",
family = "Quartier-la-Tente", role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0001-7890-3857")),
person(given = "Tanguy",
family = "Barthelemy", role = c("aut","cre"),
email ="[email protected]"),
person(given = "Anna",
family = "Smyk", role = c("aut"),
email ="[email protected]"))
Description: R Interface to 'JDemetra+ 3.x' (<https://github.com/jdemetra>) time series analysis software.
It provides functions allowing to model time series (create outlier regressors, user-defined calendar regressors,
UCARIMA models...), to test the presence of trading days or seasonal effects and also
to set specifications in pre-adjustment and benchmarking when using rjd3x13 or rjd3tramoseats.
person("Jean", "Palate", role = c("aut", "cre"),
email = "[email protected]"),
person("Alain", "Quartier-la-Tente", role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0001-7890-3857")))
Description: Interface around 'JDemetra+ 3.x' (<https://github.com/jdemetra/jdemetra-core>) seasonal adjustment software, STACE project.
It offers access to several functions to model time series (create outlier regressors, user-defined calendar regressors,
UCARIMA models...), to test the presence of trading days or seasonal effects and other tools around seasonal adjustment and
to set specifications around pre-adjustment (RegARIMA/X-13 and TRAMO/TRAMO-SEATS).
Depends:
R (>= 4.1.0)
R (>= 3.6.0)
Imports:
RProtoBuf (>= 0.4.20),
rJava (>= 1.0-6),
checkmate,
methods
RProtoBuf (>= 0.4.20),
rJava (>= 1.0-6),
checkmate,
methods
SystemRequirements: Java (>= 17)
License: EUPL
URL: https://github.com/rjdverse/rjd3toolkit, https://rjdverse.github.io/rjd3toolkit/
URL: https://github.com/rjdemetra/rjd3toolkit, https://rjdemetra.github.io/rjd3toolkit/
LazyData: TRUE
Suggests:
knitr,
rmarkdown
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
BugReports: https://github.com/rjdverse/rjd3toolkit/issues
BugReports: https://github.com/rjdemetra/rjd3toolkit/issues
Encoding: UTF-8
Collate:
'utils.R'
Expand Down
9 changes: 3 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ to [Semantic Versioning](https://semver.org/spec/v3.2.3.html).

## [Unreleased]

### Fixed
[Unreleased]: https://github.com/rjdemetra/rjd3toolkit/compare/v3.2.3...HEAD

- Correct SA decomposition with backcasts and forecasts (Java to R transfer) [#2](https://github.com/rjdverse/rjd3tramoseats/issues/2)
## [3.2.3] - 2023-12-12

## [3.2.2] - 2024-03-15

[Unreleased]: https://github.com/rjdverse/rjd3toolkit/compare/v3.2.2...HEAD
[3.2.2]: https://github.com/rjdverse/rjd3toolkit/releases/tag/v3.2.2
[3.2.3]: https://github.com/rjdemetra/rjd3toolkit/releases/tag/v3.2.3
6 changes: 3 additions & 3 deletions R/calendars.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ SINGLEDAY<-'JD3_SINGLEDAY'
}

.length_ts <- function(s){
if (is.mts(s)){
if(is.mts(s)){
nrow(s)
}else{
length(s)
Expand Down Expand Up @@ -294,7 +294,7 @@ special_day<-function(event, offset=0, weight=1, validity=NULL){
}

.group_names <- function(x, contrasts = TRUE){
if (!is.matrix(x))
if(!is.matrix(x))
return(x)
col_names <- seq_len(ncol(x)) - !contrasts #if !contrast then it starts from 0
colnames(x) <- sprintf("group_%i", col_names)
Expand Down Expand Up @@ -734,7 +734,7 @@ national_calendar <- function(days, mean_correction=TRUE){
#' More information on calendar correction in JDemetra+ online documentation:
#' \url{https://jdemetra-new-documentation.netlify.app/}
calendar_td<-function(calendar,frequency, start, length, s, groups=c(1,2,3,4,5,6,0), holiday=7, contrasts=TRUE){
if (! is(calendar, 'JD3_CALENDAR')) stop('Invalid calendar')
if(! is(calendar, 'JD3_CALENDAR')) stop('Invalid calendar')
if (!missing(s) && is.ts(s)) {
frequency <- stats::frequency(s)
start <- stats::start(s)
Expand Down
28 changes: 14 additions & 14 deletions R/display.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ print.JD3_SARIMA_ESTIMATION<-function(x, digits = max(3L, getOption("digits") -
cat("\n")

cat("\nCoefficients\n")
if (is.null(tables$coef_table)){
if(is.null(tables$coef_table)){
cat("No SARIMA variables\n")
} else if (ncol(tables$coef_table) == 2){
} else if(ncol(tables$coef_table) == 2){
print(tables$coef_table)
} else{
printCoefmat(tables$coef_table[-2], digits = digits,
Expand Down Expand Up @@ -95,9 +95,9 @@ print.summary.JD3_SARIMA_ESTIMATION<-function(x, digits = max(3L, getOption("dig

cat("\n")
cat("\nCoefficients\n")
if (is.null(x$coef_table)){
if(is.null(x$coef_table)){
cat("No SARIMA variables\n")
} else if (ncol(x$coef_table) == 2){
} else if(ncol(x$coef_table) == 2){
print(x$coef_table)
} else{
printCoefmat(x$coef_table[-2], digits = digits, signif.stars = signif.stars,
Expand Down Expand Up @@ -126,7 +126,7 @@ print.summary.JD3_SARIMA_ESTIMATION<-function(x, digits = max(3L, getOption("dig
for(i in colnames(fr)){
fr[,i] <- unlist(fr[,i])
}
if (!is.null(cov) && !is.null(ndf)){
if(!is.null(cov) && !is.null(ndf)){
fr$pvalue <- fr$t <- fr$stde <- NA
stde<-sqrt(diag(cov))
sel<-fr$type=='ESTIMATED'
Expand All @@ -150,7 +150,7 @@ print.summary.JD3_SARIMA_ESTIMATION<-function(x, digits = max(3L, getOption("dig
.sarima_coef_table(x$description$arima, cov = cov, ndf = ndf, ...)
}
.sarima_coef_table.JD3_SARIMA_ESTIMATE <- function(x,...){
ndf<-x$likelihood$neffectiveobs-x$likelihood$nparams+1
ndf<-x$likelihood$neffectiveobs-x$likelihood$nparams
sarima_orders <- list(p = x$orders$order[1],
d = x$orders$order[2],
q = x$orders$order[3],
Expand Down Expand Up @@ -247,10 +247,10 @@ print.summary.JD3_LIKELIHOOD<-function(x, ...){
#' @rdname jd3_print
#' @export
print.JD3_REGARIMA_RSLTS<-function(x, digits = max(3L, getOption("digits") - 3L), ...){
cat("Log-transformation:",if (x$description$log) {"yes"} else {"no"},
cat("Log-transformation:",if(x$description$log) {"yes"} else {"no"},
"\n", sep=" ")

ndf<-x$estimation$likelihood$neffectiveobs-x$estimation$likelihood$nparams+1
ndf<-x$estimation$likelihood$neffectiveobs-x$estimation$likelihood$nparams
print(x$description$arima, cov = x$estimation$parameters$cov,
ndf = ndf,
digits = digits,
Expand Down Expand Up @@ -281,9 +281,9 @@ print.JD3_SARIMA_ESTIMATE<-function(x, digits = max(3L, getOption("digits") - 3L
cat("\n")

cat("\nCoefficients\n")
if (is.null(tables$coef_table)){
if(is.null(tables$coef_table)){
cat("No SARIMA variables\n")
} else if (ncol(tables$coef_table) == 2){
} else if(ncol(tables$coef_table) == 2){
print(tables$coef_table)
} else{
printCoefmat(tables$coef_table[-2], digits = digits,
Expand Down Expand Up @@ -312,7 +312,7 @@ print.JD3_SARIMA_ESTIMATE<-function(x, digits = max(3L, getOption("digits") - 3L
stde<-sqrt(diag(q$estimation$bvar))
sel<-xregs$type=='ESTIMATED'
t<-xregs$value[sel]/stde
ndf<-q$estimation$likelihood$neffectiveobs-q$estimation$likelihood$nparams+1
ndf<-q$estimation$likelihood$neffectiveobs-q$estimation$likelihood$nparams
pval<-2*pt(abs(t), ndf, lower.tail = FALSE)
xregs$stde[sel]<-stde
xregs$t[sel]<-t
Expand All @@ -325,7 +325,7 @@ print.JD3_SARIMA_ESTIMATE<-function(x, digits = max(3L, getOption("digits") - 3L
}
}
.regarima_coef_table.JD3_SARIMA_ESTIMATE <- function(x,...){
ndf<-x$likelihood$neffectiveobs-x$likelihood$nparams+1
ndf<-x$likelihood$neffectiveobs-x$likelihood$nparams

estimate <- x$b
if (length(estimate) > 0){
Expand All @@ -343,7 +343,7 @@ print.JD3_SARIMA_ESTIMATE<-function(x, digits = max(3L, getOption("digits") - 3L
#' @export
summary.JD3_REGARIMA_RSLTS<-function(object, ...){
log = object$description$log
ndf<-object$estimation$likelihood$neffectiveobs-object$estimation$likelihood$nparams+1
ndf<-object$estimation$likelihood$neffectiveobs-object$estimation$likelihood$nparams
sarima_sum <- summary(object$description$arima, cov = object$estimation$parameters$cov,
ndf = ndf, ...)
xregs = .regarima_coef_table(object, ...)
Expand All @@ -370,7 +370,7 @@ summary.JD3_SARIMA_ESTIMATE <-function(object, ...){
#' @export
print.summary.JD3_REGARIMA_RSLTS <- function(x, digits = max(3L, getOption("digits") - 3L), signif.stars = getOption("show.signif.stars"), ...){
if (!is.null(x$log))
cat("Log-transformation:",if (x$log) {"yes"} else {"no"},"\n",sep=" ")
cat("Log-transformation:",if(x$log) {"yes"} else {"no"},"\n",sep=" ")

print(x$sarima, digits = digits, signif.stars = signif.stars, ...)
cat("\n")
Expand Down
2 changes: 1 addition & 1 deletion R/procresults.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ result<-function(object, id){
#' @rdname dictionary
#' @export
user_defined <- function(object, userdefined = NULL){
if (is.null(userdefined)){
if(is.null(userdefined)){
result <- list()
} else{
result <- lapply(userdefined,
Expand Down
2 changes: 1 addition & 1 deletion R/protobuf.R
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ NULL
}

.regeffect<-function(map){
if (length(map) == 0)
if(length(map) == 0)
return("Undefined")
r<-which(sapply(map, function(z){z$key == "regeffect"}))
if (length(r) == 0) return("Undefined")
Expand Down
15 changes: 6 additions & 9 deletions R/regarima_generic.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ logLik.JD3_REGARIMA_RSLTS <- function(object, ...) {
is.null(object$likelihood$ll)) {
res <- NA
} else{
res <- structure(
object$likelihood$ll,
# df already contains variance of innovations
# so we didn't add +1 as in stats:::logLik.Arima()
df = object$likelihood$nparams,
nall = object$likelihood$nobs,
nobs = object$likelihood$neffectiveobs)
res <- structure(object$likelihood$ll,
df = object$likelihood$nparams,
nall = object$likelihood$nobs,
nobs = object$likelihood$neffectiveobs)
}
class(res) <- "logLik"
res
Expand All @@ -59,8 +56,8 @@ df.residual.JD3_REGARIMA_RSLTS <- function(object, ...){
return(NULL)
if (!is.null(object$estimation)) # for sarima_estimate outputs
object <- object$estimation
# Remove variance of innovations from parameters
object$likelihood$neffectiveobs - (object$likelihood$nparams - 1)

object$likelihood$neffectiveobs - object$likelihood$nparams
}
#' @export
nobs.JD3_REGARIMA_RSLTS <- function(object, ...){
Expand Down
4 changes: 2 additions & 2 deletions R/spec_benchmarking.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#' @param forecast Boolean indicating if the forecasts of the seasonally adjusted series and of the target variable (\code{target}) are used in the benchmarking computation so that the benchmarking constrain is also applied to the forecasting period.
#' @param bias TODO
#' @details
#' \code{x} specification param must be a JD3_X13_SPEC" class object generated with \code{rjd3x13::x13_spec()}
#' \code{x} specification param must be a JD3_X13_SPEC" class object generated with \code{rjd3x13::spec_x13()}
#' (or "JD3_REGARIMA_SPEC" generated with \code{rjd3x13::spec_regarima()} or "JD3_TRAMOSEATS_SPEC"
#' generated with \code{rjd3tramoseats::spec_tramoseats()} or "JD3_TRAMO_SPEC" generated with
#' \code{rjd3tramoseats::spec_tramo()}).
#' @examples
#' # init_spec <- rjd3x13::x13_spec("RSA5c")
#' # init_spec <- rjd3x13::spec_x13("RSA5c")
#' # new_spec<- set_benchmarking(init_spec,
#' # enabled = TRUE,
#' # target = "Normal",
Expand Down
Loading
Loading