[Splm-commits] r110 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 9 21:49:01 CEST 2011


Author: the_sculler
Date: 2011-05-09 21:49:01 +0200 (Mon, 09 May 2011)
New Revision: 110

Modified:
   pkg/ChangeLog
   pkg/DESCRIPTION
   pkg/NAMESPACE
   pkg/R/sarREmod.R
   pkg/R/sarem2REmod.R
   pkg/R/saremREmod.R
   pkg/R/saremmod.R
   pkg/R/sarmod.R
   pkg/R/sem2REmod.R
   pkg/R/semREmod.R
   pkg/R/semmod.R
   pkg/R/spgm.R
   pkg/R/sphtest.R
   pkg/man/spgm.Rd
Log:
New wrapper function 'spml' for all ML based estimators. Syntax made consistent with 'plm'. Slight modifications to 'spgm' and 'sphtest' too.



Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/ChangeLog	2011-05-09 19:49:01 UTC (rev 110)
@@ -1,5 +1,12 @@
+Changes in Version 0.9-01
+  o spml as common wrapper for all ML based estimators
+  o fixed syntax in spgm and sphtest for consistency with spml (essentially: 'model=c("within", "random", "pooling")' argument as in 'plm')
+  o reordered arguments in estimators according to specification logic: formula, data, model type, effects, spatial error and lag
+  o changed names for error and lag components in 'spreml' according to 'spgm' nomenclature: spatial lag is lambda, error is rho. RE variance ratio stays phi.
+
 Changes in Version 0.8-03
   o fixed the joint bsktest, pvalue comes now from pchibar{ibdreg}; added dependency on 'ibdreg' but nothing in NAMESPACE because 'ibdreg' doesn't have one
+
 Changes in Version 0.8-02
   o fixed the bsktest, now only formula methods and correct pvals
 	

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/DESCRIPTION	2011-05-09 19:49:01 UTC (rev 110)
@@ -1,6 +1,6 @@
 Package: splm
 Title: Econometric Models for Spatial Panel Data
-Version: 0.8-03
+Version: 0.9-01
 Date: 2011-05-06
 Author: Giovanni Millo <giovanni.millo at generali.com>, Gianfranco Piras <gpiras at mac.com>
 Maintainer: Giovanni Millo <giovanni.millo at generali.com>

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/NAMESPACE	2011-05-09 19:49:01 UTC (rev 110)
@@ -8,7 +8,7 @@
 
 export(bsktest, sphtest,
 effects.splm, print.effects.splm, write.effects.splm, 
-print.splm, spfeml, spgm, spreml, summary.splm, sphtest, listw2dgCMatrix)
+print.splm, spml, spfeml, spgm, spreml, summary.splm, sphtest, listw2dgCMatrix)
 
 
 

Modified: pkg/R/sarREmod.R
===================================================================
--- pkg/R/sarREmod.R	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/R/sarREmod.R	2011-05-09 19:49:01 UTC (rev 110)
@@ -25,7 +25,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("phi", "psi")
+    nam.errcomp <- c("phi", "lambda")
 
     ## initialize values for optimizer
     myparms0 <- coef0
@@ -158,11 +158,11 @@
 
     ## final parms
     betas <- as.vector(beta[[1]])
-    arcoef <- myparms[which(nam.errcomp=="psi")]  # lag-specific line
-    errcomp <- myparms[which(nam.errcomp!="psi")]
+    arcoef <- myparms[which(nam.errcomp=="lambda")]  # lag-specific line
+    errcomp <- myparms[which(nam.errcomp!="lambda")]
     names(betas) <- nam.beta
-    names(arcoef) <- "psi"                        # lag-specific line
-    names(errcomp) <- nam.errcomp[which(nam.errcomp!="psi")]
+    names(arcoef) <- "lambda"                        # lag-specific line
+    names(errcomp) <- nam.errcomp[which(nam.errcomp!="lambda")]
 
     dimnames(covB) <- list(nam.beta, nam.beta)
     dimnames(covAR) <- list(names(arcoef), names(arcoef))

