Skip to content

Commit

Permalink
Merge pull request #24 from TanguyBarthelemy/develop
Browse files Browse the repository at this point in the history
Update DESCRIPTION with [art]
  • Loading branch information
clemasso authored Jul 11, 2024
2 parents d0a0620 + 4a5af4b commit 05d35e8
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 53 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Title: Interface to 'JDemetra+ 3.x' time series analysis software
Version: 2.0.1
Authors@R: c(
person("Jean", "Palate", role = c("aut", "cre"),
email = "jean.palate@nbb.be"))
email = "jean.palate@nbb.be"),
person("Tanguy", "Barthelemy", role = c("ctb", "art"),
email ="tanguy.barthelemy@insee.fr"))
Description: R Interface to 'JDemetra+ 3.x' (<https://github.com/jdemetra>) time series analysis software.
Depends:
R (>= 4.1.0)
Expand Down
8 changes: 4 additions & 4 deletions R/adl.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ adl_disaggregation<-function(series, constant=TRUE, trend=FALSE, indicators=NULL
}
} else if (is.ts(indicators)){
jlist[[1]]<-rjd3toolkit::.r2jd_tsdata(indicators)
} else{
} else {
stop("Invalid indicators")
}
jindicators<-.jarray(jlist, contents.class = "jdplus/toolkit/base/api/timeseries/TsData")
} else{
} else {
jindicators<-.jnull("[Ljdplus/toolkit/base/api/timeseries/TsData;")
}
jrslt<-.jcall("jdplus/benchmarking/base/r/TemporalDisaggregation", "Ljdplus/benchmarking/base/core/univariate/ADLResults;",
Expand Down Expand Up @@ -93,7 +93,7 @@ adl_disaggregation<-function(series, constant=TRUE, trend=FALSE, indicators=NULL
print.JD3AdlDisagg<-function(x, ...){
if (is.null(x$regression$model)){
cat("Invalid estimation")
} else{
} else {
cat("Model:", x$regression$type, "\n")
print(x$regression$model)

Expand All @@ -119,7 +119,7 @@ plot.JD3AdlDisagg<-function(x, ...){
if (is.null(x)){
cat("Invalid estimation")

} else{
} else {
td_series <- x$estimation$disagg

ts.plot(td_series, gpars = list(col=c("orange"), xlab = "", xaxt = "n", las = 2, ...))
Expand Down
14 changes: 7 additions & 7 deletions R/benchmark.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ denton<-function(s=NULL, t, d=1, mul=TRUE, nfreq=4, modified=TRUE,

if (!is.null(s)){
jd_s <- rjd3toolkit::.r2jd_tsdata(s)
} else{
} else {
jd_s<-as.integer(nfreq)
}
jd_rslt<-.jcall("jdplus/benchmarking/base/r/Benchmarking", "Ljdplus/toolkit/base/api/timeseries/TsData;", "denton",
jd_rslt<-.jcall("jdplus/benchmarking/base/r/Benchmarking", "Ljdplus/toolkit/base/api/timeseries/TsData;", "denton",
jd_s, jd_t, as.integer(d), mul, modified, conversion, as.integer(obsposition))
rjd3toolkit::.jd2r_tsdata(jd_rslt)
}
Expand Down Expand Up @@ -133,7 +133,7 @@ cubicspline<-function(s=NULL, t, nfreq=4,

if (!is.null(s)){
jd_s<-rjd3toolkit::.r2jd_tsdata(s)
} else{
} else {
jd_s<-as.integer(nfreq)
}
jd_rslt<-.jcall("jdplus/benchmarking/base/r/Benchmarking", "Ljdplus/toolkit/base/api/timeseries/TsData;", "cubicSpline",
Expand Down Expand Up @@ -163,7 +163,7 @@ cubicspline<-function(s=NULL, t, nfreq=4,
cholette<-function(s, t, rho=1, lambda=1, bias="None", conversion="Sum", obsposition=1){
jd_s<-rjd3toolkit::.r2jd_tsdata(s)
jd_t<-rjd3toolkit::.r2jd_tsdata(t)
jd_rslt<-.jcall("jdplus/benchmarking/base/r/Benchmarking", "Ljdplus/toolkit/base/api/timeseries/TsData;", "cholette",
jd_rslt<-.jcall("jdplus/benchmarking/base/r/Benchmarking", "Ljdplus/toolkit/base/api/timeseries/TsData;", "cholette",
jd_s, jd_t, rho, lambda, bias, conversion, as.integer(obsposition))
rjd3toolkit::.jd2r_tsdata(jd_rslt)
}
Expand All @@ -181,7 +181,7 @@ cholette<-function(s, t, rho=1, lambda=1, bias="None", conversion="Sum", obsposi
#'
#' @examples
multivariatecholette<-function(xlist, tcvector=NULL, ccvector=NULL, rho=1, lambda=1) {
if (!is.list(xlist) | length(xlist) < 3) {
if (!is.list(xlist) || length(xlist) < 3) {
stop("incorrect argument, first argument should be a list of at least 3 time series")}

#create the input
Expand All @@ -194,7 +194,7 @@ multivariatecholette<-function(xlist, tcvector=NULL, ccvector=NULL, rho=1, lambd
jtc<-.jcast(.jnull(), "[Ljava/lang/String;")
} else if (! is.vector(tcvector)){
stop("incorrect argument, constraints should be presented within a character vector")
} else{
} else {
ntc<-length(tcvector)
jtc<-.jarray(tcvector, "java/lang/String")
}
Expand All @@ -203,7 +203,7 @@ multivariatecholette<-function(xlist, tcvector=NULL, ccvector=NULL, rho=1, lambd
jcc<-.jcast(.jnull(), "[Ljava/lang/String;")
} else if (! is.vector(ccvector)){
stop("incorrect argument, constraints should be presented within a character vector")
} else{
} else {
ncc<-length(ccvector)
jcc<-.jarray(ccvector, "java/lang/String")
}
Expand Down
8 changes: 4 additions & 4 deletions R/calendarization.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ calendarization<-function(calendarobs, freq, start=NULL, end=NULL, dailyweights=
jcal<-rjd3toolkit::r2jd_calendarts(calendarobs)
if (is.null(dailyweights)){
jw<-.jnull("[D")
} else{
} else {
jw<-.jarray(as.numeric(dailyweights))
}
if (is.null(start)){
jstart<-.jnull("java/lang/String")
} else{
} else {
jstart<-as.character(start)
}
if (is.null(end)){
jend<-.jnull("java/lang/String")
} else{
} else {
jend<-as.character(end)
}
jrslt<-.jcall("jdplus/benchmarking/base/r/Calendarization", "Ljdplus/benchmarking/base/api/calendarization/CalendarizationResults;",
Expand All @@ -51,7 +51,7 @@ calendarization<-function(calendarobs, freq, start=NULL, end=NULL, dailyweights=
days<-rjd3toolkit::.proc_vector(jrslt, "days")
edays<-rjd3toolkit::.proc_vector(jrslt, "edays")
return(list(rslt=rslt, erslt=erslt, start = start, days=days, edays=edays))
} else{
} else {
rslt<-rjd3toolkit::.proc_ts(jrslt, "agg")
start<-as.Date(rjd3toolkit::.proc_str(jrslt, "start"))
days<-rjd3toolkit::.proc_vector(jrslt, "days")
Expand Down
16 changes: 8 additions & 8 deletions R/mbdenton.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ NULL
#' @param outliers a list of structured definition of the outlier periods and their intensity. The period must be submitted
#' first in the format YYYY-MM-DD and enclosed in quotation marks. This must be followed by an equal sign and
#' the intensity of the outlier, defined as the relative value of the 'innovation variances' (1= normal situation)
#' @param fixedBIratios a list of structured definition of the periods where the BI ratios must be fixed. The period must be
#' submitted first in the format YYYY-MM-DD and enclosed in quotation marks. This must be followed by an
#' @param fixedBIratios a list of structured definition of the periods where the BI ratios must be fixed. The period must be
#' submitted first in the format YYYY-MM-DD and enclosed in quotation marks. This must be followed by an
#' equal sign and the value of the BI ratio.
#' @return an object of class 'JD3MBDenton'
#' @export
Expand Down Expand Up @@ -59,19 +59,19 @@ denton_modelbased<-function(series, indicator, differencing=1, conversion=c("Sum
if (is.null(outliers)){
odates <- .jcast(.jnull(), "[Ljava/lang/String;")
ovars <- .jnull("[D")
} else{
} else {
odates <- .jarray(names(outliers))
ovars <- .jarray(as.numeric(outliers))
}
if (is.null(fixedBIratios)){
fdates <- .jcast(.jnull(), "[Ljava/lang/String;")
fvars <- .jnull("[D")
} else{
} else {
fdates <- .jarray(names(fixedBIratios))
fvars <- .jarray(as.numeric(fixedBIratios))
}
jrslt<-.jcall("jdplus/benchmarking/base/r/TemporalDisaggregation", "Ljdplus/benchmarking/base/core/univariate/ModelBasedDentonResults;",
"processModelBasedDenton", jseries, jindicator, as.integer(1), conversion, as.integer(conversion.obsposition), odates, ovars,
"processModelBasedDenton", jseries, jindicator, as.integer(1), conversion, as.integer(conversion.obsposition), odates, ovars,
fdates, fvars)
# Build the S3 result
estimation<-list(
Expand Down Expand Up @@ -104,7 +104,7 @@ denton_modelbased<-function(series, indicator, differencing=1, conversion=c("Sum
print.JD3MBDenton<-function(x, ...){
if (is.null(x$estimation$disagg)){
cat("Invalid estimation")
} else{
} else {
cat("Available estimates:\n")
print.default(names(x$estimation), ...)

Expand All @@ -130,7 +130,7 @@ summary.JD3MBDenton<-function(object, ...){
if (is.null(object)){
cat("Invalid estimation")

} else{
} else {
cat("\n")
cat("Likelihood statistics", "\n")
cat("\n")
Expand Down Expand Up @@ -165,7 +165,7 @@ plot.JD3MBDenton<-function(x, ...){
if (is.null(x)){
cat("Invalid estimation")

} else{
} else {
td<-x$estimation$disagg
td.sd<-x$estimation$edisagg
td.lb<-td - 1.96 * td.sd
Expand Down
16 changes: 8 additions & 8 deletions R/tempdisagg.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ temporaldisaggregation<-function(series, constant = TRUE, trend = FALSE, indic
}
} else if (is.ts(indicators)){
jlist[[1]]<-rjd3toolkit::.r2jd_tsdata(indicators)
} else{
} else {
stop("Invalid indicators")
}
jindicators<-.jarray(jlist, contents.class = "jdplus/toolkit/base/api/timeseries/TsData")
} else{
} else {
jindicators<-.jnull("[Ljdplus/toolkit/base/api/timeseries/TsData;")
}
jrslt<-.jcall("jdplus/benchmarking/base/r/TemporalDisaggregation", "Ljdplus/benchmarking/base/core/univariate/TemporalDisaggregationResults;",
Expand Down Expand Up @@ -180,7 +180,7 @@ temporaldisaggregationI<-function(series, indicator,
print.JD3TempDisagg<-function(x, ...){
if (is.null(x$regression$model)){
cat("Invalid estimation")
} else{
} else {
cat("Model:", x$regression$type, "\n")
print(x$regression$model)

Expand All @@ -205,7 +205,7 @@ print.JD3TempDisagg<-function(x, ...){
print.JD3TempDisaggI<-function(x, ...){
if (is.null(x$estimation$parameter)){
cat("Invalid estimation")
} else{
} else {
model<-data.frame(coef = c(round(x$regression$a, 4), round(x$regression$b, 4)))
row.names(model)<-c("a", "b")
print(model)
Expand Down Expand Up @@ -254,7 +254,7 @@ summary_disagg<-function(object){
if (is.null(object)){
cat("Invalid estimation")

} else{
} else {
cat("\n")
cat("Likelihood statistics", "\n")
cat("\n")
Expand Down Expand Up @@ -298,7 +298,7 @@ summary.JD3TempDisaggI<-function(object, ...){
if (is.null(object)){
cat("Invalid estimation")

} else{
} else {
cat("\n")
cat("Likelihood statistics", "\n")
cat("\n")
Expand Down Expand Up @@ -336,7 +336,7 @@ plot.JD3TempDisagg<-function(x, ...){
if (is.null(x)){
cat("Invalid estimation")

} else{
} else {
td_series <- x$estimation$disagg
reg_effect <- x$estimation$regeffect
smoothing_effect <- td_series - reg_effect
Expand Down Expand Up @@ -364,7 +364,7 @@ plot.JD3TempDisaggI<-function(x, ...){
if (is.null(x)){
cat("Invalid estimation")

} else{
} else {
td_series <- x$estimation$disagg
ts.plot(td_series, gpars=list(xlab="", ylab="disaggragated series", xaxt="n"))
axis(side=1, at=start(td_series)[1]:end(td_series)[1])
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#' @import RProtoBuf
#' @importFrom stats frequency is.ts pt start ts
#' @importFrom graphics axis legend par
#' @importFrom stats end ts.plot
#' @importFrom stats end ts.plot
NULL
4 changes: 2 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
NULL

.onLoad <- function(libname, pkgname) {

if (!requireNamespace("rjd3toolkit", quietly = TRUE)) stop("Loading rjd3 libraries failed")

result <- rJava::.jpackage(pkgname, lib.loc=libname)
if (!result) stop("Loading java packages failed")

Expand Down
14 changes: 14 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,28 @@ Temporal disaggregation

Running rjd3 packages requires **Java 17 or higher**. How to set up such a configuration in R is explained [here](https://jdemetra-new-documentation.netlify.app/#Rconfig)


### Latest release

To get the current stable version (from the latest release):

- From GitHub:

```{r, echo = TRUE, eval = FALSE}
# install.packages("remotes")
remotes::install_github("rjdverse/rjd3toolkit@*release")
remotes::install_github("rjdverse/rjd3bench@*release")
```

- From [r-universe](https://rjdverse.r-universe.dev/rjd3bench):

```{r, echo = TRUE, eval = FALSE}
install.packages("rjd3bench", repos = c("https://rjdverse.r-universe.dev", "https://cloud.r-project.org"))
```


### Development version

To get the current development version from GitHub:

```{r, echo = TRUE, eval = FALSE}
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,26 @@ Running rjd3 packages requires **Java 17 or higher**. How to set up such
a configuration in R is explained
[here](https://jdemetra-new-documentation.netlify.app/#Rconfig)

### Latest release

To get the current stable version (from the latest release):

- From GitHub:

``` r
# install.packages("remotes")
remotes::install_github("rjdverse/rjd3toolkit@*release")
remotes::install_github("rjdverse/rjd3bench@*release")
```

- From [r-universe](https://rjdverse.r-universe.dev/rjd3bench):

``` r
install.packages("rjd3bench", repos = c("https://rjdverse.r-universe.dev", "https://cloud.r-project.org"))
```

### Development version

To get the current development version from GitHub:

``` r
Expand Down
18 changes: 0 additions & 18 deletions man/adl_disaggregation.Rd

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

0 comments on commit 05d35e8

Please sign in to comment.