[Splm-commits] r216 - in pkg: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 10 20:23:58 CEST 2017


Author: the_sculler
Date: 2017-09-10 20:23:58 +0200 (Sun, 10 Sep 2017)
New Revision: 216

Modified:
   pkg/NAMESPACE
   pkg/R/bsktest.R
   pkg/R/ivsplm.R
   pkg/R/spfeml.R
   pkg/R/spgm.R
   pkg/R/spreml.R
Log:
Substituted lme with spreml in bsktest; plm.data with pdata.frame


Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2017-09-10 15:44:19 UTC (rev 215)
+++ pkg/NAMESPACE	2017-09-10 18:23:58 UTC (rev 216)
@@ -7,7 +7,6 @@
 importFrom("plm", "pdata.frame")
 importFrom(stats, model.matrix, model.response, aggregate, effects)
 importFrom(stats, optim, nlminb)
-importFrom(plm, plm.data)
 importFrom(plm, plm)
 importFrom(plm, pmodel.response)
 importFrom(plm, pdim)

Modified: pkg/R/bsktest.R
===================================================================
--- pkg/R/bsktest.R	2017-09-10 15:44:19 UTC (rev 215)
+++ pkg/R/bsktest.R	2017-09-10 18:23:58 UTC (rev 216)
@@ -18,6 +18,12 @@
 function(x, data, index=NULL, listw,
          test=c("LMH","LM1","LM2","CLMlambda","CLMmu"),
          standardize=FALSE, method = "eigen", ...){
+
+  ## transform data if needed
+  if(!("pdata.frame" %in% class(data))) {
+    data <- pdata.frame(data, index)
+  }
+
   
 switch(match.arg(test), LM1 = {
     
@@ -57,10 +63,10 @@
     # if(standardize) stop("Standardized SLM1 test temporarily unavailable:
     # \n use 'standardize=FALSE' for LM1 test instead")
     
-  if(!is.null(index)) { ####can be deleted when using the wrapper
+  #if(!is.null(index)) { ####can be deleted when using the wrapper
     #require(plm)
-    data <- plm.data(data, index)
-    }
+  #  data <- plm.data(data, index)
+  #  }
 
 tr<-function(R) sum(diag(R))
 fun<-function(Q) tapply(Q,inde1,sum)
@@ -156,12 +162,13 @@
 
 `slm2test` <-
 function(formula, data, index=NULL, listw, standardize, ...){
-    # if(standardize) stop("Standardized SLM2 test temporarily unavailable: \n use 'standardize=FALSE' for LM2 test instead")
-                                              
-  if(!is.null(index)) { 
+    # if(standardize) stop("Standardized SLM2 test temporarily unavailable: \n use 'standardize=FALSE' for LM2 test instead")                  
+
+
+  #if(!is.null(index)) { 
     #require(plm)
-    data <- plm.data(data, index)
-    }
+  #  data <- plm.data(data, index)
+  #  }
 
   index <- data[,1]
   tindex <- data[,2]
@@ -254,10 +261,11 @@
     ## depends on listw2dgCMatrix.R
   #require(ibdreg) # for mixed chisquare distribution
   # now imported
-  if(!is.null(index)) { ####can be deleted when using the wrapper
+
+  #if(!is.null(index)) { ####can be deleted when using the wrapper
     #require(plm)
-    data <- plm.data(data, index)
-    }
+  #  data <- plm.data(data, index)
+  #  }
 
   index <- data[,1]
   tindex <- data[,2]
@@ -353,9 +361,9 @@
     ml <- spreml(formula=formula, data=data, index=index, w=listw,
                  errors="sem", lag=F)
                                                         
-	 if(!is.null(index)) {
-    data <- plm.data(data, index)
-    }
+    #if(!is.null(index)) {
+    # data <- plm.data(data, index)
+    #}
 
   index <- data[,1]
   tindex <- data[,2]
@@ -458,16 +466,20 @@
 {
    # ml <- spreml(formula, data = data, w = listw2mat(listw),
    #     errors = "re")
-    if (!is.null(index)) {
+    #if (!is.null(index)) {
         #require(plm)
-        data <- plm.data(data, index)
-    }
+    #    data <- plm.data(data, index)
+    #}
     index <- data[, 1]
     tindex <- data[, 2]
     data$tindex <- tindex
 
-	ml <- lme(formula, data, random=~1|tindex)
+	#ml <- lme(formula, data, random=~1|tindex)
 
+    ## modified to get rid of lme problems with "inner_perc_table" 
+    ml <- spreml(formula=formula, data=data, index=index, w=listw,
+                 errors="re", lag=F)
+    
     X <- model.matrix(formula, data = data)
     y <- model.response(model.frame(formula, data = data))
     names(index) <- row.names(data)

Modified: pkg/R/ivsplm.R
===================================================================
--- pkg/R/ivsplm.R	2017-09-10 15:44:19 UTC (rev 215)
+++ pkg/R/ivsplm.R	2017-09-10 18:23:58 UTC (rev 216)
@@ -4,11 +4,17 @@
 if(length(method) !=1 && effects == "fixed") method <- "w2sls" 	
 if(length(method) !=1 && effects == "random") method <- "ec2sls" 	
 		
- if(!is.null(index)) {
+ #if(!is.null(index)) {
     #require(plm)
-    data <- plm.data(data, index)
-    }
-  
+ #   data <- plm.data(data, index)
+ #   }
+
+ ## substituted module based on plm.data (deprecated)
+ ## with one based on pdata.frame
+  if(!("pdata.frame" %in% class(data))) {
+    data <- pdata.frame(data, index)
+  } 
+ 
   index <- data[,1]
   tindex <- data[,2]
 

Modified: pkg/R/spfeml.R
===================================================================
--- pkg/R/spfeml.R	2017-09-10 15:44:19 UTC (rev 215)
+++ pkg/R/spfeml.R	2017-09-10 18:23:58 UTC (rev 216)
@@ -29,11 +29,17 @@
 	  
 	  
 	  ## reorder data if needed
-  if(!is.null(index)) {
+  #if(!is.null(index)) {
     #require(plm)
-    data <- plm.data(data, index)
-    }
+  #  data <- plm.data(data, index)
+  #  }
 
+## data transform with pdata.frame (plm.data deprecated)
+  ## transform data if needed
+  if(!("pdata.frame" %in% class(data))) {
+    data <- pdata.frame(data, index)
+  }
+
   index <- data[,1]
   tindex <- data[,2]
 

Modified: pkg/R/spgm.R
===================================================================
--- pkg/R/spgm.R	2017-09-10 15:44:19 UTC (rev 215)
+++ pkg/R/spgm.R	2017-09-10 18:23:58 UTC (rev 216)
@@ -175,11 +175,17 @@
 moments<-match.arg(moments)
 indes<-index
 
- if(!is.null(index)) {
+ #if(!is.null(index)) {
     #require(plm)
-    data <- plm.data(data, index)
-    }
-  
+ #   data <- plm.data(data, index)
+ #   }
+
+ ## substituted module based on plm.data (deprecated)
+ ## with one based on pdata.frame
+  if(!("pdata.frame" %in% class(data))) {
+    data <- pdata.frame(data, index)
+  }   
+
   index <- data[,1]
   tindex <- data[,2]
 
@@ -656,10 +662,16 @@
 moments<-match.arg(moments)
 indes<-index
 
- if(!is.null(index)) {
+ #if(!is.null(index)) {
     #require(plm)
-    data <- plm.data(data, index)
-    }
+ #   data <- plm.data(data, index)
+ #   }
+
+ ## substituted module based on plm.data (deprecated)
+ ## with one based on pdata.frame
+  if(!("pdata.frame" %in% class(data))) {
+    data <- pdata.frame(data, index)
+  } 
   
   index <- data[,1]
   tindex <- data[,2]

Modified: pkg/R/spreml.R
===================================================================
--- pkg/R/spreml.R	2017-09-10 15:44:19 UTC (rev 215)
+++ pkg/R/spreml.R	2017-09-10 18:23:58 UTC (rev 216)
@@ -8,10 +8,10 @@
 {
 
     trace <- as.numeric(!quiet)
-    if (!is.null(index)) {
+    #if (!is.null(index)) { # done below
         #require(plm)
-        data <- plm.data(data, index)
-    }
+    #    data <- plm.data(data, index)
+    #}
     #index <- data[, 1]
     #tindex <- data[, 2]
     cl <- match.call()



More information about the Splm-commits mailing list