Modified: pkg/R/sarem2REmod.R
===================================================================
--- pkg/R/sarem2REmod.R	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/R/sarem2REmod.R	2011-05-09 19:49:01 UTC (rev 110)
@@ -22,7 +22,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("phi", "lambda", "psi")
+    nam.errcomp <- c("phi", "rho", "lambda")
 
     ## initialize values for optimizer
     myparms0 <- coef0
@@ -140,11 +140,11 @@
 
     ## final parms
     betas <- as.vector(beta[[1]])
-    arcoef <- myparms[which(nam.errcomp=="psi")]  # lag-specific line
-    errcomp <- myparms[which(nam.errcomp!="psi")]
+    arcoef <- myparms[which(nam.errcomp=="lambda")]  # lag-specific line
+    errcomp <- myparms[which(nam.errcomp!="lambda")]
     names(betas) <- nam.beta
-    names(arcoef) <- "psi"                        # lag-specific line
-    names(errcomp) <- nam.errcomp[which(nam.errcomp!="psi")]
+    names(arcoef) <- "lambda"                        # lag-specific line
+    names(errcomp) <- nam.errcomp[which(nam.errcomp!="lambda")]
 
     dimnames(covB) <- list(nam.beta, nam.beta)
     dimnames(covAR) <- list(names(arcoef), names(arcoef))

Modified: pkg/R/saremREmod.R
===================================================================
--- pkg/R/saremREmod.R	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/R/saremREmod.R	2011-05-09 19:49:01 UTC (rev 110)
@@ -22,7 +22,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("phi", "lambda", "psi")
+    nam.errcomp <- c("phi", "rho", "lambda")
 
     ## initialize values for optimizer
     myparms0 <- coef0
@@ -138,11 +138,11 @@
 
     ## final parms
     betas <- as.vector(beta[[1]])
-    arcoef <- myparms[which(nam.errcomp=="psi")]  # lag-specific line
-    errcomp <- myparms[which(nam.errcomp!="psi")]
+    arcoef <- myparms[which(nam.errcomp=="lambda")]  # lag-specific line
+    errcomp <- myparms[which(nam.errcomp!="lambda")]
     names(betas) <- nam.beta
-    names(arcoef) <- "psi"                        # lag-specific line
-    names(errcomp) <- nam.errcomp[which(nam.errcomp!="psi")]
+    names(arcoef) <- "lambda"                        # lag-specific line
+    names(errcomp) <- nam.errcomp[which(nam.errcomp!="lambda")]
 
     dimnames(covB) <- list(nam.beta, nam.beta)
     dimnames(covAR) <- list(names(arcoef), names(arcoef))

Modified: pkg/R/saremmod.R
===================================================================
--- pkg/R/saremmod.R	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/R/saremmod.R	2011-05-09 19:49:01 UTC (rev 110)
@@ -22,7 +22,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("lambda", "psi")
+    nam.errcomp <- c("rho", "lambda")
 
     ## initialize values for optimizer
     myparms0 <- coef0
@@ -128,11 +128,11 @@
 
     ## final parms
     betas <- as.vector(beta[[1]])
-    arcoef <- myparms[which(nam.errcomp=="psi")]  # lag-specific line
-    errcomp <- myparms[which(nam.errcomp!="psi")]
+    arcoef <- myparms[which(nam.errcomp=="lambda")]  # lag-specific line
+    errcomp <- myparms[which(nam.errcomp!="lambda")]
     names(betas) <- nam.beta
-    names(arcoef) <- "psi"                        # lag-specific line
-    names(errcomp) <- nam.errcomp[which(nam.errcomp!="psi")]
+    names(arcoef) <- "lambda"                        # lag-specific line
+    names(errcomp) <- nam.errcomp[which(nam.errcomp!="lambda")]
 
     dimnames(covB) <- list(nam.beta, nam.beta)
     dimnames(covAR) <- list(names(arcoef), names(arcoef))

Modified: pkg/R/sarmod.R
===================================================================
--- pkg/R/sarmod.R	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/R/sarmod.R	2011-05-09 19:49:01 UTC (rev 110)
@@ -21,7 +21,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("psi")
+    nam.errcomp <- c("lambda")
 
     ## initialize values for optimizer
     myparms0 <- coef0
