diff --git a/R/export_workspace.R b/R/export_workspace.R index b59567b..8339fad 100644 --- a/R/export_workspace.R +++ b/R/export_workspace.R @@ -22,7 +22,7 @@ #' @rdname new_workspace #' @export new_workspace <- function() { - dictionary = .jnull("jdr/spec/ts/Utility$Dictionary") + dictionary <- .jnull("jdr/spec/ts/Utility$Dictionary") wk <- .jcall("ec/tstoolkit/jdr/ws/Workspace", "Lec/tstoolkit/jdr/ws/Workspace;", "create", dictionary) @@ -314,7 +314,7 @@ complete_dictionary.jSA <- function(workspace, sa_obj){ core <- .jcast(core, "ec/satoolkit/x13/X13Specification") spec <- .jnew("jdr/spec/x13/X13Spec", core) } else{ - spec = sa_obj$spec + spec <- sa_obj$spec } } jregression <- spec$getRegression() diff --git a/R/init.R b/R/init.R index 9ddea8d..2dafe39 100644 --- a/R/init.R +++ b/R/init.R @@ -94,7 +94,7 @@ proc_dictionary<-function(name){ keys<-array(dim=size) jiter<-.jcall(jkeys, "Ljava/util/Iterator;", "iterator") for (i in 1:size){ - keys[i]=.jcall(.jcall(jiter, "Ljava/lang/Object;", "next"), "Ljava/lang/String;", "toString") + keys[i] <- .jcall(.jcall(jiter, "Ljava/lang/Object;", "next"), "Ljava/lang/String;", "toString") } return (keys) } diff --git a/R/regarima.R b/R/regarima.R index 04e2403..c95955b 100644 --- a/R/regarima.R +++ b/R/regarima.R @@ -476,7 +476,7 @@ regarima_X13 <- function(jrobj, spec){ residuals.stat = jd_results$residuals.stat, forecast = jd_results$forecast) - class(z) = c("regarima","X13") + class(z) <- c("regarima","X13") return(z) } @@ -513,6 +513,6 @@ regarima_TS <- function(jrobj, spec){ residuals.stat = jd_results$residuals.stat, forecast = jd_results$forecast) - class(z) = c("regarima","TRAMO_SEATS") + class(z) <- c("regarima","TRAMO_SEATS") return(z) } diff --git a/R/regarima_plot.R b/R/regarima_plot.R index 02d03a2..0644fed 100644 --- a/R/regarima_plot.R +++ b/R/regarima_plot.R @@ -2,7 +2,7 @@ #' @name plot #' @rdname plot #' @export -plot.regarima = function(x, which = 1:6, +plot.regarima <- function(x, which = 1:6, caption = list("Residuals", "Histogram of residuals", "Normal Q-Q", "ACF of residuals", "PACF of residuals", "Decomposition", list("Y linearised", "Calendar effects", "Outliers effects"))[sort(which)], @@ -22,9 +22,9 @@ plot.regarima = function(x, which = 1:6, "PACF of residuals", "Decomposition", list("Y linearised", "Calendar effects", "Outliers effects")) all_caption[which] <- caption - sub.caption = NULL - cex.caption = 1 - cex.oma.main = 1.25 + sub.caption <- NULL + cex.caption <- 1 + cex.oma.main <- 1.25 # Define additional variables for selected graphs: if (any(show[2L:3L])) { sres <- x$residuals / x$residuals.stat$st.error diff --git a/R/regarima_print.R b/R/regarima_print.R index e059e2f..c184c38 100644 --- a/R/regarima_print.R +++ b/R/regarima_print.R @@ -26,13 +26,13 @@ summary.regarima <- function(object, ...){ fvar <- fout <- NULL if (!is.null(arima_coef)){ - a_tvalues=matrix(2*(1 - pt(abs(arima_coef[,3]), loglik[3])),ncol=1) - colnames(a_tvalues)=c("Pr(>|t|)") + a_tvalues <- matrix(2*(1 - pt(abs(arima_coef[,3]), loglik[3])),ncol=1) + colnames(a_tvalues) <- c("Pr(>|t|)") arima_coef <- cbind(arima_coef,a_tvalues) } if (!is.null(reg_coef)){ - r_tvalues=matrix(2*(1 - pt(abs(reg_coef[,3]), loglik[3])),ncol=1) - colnames(r_tvalues)=c("Pr(>|t|)") + r_tvalues <- matrix(2*(1 - pt(abs(reg_coef[,3]), loglik[3])),ncol=1) + colnames(r_tvalues) <- c("Pr(>|t|)") reg_coef <- cbind(reg_coef, r_tvalues) } if (usr_spec[1] & usr_spec[2]){ @@ -172,20 +172,20 @@ print.regarima <- function (x, digits = max(3L, getOption("digits") - 3L), ...){ cat("Coefficients:") if (!is.null(arima_coef)){ if (!is.matrix(arima_coef[,-3])){ - tab.arima=t(as.matrix(arima_coef[,-3])) - rownames(tab.arima)=rownames(arima_coef) + tab.arima <- t(as.matrix(arima_coef[,-3])) + rownames(tab.arima) <- rownames(arima_coef) }else{ - tab.arima=arima_coef[,-3] + tab.arima <- arima_coef[,-3] } cat("\n") printCoefmat(tab.arima, digits = digits, P.values= FALSE, na.print = "NA", ...) } if (!is.null(reg_coef)){ if (!is.matrix(reg_coef[,-3])){ - tab.reg=t(as.matrix(reg_coef[,-3])) - rownames(tab.reg)=rownames(reg_coef) + tab.reg <- t(as.matrix(reg_coef[,-3])) + rownames(tab.reg) <- rownames(reg_coef) }else{ - tab.reg=reg_coef[,-3] + tab.reg <- reg_coef[,-3] } cat("\n") printCoefmat(tab.reg, digits = digits, P.values= FALSE, na.print = "NA", ...) @@ -235,7 +235,7 @@ print.regarima <- function (x, digits = max(3L, getOption("digits") - 3L), ...){ } # Method: "regarima_rtest" for the print #' @export -print.regarima_rtests=function (x, digits = max(3L, getOption("digits") - 3L), +print.regarima_rtests <- function (x, digits = max(3L, getOption("digits") - 3L), enable_print_style = getOption("enable_print_style"), ...){ if(enable_print_style){ bold_pre_code <- "\033[1m" @@ -249,15 +249,15 @@ print.regarima_rtests=function (x, digits = max(3L, getOption("digits") - 3L), stat <- x[,1] pval <- x[,2] - sigcode=vector(mode = "character", length = 6) - sigcode[pval >=0.1] = triplestar - sigcode[pval < 0.1 & pval >= 0.05] = doublestar - sigcode[pval < 0.05] = " " - tabstat=data.frame(stat,pval,sigcode) - rownames(tabstat)=rownames(x) - colnames(tabstat)=c("Statistic","P.value","") - tabstat[,1]=format(tabstat[,1], digits = digits) - tabstat[,2]=format(round(tabstat[,2],max(4,digits))) + sigcode <- vector(mode = "character", length = 6) + sigcode[pval >=0.1] <- triplestar + sigcode[pval < 0.1 & pval >= 0.05] <- doublestar + sigcode[pval < 0.05] <- " " + tabstat <- data.frame(stat,pval,sigcode) + rownames(tabstat) <- rownames(x) + colnames(tabstat) <- c("Statistic","P.value","") + tabstat[,1] <- format(tabstat[,1], digits = digits) + tabstat[,2] <- format(round(tabstat[,2],max(4,digits))) cat("\n") cat(bold_pre_code, diff --git a/R/regarima_rslts.R b/R/regarima_rslts.R index 36fccdc..c16414c 100644 --- a/R/regarima_rslts.R +++ b/R/regarima_rslts.R @@ -45,7 +45,7 @@ regarima_rslts <- function(jrobj, fcsth){ rownames(arima.coefficients) <- arma.description colnames(arima.coefficients) <- c("Estimate","Std. Error","T-stat") }else{ - arima.coefficients = NULL + arima.coefficients <- NULL } # Regression coefficients @@ -82,8 +82,8 @@ regarima_rslts <- function(jrobj, fcsth){ transformed <- as.logical(result(jrobj,"model.log")) mean <- "Mean" %in% rownames(regression.coefficients) ntd <- result(jrobj,"model.ntd") - if (is.null(result(jrobj,"model.lp"))){leap.year=FALSE} else {leap.year=TRUE} - if (is.null(result(jrobj,"model.easter"))){easter=FALSE} else {easter=TRUE} + if (is.null(result(jrobj,"model.lp"))){leap.year <- FALSE} else {leap.year <- TRUE} + if (is.null(result(jrobj,"model.easter"))){easter <- FALSE} else {easter <- TRUE} nout <- result(jrobj,"model.nout") spec_rslt <- data.frame(model, t.span, transformed, mean, ntd, leap.year, easter, nout, diff --git a/R/regarima_specTS.R b/R/regarima_specTS.R index 95d26eb..ebbd92e 100644 --- a/R/regarima_specTS.R +++ b/R/regarima_specTS.R @@ -575,7 +575,7 @@ regarima_spec_tramoseats.character <- function(spec = c("TRfull", "TR0", "TR1", # To check the mode of the remaining variables list.logical.usrdef <-list("usrdef.outliersEnabled","usrdef.varEnabled","arima.coefEnabled") - list.logical = list("preliminary.check", "estimate.eml","tradingdays.leapyear","easter.julian","easter.test","outlier.enabled","outlier.ao", + list.logical <- list("preliminary.check", "estimate.eml","tradingdays.leapyear","easter.julian","easter.test","outlier.enabled","outlier.ao", "outlier.tc","outlier.ls","outlier.so","outlier.usedefcv","outlier.eml","automdl.enabled", "automdl.acceptdefault","automdl.compare","arima.mu") list.logical.check <- append(list.logical.usrdef,list.logical) @@ -583,7 +583,7 @@ regarima_spec_tramoseats.character <- function(spec = c("TRfull", "TR0", "TR1", list.numeric.span <- list("estimate.first","estimate.last","estimate.exclFirst","estimate.exclLast", "outlier.first","outlier.last","outlier.exclFirst","outlier.exclLast","fcst.horizon") - list.numeric = list("estimate.tol","estimate.urfinal","transform.fct","tradingdays.pftd", + list.numeric <- list("estimate.tol","estimate.urfinal","transform.fct","tradingdays.pftd", "tradingdays.stocktd","easter.duration","outlier.cv","outlier.tcrate", "automdl.cancel","automdl.ub1","automdl.ub2","automdl.armalimit","automdl.reducecv", "automdl.ljungboxlimit","arima.p","arima.d","arima.q","arima.bp","arima.bd","arima.bq") @@ -667,7 +667,7 @@ regarima_spec_tramoseats.character <- function(spec = c("TRfull", "TR0", "TR1", arima=arima, forecast = forecast, span=span) - class(z) = c("regarima_spec","TRAMO_SEATS") + class(z) <- c("regarima_spec","TRAMO_SEATS") return(z) } # The function creates a ("regarima_spec","TRAMO_SEATS") class object from a regarima_Spec or a regarima object @@ -780,12 +780,12 @@ regarima_spec_tramoseats.TRAMO_SEATS <- function(spec, # To check the mode of the remaining variables - list.logical = list("preliminary.check","usrdef.outliersEnabled","usrdef.varEnabled","estimate.eml","tradingdays.leapyear", + list.logical <- list("preliminary.check","usrdef.outliersEnabled","usrdef.varEnabled","estimate.eml","tradingdays.leapyear", "easter.julian","easter.test","outlier.enabled","outlier.ao", "outlier.tc","outlier.ls","outlier.so","outlier.usedefcv","outlier.eml","automdl.enabled", "automdl.acceptdefault","automdl.compare","arima.mu","arima.coefEnabled") - list.numeric = list("estimate.first","estimate.last","estimate.exclFirst","estimate.exclLast", + list.numeric <- list("estimate.first","estimate.last","estimate.exclFirst","estimate.exclLast", "outlier.first","outlier.last","outlier.exclFirst","outlier.exclLast", "estimate.tol","estimate.urfinal","transform.fct","tradingdays.pftd", "tradingdays.stocktd","easter.duration","outlier.cv","outlier.tcrate", @@ -874,7 +874,7 @@ regarima_spec_tramoseats.TRAMO_SEATS <- function(spec, arima=arima, forecast = forecast, span=span) - class(z) = c("regarima_spec","TRAMO_SEATS") + class(z) <- c("regarima_spec","TRAMO_SEATS") return(z) } diff --git a/R/regarima_specX13.R b/R/regarima_specX13.R index 602f17e..2b22178 100644 --- a/R/regarima_specX13.R +++ b/R/regarima_specX13.R @@ -665,7 +665,7 @@ new_regarima_spec_x13 <- function(estimate = NULL, arima = arima, forecast = forecast, span = span) - class(z) = c("regarima_spec","X13") + class(z) <- c("regarima_spec","X13") z } reformat_spec_def <- function(x, parameter){ diff --git a/R/sa_plot.R b/R/sa_plot.R index 0d2fb16..c5042e6 100644 --- a/R/sa_plot.R +++ b/R/sa_plot.R @@ -42,7 +42,7 @@ #' @name plot #' @rdname plot #' @export -plot.decomposition_X11 = function(x, first_date, last_date, caption = "S-I ratio", ylim, ...){ +plot.decomposition_X11 <- function(x, first_date, last_date, caption = "S-I ratio", ylim, ...){ if (!inherits(x, "decomposition_X11")) stop("This function must only be used with a \"decomposition_X11\" object") @@ -74,9 +74,9 @@ plot.decomposition_X11 = function(x, first_date, last_date, caption = "S-I ratio }else if (freq==2) { leg<-c("H1","H2") } else { - leg=c("") + leg <- c("") } - yaxt="s" + yaxt <- "s" for (i in 1:freq){ mm <- cycle(d10)==i xd10 <- d10[mm] @@ -85,9 +85,9 @@ plot.decomposition_X11 = function(x, first_date, last_date, caption = "S-I ratio points(xd8, col="red", pch="*", xlab="") lines(rep(mean(xd10),length(xd10)), col="black", type="l", lty=1) legend(x = "bottom", legend=leg[i],inset = 0, bty="n") - yaxt = "n" + yaxt <- "n" par(cex = 0.7, mai = c(0.1,0,0.4,0)) - ylab = "" + ylab <- "" } mtext(caption[1], side = 3, col = "blue", outer = TRUE, line = -2) par(cex = op$cex, mai = op$mai, mfcol = op$mfcol, mfrow = op$mfrow) @@ -96,7 +96,7 @@ plot.decomposition_X11 = function(x, first_date, last_date, caption = "S-I ratio #' @name plot #' @rdname plot #' @export -plot.decomposition_SEATS = function(x, first_date, last_date, caption = "S-I ratio", ylim, ...){ +plot.decomposition_SEATS <- function(x, first_date, last_date, caption = "S-I ratio", ylim, ...){ if (!inherits(x, "decomposition_SEATS")) stop("This function must only be used with a \"decomposition_SEATS\" object") @@ -132,9 +132,9 @@ plot.decomposition_SEATS = function(x, first_date, last_date, caption = "S-I rat }else if (freq==2) { leg<-c("H1","H2") } else { - leg=c("") + leg <- c("") } - yaxt="s" + yaxt <- "s" for (i in 1:freq){ mm <- cycle(z)==i zm <- z[mm] @@ -142,9 +142,9 @@ plot.decomposition_SEATS = function(x, first_date, last_date, caption = "S-I rat lines(rep(mean(zm),length(zm)), col="black", type="l", lty=1) points(zm, col="red", pch="*", xlab="") legend(x = "bottom", legend=leg[i],inset = 0, bty="n") - yaxt = "n" + yaxt <- "n" par(cex=0.7, mai=c(0.1,0,0.4,0)) - ylab="" + ylab <- "" } mtext(caption[1], side = 3, col = "blue", outer = TRUE, line = -2) par(cex = op$cex, mai = op$mai, mfcol = op$mfcol, mfrow = op$mfrow) diff --git a/R/sa_print.R b/R/sa_print.R index 49970a7..e736b5f 100644 --- a/R/sa_print.R +++ b/R/sa_print.R @@ -1,5 +1,5 @@ #' @export -print.decomposition_X11=function (x, digits = max(3L, getOption("digits") - 3L), +print.decomposition_X11 <- function (x, digits = max(3L, getOption("digits") - 3L), enable_print_style = getOption("enable_print_style"), ...){ if(enable_print_style){ bold_pre_code <- "\033[1m" @@ -24,7 +24,7 @@ print.decomposition_X11=function (x, digits = max(3L, getOption("digits") - 3L), cat("\n") } #' @export -print.decomposition_SEATS=function (x, digits = max(3L, getOption("digits") - 3L), +print.decomposition_SEATS <- function (x, digits = max(3L, getOption("digits") - 3L), enable_print_style = getOption("enable_print_style"),...){ if(enable_print_style){ bold_pre_code <- "\033[1m" @@ -101,7 +101,7 @@ print.combined_test <- function(x, digits = max(3L, getOption("digits") - 3L), } #' @export -print.diagnostics = function (x, digits = max(3L, getOption("digits") - 3L), +print.diagnostics <- function (x, digits = max(3L, getOption("digits") - 3L), enable_print_style = getOption("enable_print_style"), ...){ diff --git a/R/saveSpec.R b/R/saveSpec.R index b8c4e8f..7edf837 100644 --- a/R/saveSpec.R +++ b/R/saveSpec.R @@ -84,7 +84,7 @@ #' @rdname save_spec #' @name save_spec #' @export -save_spec = function (object, file = file.path(tempdir(), "spec.RData")) { +save_spec <- function (object, file = file.path(tempdir(), "spec.RData")) { if (inherits(object, c("regarima","regarima_spec","SA","SA_spec"))==FALSE) stop("The function must only be used with \"regarima\", \"regarima_spec\", \"SA\" and \"SA_spec\" objects", call. = FALSE) @@ -154,14 +154,14 @@ load_spec <- function (file = "spec.RData") { arima.dsc <- rbind(s.arima.dsc,rep(NA,length(s.arima.dsc)),s.arima.dsc) forecast <- rbind(s.forecast,rep(NA,length(s.forecast)),s.forecast) - rownames(estimate)=c("Loaded","User_modif","Final") - rownames(transform)=c("Loaded","User_modif","Final") - rownames(usrdef)=c("Loaded","User_modif","Final") - rownames(trading.days)=c("Loaded","User_modif","Final") - rownames(easter)=c("Loaded","User_modif","Final") - rownames(outliers)=c("Loaded","User_modif","Final") - rownames(arima.dsc)=c("Loaded","User_modif","Final") - rownames(forecast)=c("Loaded","User_modif","Final") + rownames(estimate) <- c("Loaded","User_modif","Final") + rownames(transform) <- c("Loaded","User_modif","Final") + rownames(usrdef) <- c("Loaded","User_modif","Final") + rownames(trading.days) <- c("Loaded","User_modif","Final") + rownames(easter) <- c("Loaded","User_modif","Final") + rownames(outliers) <- c("Loaded","User_modif","Final") + rownames(arima.dsc) <- c("Loaded","User_modif","Final") + rownames(forecast) <- c("Loaded","User_modif","Final") userdef <-list(specification = usrdef, outliers = list(Predefined = s.predef.outliers, Final = s.predef.outliers), variables = list(Predefined = s.predef.variables, Final = s.predef.variables)) @@ -180,7 +180,7 @@ load_spec <- function (file = "spec.RData") { } else if (inherits(object,"SA_saveX13")){ class(regarima) <- c("regarima_spec","X13") x11 <- rbind(s.decomp,rep(NA,length(s.decomp )),s.decomp) - rownames(x11)=c("Loaded","User_modif","Final") + rownames(x11) <- c("Loaded","User_modif","Final") class(x11) <- c("X11_spec","data.frame") z <- list(regarima = regarima, x11 = x11) class(z) <- c("SA_spec","X13") @@ -188,7 +188,7 @@ load_spec <- function (file = "spec.RData") { } else { class(regarima) <- c("regarima_spec","TRAMO_SEATS") seats <- rbind(s.decomp,rep(NA,length(s.decomp )),s.decomp) - rownames(seats)=c("Loaded","User_modif","Final") + rownames(seats) <- c("Loaded","User_modif","Final") class(seats) <- c("seats_spec","data.frame") z <- list(regarima = regarima, seats = seats) class(z) <- c("SA_spec","TRAMO_SEATS") diff --git a/R/spec_rjd.R b/R/spec_rjd.R index f369da7..fdc3e91 100644 --- a/R/spec_rjd.R +++ b/R/spec_rjd.R @@ -847,9 +847,9 @@ preOut_r2jd <- function(jsobjct = NA, coefEna = NA, out = NA, outDate = NA, outC preVar_r2jd <- function(jsobjct = NA, jsdict = NA, coefEna = NA, prevar_spec = list(series = NA, description = data.frame(NA,NA)), jtd = NA) { - series = prevar_spec$series - varType = prevar_spec$description[,1] - varCoef = prevar_spec$description[,2] + series <- prevar_spec$series + varType <- prevar_spec$description[,1] + varCoef <- prevar_spec$description[,2] varNames <- rownames(prevar_spec$description) nvar <- if (is.mts(series)) {dim(series)[2]} else if (is.ts(series)) {1} else {0} @@ -861,7 +861,7 @@ preVar_r2jd <- function(jsobjct = NA, jsdict = NA, coefEna = NA, calendar_def <- grep("Calendar",type) n_calendar_def <- length(calendar_def) - jcoreg = jsobjct$getCore()$getRegression() + jcoreg <- jsobjct$getCore()$getRegression() if (nvar == 1){ if(n_calendar_def == 1){ diff --git a/R/tramoseats.R b/R/tramoseats.R index 68bef00..4383eca 100644 --- a/R/tramoseats.R +++ b/R/tramoseats.R @@ -150,7 +150,7 @@ tramoseats.SA_spec <- function(series, spec, }else{ # Error during the preliminary check - res = jrslt$getResults()$getProcessingInformation() + res <- jrslt$getResults()$getProcessingInformation() if(is.null(jrslt$getDiagnostics()) & !.jcall(res,"Z","isEmpty")){ proc_info <- jrslt$getResults()$getProcessingInformation() @@ -198,7 +198,7 @@ tramoseatsJavaResults <- function(jrslt, spec, return(NaN) # Error in preliminary check - res = jrslt$getResults()$getProcessingInformation() + res <- jrslt$getResults()$getProcessingInformation() if(is.null(jrslt$getDiagnostics()) & !.jcall(res,"Z","isEmpty")){ proc_info <- jrslt$getResults()$getProcessingInformation() diff --git a/R/x13.R b/R/x13.R index 5572092..e3f5dcf 100644 --- a/R/x13.R +++ b/R/x13.R @@ -145,7 +145,7 @@ x13.SA_spec <- function(series, spec, userdefined = NULL){ return(NaN) }else{ # Error with the preliminary check - res = jrslt$getResults()$getProcessingInformation() + res <- jrslt$getResults()$getProcessingInformation() if(is.null(jrslt$getDiagnostics()) & !.jcall(res,"Z","isEmpty")){ proc_info <- jrslt$getResults()$getProcessingInformation() @@ -192,7 +192,7 @@ x13JavaResults <- function(jrslt, spec, userdefined = NULL, } # Error during the preliminary check - res = jrslt$getResults()$getProcessingInformation() + res <- jrslt$getResults()$getProcessingInformation() if(is.null(jrslt$getDiagnostics()) & !.jcall(res,"Z","isEmpty")){ proc_info <- jrslt$getResults()$getProcessingInformation() error_msg <- .jcall(proc_info, "Ljava/lang/Object;", "get", 0L)$getErrorMessages(proc_info)