Skip to content

Commit

Permalink
Merge pull request #25 from TanguyBarthelemy/develop
Browse files Browse the repository at this point in the history
T --> TRUE and F --> FALSE
  • Loading branch information
palatej committed Feb 2, 2024
2 parents fe44092 + d9561f9 commit 2c24b80
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 48 deletions.
4 changes: 2 additions & 2 deletions R/arima.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ arima_model<-function(name="arima", ar=1, delta=1, ma=1, variance=1){
.jarray(as.numeric(model$ar)),
.jarray(as.numeric(model$delta)),
.jarray(as.numeric(model$ma)),
as.numeric(model$var), F))
as.numeric(model$var), FALSE))
}

#' Sum ARIMA Models
Expand Down Expand Up @@ -236,7 +236,7 @@ arima_properties<-function(model, nspectrum=601, nacf=36){
#' @export
#'
#' @examples
ucarima_model<-function(model=NULL, components, complements=NULL, checkmodel=F){
ucarima_model<-function(model=NULL, components, complements=NULL, checkmodel=FALSE){
if (is.null(model))
model<-arima_lsum(components)
else if (! is(model, "JD3_ARIMA") && ! is(model, "JD3_SARIMA")) stop("Invalid model")
Expand Down
3 changes: 1 addition & 2 deletions R/calendars.R
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ weighted_calendar<-function(calendars, weights){
#' More information on calendar correction in JDemetra+ online documentation:
#' \url{https://jdemetra-new-documentation.netlify.app/}
#' @export
national_calendar<-function(days, mean_correction=T){
national_calendar<-function(days, mean_correction=TRUE){
if (! is.list(days)) stop ('Days should be a list of holidays')
return (structure(list(days=days, mean_correction=mean_correction), class=c('JD3_CALENDAR', 'JD3_CALENDARDEFINITION')))
}
Expand Down Expand Up @@ -836,4 +836,3 @@ print.JD3_WEIGHTEDCALENDAR <- function (x, ...)

return(invisible(x))
}

8 changes: 4 additions & 4 deletions R/display.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ print.summary.JD3_SARIMA_ESTIMATION<-function(x, digits = max(3L, getOption("dig
stde<-sqrt(diag(cov))
sel<-fr$type=='ESTIMATED'
t<-fr$value[sel]/stde
pval<-2*pt(abs(t), ndf, lower.tail = F)
pval<-2*pt(abs(t), ndf, lower.tail = FALSE)
fr$stde[sel]<-stde
fr$t[sel]<-t
fr$pvalue[sel]<-pval
Expand Down Expand Up @@ -163,7 +163,7 @@ print.summary.JD3_SARIMA_ESTIMATION<-function(x, digits = max(3L, getOption("dig
if (length(estimate) > 0){
stde <- sqrt(diag(x$parameters$cov))
t<-estimate/stde
pval<-2*pt(abs(t), ndf, lower.tail = F)
pval<-2*pt(abs(t), ndf, lower.tail = FALSE)
table <- data.frame(estimate, "ESTIMATED", stde, t, pval)
colnames(table) <- c("Estimate", "Type", "Std. Error",
"T-stat", "Pr(>|t|)")
Expand Down Expand Up @@ -313,7 +313,7 @@ print.JD3_SARIMA_ESTIMATE<-function(x, digits = max(3L, getOption("digits") - 3L
sel<-xregs$type=='ESTIMATED'
t<-xregs$value[sel]/stde
ndf<-q$estimation$likelihood$neffectiveobs-q$estimation$likelihood$nparams+1
pval<-2*pt(abs(t), ndf, lower.tail = F)
pval<-2*pt(abs(t), ndf, lower.tail = FALSE)
xregs$stde[sel]<-stde
xregs$t[sel]<-t
xregs$pvalue[sel]<-pval
Expand All @@ -331,7 +331,7 @@ print.JD3_SARIMA_ESTIMATE<-function(x, digits = max(3L, getOption("digits") - 3L
if (length(estimate) > 0){
stde <- sqrt(diag(x$bvar))
t<-estimate/stde
pval<-2*pt(abs(t), ndf, lower.tail = F)
pval<-2*pt(abs(t), ndf, lower.tail = FALSE)
table <- data.frame(estimate, "ESTIMATED", stde, t, pval)
colnames(table) <- c("Estimate", "Type", "Std. Error",
"T-stat", "Pr(>|t|)")
Expand Down
2 changes: 0 additions & 2 deletions R/jd2r.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,3 @@ NULL
, as.integer(period), as.integer(start[1]), as.integer(start[2]), as.integer(n))
return (jdom)
}


4 changes: 1 addition & 3 deletions R/modellingcontext.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ modelling_context<-function(calendars=NULL, variables=NULL){
if (any(mts_var)) {
# case of a simple mts dictionary
for (i in which(mts_var)) {
all_var <- lapply(1:ncol(variables[[i]]), function(j) {
all_var <- lapply(seq_len(ncol(variables[[i]])), function(j) {
variables[[i]][, j]
})
names(all_var) <- colnames(variables[[i]])
Expand Down Expand Up @@ -383,5 +383,3 @@ modelling_context<-function(calendars=NULL, variables=NULL){
p<-.r2p_context(r)
return (.p2jd_context(p))
}


4 changes: 1 addition & 3 deletions R/procresults.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RSLT<-'JD3_ProcResults'

#' @export
#' @rdname jd3_utilities
.jd3_object<-function(jobjRef, subclasses=NULL, result=F){
.jd3_object<-function(jobjRef, subclasses=NULL, result=FALSE){
if (result)
classes<-c(OBJ, RSLT, subclasses)
else
Expand Down Expand Up @@ -64,5 +64,3 @@ user_defined <- function(object, userdefined = NULL){
class(result) <- c("user_defined")
result
}


7 changes: 2 additions & 5 deletions R/protobuf.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ NULL
#' @rdname jd3_utilities
.p2r_ucarima<-function(p){
model<-.p2r_arima(p$model)
return (ucarima_model(model,lapply(p$components, function(z){.p2r_arima(z)}), lapply(p$complements, function(z){.p2r_arima(z)}), F))
return (ucarima_model(model,lapply(p$components, function(z){.p2r_arima(z)}), lapply(p$complements, function(z){.p2r_arima(z)}), FALSE))
}


Expand Down Expand Up @@ -459,7 +459,7 @@ NULL

#' @export
#' @rdname jd3_utilities
.p2r_sa_decomposition<-function(p, full=F){
.p2r_sa_decomposition<-function(p, full=FALSE){
if (full){
return (list(mode = .enum_extract(sa.DecompositionMode, p$mode),
series=.p2r_sa_component(p$series),
Expand Down Expand Up @@ -526,6 +526,3 @@ NULL
p$forecast<-r$forecast
return (p)
}



1 change: 0 additions & 1 deletion R/regarima_generic.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ residuals.JD3_REGARIMA_RSLTS <- function(object, ...){
object <- object$estimation
object$res
}

1 change: 0 additions & 1 deletion R/regarima_rslts.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ NULL
tnames<-lapply(p$residuals_tests, function(z){z$key})
testonresiduals<-`names<-`(tlist, tnames)
}

1 change: 0 additions & 1 deletion R/spec_regarima.R
Original file line number Diff line number Diff line change
Expand Up @@ -1549,4 +1549,3 @@ set_span <- function(x,
}
x
}

18 changes: 6 additions & 12 deletions R/tests_regular.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ print.JD3_TEST<-function(x, details=FALSE, ...){
#' ljungbox(random_t(2, 100), lag = 24, k =1)
#' ljungbox(ABS$X0.2.09.10.M, lag = 24, k =1)
#' @export
ljungbox<-function(data, k=1, lag=1, nhp=0, sign=0, mean=T){
ljungbox<-function(data, k=1, lag=1, nhp=0, sign=0, mean=TRUE){
jtest<-.jcall("jdplus/toolkit/base/r/stats/Tests", "Ljdplus/toolkit/base/api/stats/StatisticalTest;", "ljungBox",
as.numeric(data), as.integer(k), as.integer(lag), as.integer(nhp), as.integer(sign), as.logical(mean))
return (.jd2r_test(jtest))
Expand Down Expand Up @@ -112,7 +112,7 @@ doornikhansen<-function(data){

#' @export
#' @describeIn normality_tests Jarque-Bera test
jarquebera<-function(data, k=0, sample=T){
jarquebera<-function(data, k=0, sample=TRUE){
jtest<-.jcall("jdplus/toolkit/base/r/stats/Tests", "Ljdplus/toolkit/base/api/stats/StatisticalTest;", "jarqueBera",
as.numeric(data), as.integer(k), as.logical(sample))
return (.jd2r_test(jtest))
Expand Down Expand Up @@ -141,15 +141,15 @@ NULL

#' @describeIn runstests Runs test around mean or median
#' @export
testofruns<-function(data, mean=T, number=T){
testofruns<-function(data, mean=TRUE, number=TRUE){
jtest<-.jcall("jdplus/toolkit/base/r/stats/Tests", "Ljdplus/toolkit/base/api/stats/StatisticalTest;", "testOfRuns",
as.numeric(data), as.logical(mean), as.logical(number))
return (.jd2r_test(jtest))
}

#' @describeIn runstests up and down runs test
#' @export
testofupdownruns<-function(data, number=T){
testofupdownruns<-function(data, number=TRUE){
jtest<-.jcall("jdplus/toolkit/base/r/stats/Tests", "Ljdplus/toolkit/base/api/stats/StatisticalTest;", "testOfUpDownRuns",
as.numeric(data), as.logical(number))
return (.jd2r_test(jtest))
Expand All @@ -167,15 +167,15 @@ testofupdownruns<-function(data, number=T){
#' autocorrelations_partial(x)
#' autocorrelations_inverse(x)
#' @export
autocorrelations<-function(data, mean=T, n=15){
autocorrelations<-function(data, mean=TRUE, n=15){
res = .jcall("jdplus/toolkit/base/r/stats/Tests", "[D", "autocorrelations",
as.numeric(data), as.logical(mean), as.integer(n))
names(res) <- seq_len(n)
return (res)
}
#' @export
#' @rdname autocorrelations
autocorrelations_partial<-function(data, mean=T, n=15){
autocorrelations_partial<-function(data, mean=TRUE, n=15){
res <- .jcall("jdplus/toolkit/base/r/stats/Tests", "[D", "partialAutocorrelations",
as.numeric(data), as.logical(mean), as.integer(n))
names(res) <- seq_len(n)
Expand Down Expand Up @@ -217,9 +217,3 @@ kurtosis<-function(data){
mad<-function(data, centile=50, medianCorrected=TRUE){
return (.jcall("jdplus/toolkit/base/r/stats/Tests", "D", "mad",as.numeric(data), as.numeric(centile), as.logical(medianCorrected)))
}






1 change: 0 additions & 1 deletion R/tests_seasonality.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,3 @@ seasonality_canovahansen<-function(data, p0, p1, np, original=FALSE){
as.numeric(data), as.numeric(p0), as.numeric(p1), as.integer(np), as.logical(original))
return (jtest)
}

6 changes: 3 additions & 3 deletions R/timeseries.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ aggregate.default<-function(s, nfreq=1,
jd_s<-.r2jd_tsdata(s)
jd_agg<-.jcall("jdplus/toolkit/base/r/timeseries/TsUtility", "Ljdplus/toolkit/base/api/timeseries/TsData;", "aggregate", jd_s, as.integer(nfreq), conversion, complete)
if (is.jnull(jd_agg)){
return (NULL);
return (NULL)
}
else{
return (.jd2r_tsdata(jd_agg))
Expand Down Expand Up @@ -85,7 +85,7 @@ clean_extremities<-function(s){
jd_scleaned<-.jcall("jdplus/toolkit/base/r/timeseries/TsUtility", "Ljdplus/toolkit/base/api/timeseries/TsData;", "cleanExtremities", jd_s)

if (is.jnull(jd_scleaned)){
return (NULL);
return (NULL)
}
else{
return (.jd2r_tsdata(jd_scleaned))
Expand Down Expand Up @@ -167,7 +167,7 @@ ts_adjust.default<-function(s, method=c("LeapYear", "LengthOfPeriod"), reverse =
jd_s<-.r2jd_tsdata(s)
jd_st<-.jcall("jdplus/toolkit/base/r/modelling/Transformation", "Ljdplus/toolkit/base/api/timeseries/TsData;", "adjust", jd_s, method, as.logical(reverse))
if (is.jnull(jd_st)){
return (NULL);
return (NULL)
}
else{
return (.jd2r_tsdata(jd_st))
Expand Down
2 changes: 0 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,3 @@ likelihood<-function(nobs, neffectiveobs=NA, nparams=0, ll, adjustedll=NA, aic,
aic=aic, aicc=aicc, bic=bic, bicc=bicc, ssq=ssq),
class = "JD3_LIKELIHOOD"))
}


2 changes: 0 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ NULL
DATE_MAX<<-dateOf(9999, 12, 31)

}


10 changes: 6 additions & 4 deletions rjd3toolkit.Rproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: No

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
NumSpacesForTab: 4
Encoding: UTF-8

RnwWeave: Sweave
Expand All @@ -21,3 +21,5 @@ PackageInstallArgs: --no-multiarch --with-keep.source
PackageBuildBinaryArgs: --no-multiarch
PackageCheckArgs: --no-multiarch
PackageRoxygenize: rd,collate,namespace,vignette

UseNativePipeOperator: Yes

0 comments on commit 2c24b80

Please sign in to comment.