[Vars-commits] r114 - in pkg: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 19 12:19:58 CET 2023


Author: bpfaff
Date: 2023-03-19 12:19:58 +0100 (Sun, 19 Mar 2023)
New Revision: 114

Modified:
   pkg/DESCRIPTION
   pkg/NAMESPACE
   pkg/R/A.R
   pkg/R/B.R
   pkg/R/BQ.R
   pkg/R/Phi.svarest.R
   pkg/R/Phi.svecest.R
   pkg/R/Phi.varest.R
   pkg/R/Phi.vec2var.R
   pkg/R/Psi.varest.R
   pkg/R/Psi.vec2var.R
   pkg/R/SVAR.R
   pkg/R/SVEC.R
   pkg/R/arch.R
   pkg/R/causality.R
   pkg/R/fanchart.R
   pkg/R/fevd.svarest.R
   pkg/R/fevd.svecest.R
   pkg/R/fevd.varest.R
   pkg/R/fevd.vec2var.R
   pkg/R/fitted.vec2var.R
   pkg/R/internal.R
   pkg/R/irf.svarest.R
   pkg/R/irf.svecest.R
   pkg/R/irf.varest.R
   pkg/R/irf.vec2var.R
   pkg/R/normality.R
   pkg/R/residuals.vec2var.R
   pkg/R/restrict.R
   pkg/R/roots.R
   pkg/R/serial.R
   pkg/R/vec2var.R
Log:
Fixed class checks with is()


Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/DESCRIPTION	2023-03-19 11:19:58 UTC (rev 114)
@@ -2,10 +2,11 @@
 Type: Package
 Title: VAR Modelling
 Version: 1.5-7
-Date: 2023-03-12
+Date: 2023-03-19
 Authors at R: c(person("Bernhard", "Pfaff", email = "bernhard at pfaffikus.de", role = c("aut", "cre")), person("Matthieu", "Stigler", role = "ctb"))
 Depends: R (>= 2.0.0), MASS, strucchange, urca (>= 1.1-6), lmtest (>=
         0.9-26), sandwich (>= 2.2-4)
+Imports: methods
 LazyLoad: yes
 Description: Estimation, lag selection, diagnostic testing, forecasting, causality analysis, forecast error variance decomposition and impulse response functions of VAR models and estimation of SVAR and SVEC models.
 License: GPL (>= 2)

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/NAMESPACE	2023-03-19 11:19:58 UTC (rev 114)
@@ -87,6 +87,6 @@
            "plot.ts", "predict", "printCoefmat", "qnorm", "quantile",
            "resid", "residuals", "rnorm", "update", "vcov")
 importFrom("utils", "head", "tail")
-
+importFrom("methods", "is")
 import(MASS)
 import(strucchange)