@@ -108,11 +108,11 @@
 
     ## final parms
     betas <- as.vector(beta[[1]])
-    arcoef <- myparms[which(nam.errcomp=="psi")]  # lag-specific line
+    arcoef <- myparms[which(nam.errcomp=="lambda")]  # lag-specific line
     errcomp <- NULL                               # ols.errors-specific
     names(betas) <- nam.beta
-    names(arcoef) <- "psi"                        # lag-specific line
-    #names(errcomp) <- nam.errcomp[which(nam.errcomp!="psi")]
+    names(arcoef) <- "lambda"                        # lag-specific line
+    #names(errcomp) <- nam.errcomp[which(nam.errcomp!="lambda")]
 
     dimnames(covB) <- list(nam.beta, nam.beta)
     dimnames(covAR) <- list(names(arcoef), names(arcoef))

Modified: pkg/R/sem2REmod.R
===================================================================
--- pkg/R/sem2REmod.R	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/R/sem2REmod.R	2011-05-09 19:49:01 UTC (rev 110)
@@ -21,7 +21,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("phi", "lambda")
+    nam.errcomp <- c("phi", "rho")
 
     ## initialize values for optimizer
     myparms0 <- coef0

Modified: pkg/R/semREmod.R
===================================================================
--- pkg/R/semREmod.R	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/R/semREmod.R	2011-05-09 19:49:01 UTC (rev 110)
@@ -19,7 +19,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("phi", "lambda")
+    nam.errcomp <- c("phi", "rho")
 
     ## initialize values for optimizer
     myparms0 <- coef0

Modified: pkg/R/semmod.R
===================================================================
--- pkg/R/semmod.R	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/R/semmod.R	2011-05-09 19:49:01 UTC (rev 110)
@@ -19,7 +19,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("lambda")
+    nam.errcomp <- c("rho")
 
     ## initialize values for optimizer
     myparms0 <- coef0

Modified: pkg/R/spgm.R
===================================================================
--- pkg/R/spgm.R	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/R/spgm.R	2011-05-09 19:49:01 UTC (rev 110)
@@ -1,7 +1,10 @@
 `spgm` <-
