[Splm-commits] r239 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 12 19:29:10 CEST 2022


Author: the_sculler
Date: 2022-07-12 19:29:10 +0200 (Tue, 12 Jul 2022)
New Revision: 239

Modified:
   pkg/R/fixed_effects.R
   pkg/R/sparseBmethods.R
Log:
Fixed if() conditions comparing class() to string


Modified: pkg/R/fixed_effects.R
===================================================================
--- pkg/R/fixed_effects.R	2022-07-12 17:20:23 UTC (rev 238)
+++ pkg/R/fixed_effects.R	2022-07-12 17:29:10 UTC (rev 239)
@@ -203,8 +203,8 @@
 	
 effects.splm<-function(object,...){
 	x<-object
-	if (class(x) != "splm") stop(paste("methos not implemented for objects of class", class(x)))
-	if (class(x) != "splm" && (x$type != "fixed effects lag" || x$type != "fixed effects error")) stop(paste("methos not implemented for objects of type", x$type))
+	if (!inherits(x, "splm")) stop(paste("methos not implemented for objects of class", class(x)))
+	if (!inherits(x, "splm") && (x$type != "fixed effects lag" || x$type != "fixed effects error")) stop(paste("methos not implemented for objects of type", x$type))
 	all.FE<-x$res.eff[[1]]
 	effects <- x$effects
 if (effects=="pooled") stop("No fixed effects available if effects == pooled")

Modified: pkg/R/sparseBmethods.R
===================================================================
--- pkg/R/sparseBmethods.R	2022-07-12 17:20:23 UTC (rev 238)
+++ pkg/R/sparseBmethods.R	2022-07-12 17:29:10 UTC (rev 239)
@@ -93,7 +93,7 @@
         I <- diag.spam(1, n, n)
         B <- I - lambda * csrw
         J1 <- try(determinant(B, logarithm = TRUE)$modulus, silent = TRUE)
-        if (class(J1) == "try-error") {
+        if (class(J1)[1] == "try-error") {
             ## fall back on standard methods
             ldetB <- log(det(as.matrix(B)))
             warning("Bad result in calculating log(det(B))")



More information about the Splm-commits mailing list