Modified: pkg/R/A.R
===================================================================
--- pkg/R/A.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/A.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,7 +1,7 @@
 "Acoef" <-
 function (x) 
 {
-    if (!(class(x) == "varest")) {
+    if (!is(x, "varest")) {
         stop("\nPlease provide an object of class 'varest', generated by 'var()'.\n")
     }
     K <- x$K

Modified: pkg/R/B.R
===================================================================
--- pkg/R/B.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/B.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "Bcoef" <-
 function(x){
-  if(!(class(x)=="varest")){
+  if(!is(x, "varest")){
     stop("\nPlease provide an object of class 'varest', generated by 'var()'.\n")
   }
   y.names <- colnames(x$datamat[, c(1 : x$K)])

Modified: pkg/R/BQ.R
===================================================================
--- pkg/R/BQ.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/BQ.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "BQ" <-
 function(x){
-    if (!class(x) == "varest") {
+    if (!is(x, "varest")) {
         stop("\nPlease, provide an object of class 'varest',\n generated by function 'VAR()' as input for 'x'.\n")
     }
     Amats <- Acoef(x)

Modified: pkg/R/Phi.svarest.R
===================================================================
--- pkg/R/Phi.svarest.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/Phi.svarest.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "Phi.svarest" <-
 function(x, nstep = 10, ...){
-  if(!(class(x)=="svarest")){
+  if(!is(x, "svarest")){
     stop("\nPlease provide an object of class 'svarest', generated by 'SVAR()'.\n")
   }
   nstep <- abs(as.integer(nstep))

Modified: pkg/R/Phi.svecest.R
===================================================================
--- pkg/R/Phi.svecest.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/Phi.svecest.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "Phi.svecest" <-
 function(x, nstep = 10, ...){
-  if(!(class(x)=="svecest")){
+  if(!is(x, "svecest")){
     stop("\nPlease provide an object of class 'svecest', generated by 'SVEC()'.\n")
   }
   nstep <- abs(as.integer(nstep))

Modified: pkg/R/Phi.varest.R
===================================================================
--- pkg/R/Phi.varest.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/Phi.varest.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "Phi.varest" <-
 function(x, nstep=10, ...){
-  if(!(class(x)=="varest")){
+  if(!is(x, "varest")){
     stop("\nPlease provide an object of class 'varest', generated by 'VAR()'.\n")
   }
   nstep <- abs(as.integer(nstep))

Modified: pkg/R/Phi.vec2var.R
===================================================================
--- pkg/R/Phi.vec2var.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/Phi.vec2var.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "Phi.vec2var" <-
 function(x, nstep=10, ...){
-  if(!(class(x)=="vec2var")){
+  if(!is(x, "vec2var")){
     stop("\nPlease provide an object of class 'vec2var', generated by 'vec2var()'.\n")
   }
   nstep <- abs(as.integer(nstep))

Modified: pkg/R/Psi.varest.R
===================================================================
--- pkg/R/Psi.varest.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/Psi.varest.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "Psi.varest" <-
 function(x, nstep=10, ...){
-  if(!(class(x)=="varest")){
+  if(!is(x, "varest")){
     stop("\nPlease provide an object of class 'varest', generated by 'VAR()'.\n")
   }
   nstep <- abs(as.integer(nstep))

Modified: pkg/R/Psi.vec2var.R
===================================================================
--- pkg/R/Psi.vec2var.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/Psi.vec2var.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "Psi.vec2var" <-
 function(x, nstep=10, ...){
-  if(!(class(x)=="vec2var")){
+  if(!is(x, "vec2var")){
     stop("\nPlease provide an object of class 'vec2var', generated by 'vec2var()'.\n")
   }
   nstep <- abs(as.integer(nstep))

Modified: pkg/R/SVAR.R
===================================================================
--- pkg/R/SVAR.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/SVAR.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -3,7 +3,7 @@
     Bmat = NULL, start = NULL, max.iter = 100, conv.crit = 1e-07, 
     maxls = 1, lrtest = TRUE, ...) 
 {
-    if (!class(x) == "varest") {
+    if (!is(x, "varest")) {
         stop("\nPlease, provide an object of class 'varest',\n generated by function 'VAR()' as input for 'x'.\n")
     }
     call <- match.call()

Modified: pkg/R/SVEC.R
===================================================================
--- pkg/R/SVEC.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/SVEC.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "SVEC" <-
 function(x, LR = NULL, SR = NULL, r = 1, start = NULL, max.iter = 100, conv.crit = 1e-07, maxls = 1, lrtest = TRUE, boot = FALSE, runs = 100){
-  if (!(class(x) == "ca.jo")) {
+  if (!is(x, "ca.jo")) {
     stop("\nPlease, provide object of class 'ca.jo' as 'z'.\n")
   }
   if((is.null(LR)) || (is.null(SR))){

Modified: pkg/R/arch.R
===================================================================
--- pkg/R/arch.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/arch.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "arch.test" <-
 function(x, lags.single = 16, lags.multi = 5, multivariate.only = TRUE){
-  if(!((class(x)=="varest") || (class(x)=="vec2var"))){
+  if(!(is(x, "varest") || is(x, "vec2var"))){
     stop("\nPlease provide an object of class 'varest', generated by 'var()', or an object of class 'vec2var' generated by 'vec2var()'.\n")
   }
   obj.name <- deparse(substitute(x))

Modified: pkg/R/causality.R
===================================================================
--- pkg/R/causality.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/causality.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 causality <-
 function(x, cause = NULL, vcov.=NULL, boot=FALSE, boot.runs=100){
-  if(!(class(x)=="varest")){
+  if(!is(x, "varest")){
     stop("\nPlease provide an object of class 'varest', generated by 'var()'.\n")
   }
   K <- x$K

Modified: pkg/R/fanchart.R
===================================================================
--- pkg/R/fanchart.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/fanchart.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,7 +1,8 @@
 "fanchart" <-
 function(x, colors = NULL, cis = NULL, names = NULL, main = NULL, ylab = NULL, xlab = NULL, col.y = NULL, nc, plot.type = c("multiple", "single"), mar = par("mar"), oma = par("oma"), ...){
-  if(!(class(x) == "varprd"))
-    stop("\nPlease provide an object of class 'varprd',\ngenerated by predict-method for objects of class 'varest'.\n")
+  if(!is(x, "varprd")){
+      stop("\nPlease provide an object of class 'varprd',\ngenerated by predict-method for objects of class 'varest'.\n")
+      }
   if(is.null(colors))
     colors <- gray(sqrt(seq(from = 0.05, to = 1.0, length = 9))) 
   if(is.null(cis)){

Modified: pkg/R/fevd.svarest.R
===================================================================
--- pkg/R/fevd.svarest.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/fevd.svarest.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "fevd.svarest" <-
 function(x, n.ahead=10, ...){
-  if(!(class(x)=="svarest")){
+  if(!is(x, "svarest")){
     stop("\nPlease provide an object of class 'svarest', generated by 'SVAR()'.\n")
   }
   n.ahead <- abs(as.integer(n.ahead))

Modified: pkg/R/fevd.svecest.R
===================================================================
--- pkg/R/fevd.svecest.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/fevd.svecest.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "fevd.svecest" <-
 function(x, n.ahead=10, ...){
-  if(!(class(x)=="svecest")){
+  if(!is(x, "svecest")){
     stop("\nPlease provide an object of class 'svecest', generated by 'SVEC()'.\n")
   }
   n.ahead <- abs(as.integer(n.ahead))

Modified: pkg/R/fevd.varest.R
===================================================================
--- pkg/R/fevd.varest.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/fevd.varest.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "fevd.varest" <-
 function(x, n.ahead=10, ...){
-  if(!(class(x)=="varest")){
+  if(!is(x, "varest")){
     stop("\nPlease provide an object of class 'varest', generated by 'VAR()'.\n")
   }
   n.ahead <- abs(as.integer(n.ahead))

Modified: pkg/R/fevd.vec2var.R
===================================================================
--- pkg/R/fevd.vec2var.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/fevd.vec2var.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "fevd.vec2var" <-
 function(x, n.ahead=10, ...){
-  if(!(class(x)=="vec2var")){
+  if(!is(x, "vec2var")){
     stop("\nPlease provide an object of class 'vec2var', generated by 'vec2var()'.\n")
   }
   n.ahead <- abs(as.integer(n.ahead))

Modified: pkg/R/fitted.vec2var.R
===================================================================
--- pkg/R/fitted.vec2var.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/fitted.vec2var.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "fitted.vec2var" <-
 function(object, ...){
-  if (!(class(object) == "vec2var")) {
+  if (!is(object, "vec2var")) {
     stop("\nPlease, provide object of class 'vec2var' as 'object'.\n")
   }
   resids <- resid(object)

Modified: pkg/R/internal.R
===================================================================
--- pkg/R/internal.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/internal.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -84,13 +84,13 @@
 ##
 ".irf" <-
 function(x, impulse, response, y.names, n.ahead, ortho, cumulative){
-  if((class(x) == "varest") || (class(x) == "vec2var")){
+  if(is(x, "varest") || is(x, "vec2var")){
     if(ortho){
       irf <- Psi(x, nstep = n.ahead)
     } else {
       irf <- Phi(x, nstep = n.ahead)
     }
-  } else if((class(x) == "svarest") || (class(x) == "svecest")){
+  } else if(is(x, "svarest") || is(x, "svecest")){
     irf <- Phi(x, nstep = n.ahead)
   }
   dimnames(irf) <- list(y.names, y.names, NULL)
@@ -118,9 +118,9 @@
 ".boot" <-
 function(x, n.ahead, runs, ortho, cumulative, impulse, response, ci, seed, y.names){
   if(!(is.null(seed))) set.seed(abs(as.integer(seed)))
-  if(class(x) == "varest"){
+  if(is(x, "varest")){
     VAR <- eval.parent(x)
-  }else if(class(x) == "svarest"){
+  }else if(is(x, "svarest")){
     VAR <- eval.parent(x$var)
   } else {
     stop("Bootstrap not implemented for this class.\n")
@@ -152,7 +152,7 @@
       lasty <- c(ysampled[j + p, ], lasty) 
     }
     varboot <- update(VAR, y = ysampled)
-    if(class(x) == "svarest"){
+    if(is(x, "svarest")){
       varboot <- update(x, x = varboot)
     }
     BOOT[[i]] <- .irf(x = varboot, n.ahead = n.ahead, ortho = ortho, cumulative = cumulative, impulse = impulse, response = response, y.names=y.names)

Modified: pkg/R/irf.svarest.R
===================================================================
--- pkg/R/irf.svarest.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/irf.svarest.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "irf.svarest" <-
 function(x, impulse=NULL, response=NULL, n.ahead=10, ortho=TRUE, cumulative=FALSE, boot=TRUE, ci=0.95, runs=100, seed=NULL, ...){
-  if(!(class(x)=="svarest")){
+  if(!is(x, "svarest")){
     stop("\nPlease provide an object of class 'svarest', generated by 'SVAR()'.\n")
   }
   y.names <- colnames(x$var$y)

Modified: pkg/R/irf.svecest.R
===================================================================
--- pkg/R/irf.svecest.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/irf.svecest.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "irf.svecest" <-
 function(x, impulse=NULL, response=NULL, n.ahead=10, ortho=TRUE, cumulative=FALSE, boot=TRUE, ci=0.95, runs=100, seed=NULL, ...){
-  if(!(class(x)=="svecest")){
+  if(!is(x, "svecest")){
     stop("\nPlease provide an object of class 'svecest', generated by 'SVEC()'.\n")
   }
   y.names <- colnames(x$var at x)

Modified: pkg/R/irf.varest.R
===================================================================
--- pkg/R/irf.varest.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/irf.varest.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "irf.varest" <-
 function(x, impulse=NULL, response=NULL, n.ahead=10, ortho=TRUE, cumulative=FALSE, boot=TRUE, ci=0.95, runs=100, seed=NULL, ...){
-  if(!(class(x)=="varest")){
+  if(!is(x, "varest")){
     stop("\nPlease provide an object of class 'varest', generated by 'VAR()'.\n")
   }
   y.names <- colnames(x$y)

Modified: pkg/R/irf.vec2var.R
===================================================================
--- pkg/R/irf.vec2var.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/irf.vec2var.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "irf.vec2var" <-
 function(x, impulse=NULL, response=NULL, n.ahead=10, ortho=TRUE, cumulative=FALSE, boot=TRUE, ci=0.95, runs=100, seed=NULL, ...){
-  if(!(class(x)=="vec2var")){
+  if(!is(x, "vec2var")){
     stop("\nPlease provide an object of class 'vec2var', generated by 'vec2var()'.\n")
   }
   y.names <- colnames(x$y)

Modified: pkg/R/normality.R
===================================================================
--- pkg/R/normality.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/normality.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "normality.test" <-
 function(x, multivariate.only = TRUE){
-  if(!((class(x)=="varest") || (class(x)=="vec2var"))){
+  if(!(is(x, "varest") || is(x, "vec2var"))){
     stop("\nPlease provide an object of class 'varest', generated by 'var()', or an object of class 'vec2var' generated by 'vec2var()'.\n")
   }
   obj.name <- deparse(substitute(x))

Modified: pkg/R/residuals.vec2var.R
===================================================================
--- pkg/R/residuals.vec2var.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/residuals.vec2var.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "residuals.vec2var" <-
 function(object, ...){
-  if (!(class(object) == "vec2var")) {
+  if (!is(object, "vec2var")) {
     stop("\nPlease, provide object of class 'vec2var' as 'object'.\n")
   }
   resids <- object$datamat[, colnames(object$y)] - object$datamat[, colnames(object$deterministic)] %*% t(object$deterministic)

Modified: pkg/R/restrict.R
===================================================================
--- pkg/R/restrict.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/restrict.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,7 +1,7 @@
 "restrict" <- 
 function (x, method = c("ser", "manual"), thresh = 2, resmat = NULL) 
 {
-    if (!(class(x) == "varest")) {
+    if (!is(x, "varest")) {
         stop("\nPlease provide an object of class 'varest', generated by 'var()'.\n")
     }
     method <- match.arg(method)

Modified: pkg/R/roots.R
===================================================================
--- pkg/R/roots.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/roots.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "roots" <-
 function(x, modulus = TRUE){
-  if(!(class(x)=="varest")){
+  if(!is(x, "varest")){
     stop("\nPlease provide an object of class 'varest', generated by 'VAR()'.\n")
   }
   K <- x$K

Modified: pkg/R/serial.R
===================================================================
--- pkg/R/serial.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/serial.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "serial.test" <-
 function(x, lags.pt = 16, lags.bg = 5, type = c("PT.asymptotic", "PT.adjusted", "BG", "ES")){
-  if(!((class(x)=="varest") || (class(x)=="vec2var"))){
+  if(!(is(x, "varest") || is(x, "vec2var"))){
     stop("\nPlease provide an object of class 'varest', generated by 'var()', or an object of class 'vec2var' generated by 'vec2var()'.\n")
   }
   obj.name <- deparse(substitute(x))

Modified: pkg/R/vec2var.R
===================================================================
--- pkg/R/vec2var.R	2023-03-12 15:00:45 UTC (rev 113)
+++ pkg/R/vec2var.R	2023-03-19 11:19:58 UTC (rev 114)
@@ -1,6 +1,6 @@
 "vec2var" <-
 function(z, r = 1){
-  if (!(class(z) == "ca.jo")) {
+  if (!is(z, "ca.jo")) {
     stop("\nPlease, provide object of class 'ca.jo' as 'z'.\n")
   }
   r <- as.integer(r)



More information about the Vars-commits mailing list