-function(formula, data=list(), index=NULL, listw, 
-moments = c("initial", "weights", "fullweights"), lag = FALSE, endog = NULL, instruments= NULL, verbose = FALSE, method = c("w2sls", "b2sls", "g2sls", "ec2sls"), spatial.error=FALSE, effects = c("fixed","random"), control = list()){
+function(formula, data=list(), index=NULL, listw,
+         model=c("within","random"), lag=FALSE, spatial.error=FALSE,
+         moments = c("initial", "weights", "fullweights"), endog = NULL, instruments= NULL, verbose = FALSE, method = c("w2sls", "b2sls", "g2sls", "ec2sls"), control = list()){
 
+## translation for uniformity
+effects <- switch(match.arg(model), within="fixed", random="random")
 
 #source('utilities_GM.R')
 #source('listw2dgCMatrix.R')
@@ -1093,4 +1096,4 @@
 	
 	
 	
-	
\ No newline at end of file
+	

Modified: pkg/R/sphtest.R
===================================================================
--- pkg/R/sphtest.R	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/R/sphtest.R	2011-05-09 19:49:01 UTC (rev 110)
@@ -4,12 +4,12 @@
     UseMethod("sphtest")
 }
 
-sphtest.formula <- function (x, data, index = NULL, listw, model = c("lag", "error", "sarar"), method = c("ML", "GM"), errors = c("KKP", "BSK"),...)
+sphtest.formula <- function (x, data, index = NULL, listw, spatial.model = c("lag", "error", "sarar"), method = c("ML", "GM"), errors = c("KKP", "BSK"),...)
 {
  ## performs a Hausman test of a FE model with spatial lag or error
  ## against "alternative" with same spatial specification
 
-    model <- switch(match.arg(model),
+    switch(match.arg(spatial.model),
     lag = {
     	lag = TRUE
     	spatial.error = FALSE
@@ -33,17 +33,17 @@
 
     ML = {
     	
-    femod <- spml(x, data = data, index = index, listw = listw, lag = lag, spatial.error = spatial.error, effects = "fixed", errors = errors)
+    femod <- spml(x, data = data, index = index, listw = listw, lag = lag, spatial.error = spatial.error, model = "within", errors = errors)
 
-    remod <- spml(x, data = data, index = index, listw = listw, lag = lag, spatial.error = spatial.error, effects = "random", errors = errors)
+    remod <- spml(x, data = data, index = index, listw = listw, lag = lag, spatial.error = spatial.error, model = "random", errors = errors)
   	
     	},
     	
     GM = {
     	
-  femod <- spgm(x, data = data, index = index, listw = listw, lag = lag, spatial.error = spatial.error, effects = "fixed", moments = "fullweights")
+  femod <- spgm(x, data = data, index = index, listw = listw, lag = lag, spatial.error = spatial.error, model = "within", moments = "fullweights")
   
-  remod <- spgm(x, data = data, index = index, listw = listw, lag = lag, spatial.error = spatial.error, effects = "random", moments = "fullweights")
+  remod <- spgm(x, data = data, index = index, listw = listw, lag = lag, spatial.error = spatial.error, model = "random", moments = "fullweights")
     	
     	},	
     

Modified: pkg/man/spgm.Rd
===================================================================
--- pkg/man/spgm.Rd	2011-05-07 16:56:50 UTC (rev 109)
+++ pkg/man/spgm.Rd	2011-05-09 19:49:01 UTC (rev 110)
@@ -20,11 +20,11 @@
 }
 
 \usage{
-spgm(formula, data=list(), index=NULL, listw, 
-moments = c("initial", "weights", "fullweights"), lag=FALSE, endog = NULL, 
-instruments= NULL, verbose = FALSE, 
-method = c("w2sls", "b2sls", "g2sls", "ec2sls"), 
-spatial.error=FALSE, effects = c("fixed","random"), control = list())
+spgm(formula, data=list(), index=NULL, listw,
+         model=c("within","random"), lag=FALSE, spatial.error=FALSE,
+         moments = c("initial", "weights", "fullweights"), endog = NULL,
+         instruments= NULL, verbose = FALSE,
+         method = c("w2sls", "b2sls", "g2sls", "ec2sls"), control = list())
 }
 
 \arguments{
@@ -35,15 +35,17 @@
   \item{index}{if not NULL (default), a character vector to identify the indexes among the columns of the \code{\link{data.frame}}}
   \item{listw}{an object of class \code{listw} created for example by \code{nb2listw}. 
   If a \code{matrix} is given as input the function will transform it using \code{mat2listw}}
+  \item{model}{One of \code{"within"} or \code{"random"}. The assumption
+    made on the individual effects}
+  \item{lag}{if \code{TRUE} a spatial lag of the dependent variable is
+    added to the regression equation}
+  \item{spatial.error}{a logic vector. If \code{TRUE} the spatial autoregressive error term is added to the model and an estimate for \eqn{\rho} is produced}
   \item{moments}{\code{"initial"} (default) defines the set of GM estimator to be used. Alternatives are  
   \code{"weights"} and \code{"fullweights"} (See Details)}
-  \item{lag}{if \code{TRUE} a spatial lag of the dependent variable is added to the regression equation}
   \item{endog}{default \code{NULL}. A string with the name of additional (other than the spatial lag) endogenous variables}
   \item{instruments}{default \code{NULL}. Either a matrix or a string with the name of the specific instruments for the additional endogenous variables}
   \item{verbose}{default \code{FALSE}, If \code{TRUE} reports function values during optimization}  
   \item{method}{One of \code{"w2sls"}, \code{"b2sls"}, \code{"g2sls"}, \code{"ec2sls"}. (See Details)}
-  \item{spatial.error}{a logic vector. If \code{TRUE} the spatial autoregressive error term is added to the model and an estimate for \eqn{\rho} is produced}
-  \item{effects}{One of \code{"fixed"} or \code{"random"}. The assumption made on the individual effects}
   \item{control}{a list of control parameters for the optimization}
 }
 



More information about the Splm-commits mailing list