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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri May 20 00:17:45 CEST 2011


Author: the_sculler
Date: 2011-05-20 00:17:45 +0200 (Fri, 20 May 2011)
New Revision: 113

Added:
   pkg/R/bsjktest.R
   pkg/R/bsjktest.formula.R
   pkg/R/pbsjkARtest.R
   pkg/R/pbsjkJtest.R
   pkg/R/pbsjkSDtest.R
   pkg/man/bsjktest.Rd
Modified:
   pkg/ChangeLog
   pkg/DESCRIPTION
   pkg/NAMESPACE
   pkg/R/saremsrREmod.R
   pkg/R/saremsrmod.R
   pkg/R/sarsrREmod.R
   pkg/R/sarsrmod.R
   pkg/R/semsrREmod.R
   pkg/R/semsrmod.R
   pkg/R/ssrREmod.R
   pkg/R/ssrmod.R
   pkg/man/bsktest.Rd
   pkg/man/effects.splm.Rd
   pkg/man/print.splm.Rd
   pkg/man/splm-package.Rd
   pkg/man/spml.Rd
   pkg/man/summary.splm.Rd
   pkg/man/write.effects.splm.Rd
Log:
Reintroduced bsjktest, spreml-feml now invisible, various fixes



Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/ChangeLog	2011-05-19 22:17:45 UTC (rev 113)
@@ -1,3 +1,11 @@
+Changes in Version 0.9-03
+  o reinroduced bsjktest, excluding C.3; syntax harmonized with bsktest
+  o removed spreml, spfeml from namespace and documentation
+  o fixed documentation
+  o fixed parameter names in (hidden) spreml estimators: sr, semsr, srre and semsrre +/- sar (now phi=RE variance ratio, psi=AR, rho=SEM, lambda=SAR)
+  o fixed parameter names in functions calling spreml (pbsjkSDtest)
+
+
 Changes in Version 0.9-02
   o standardized versions of marginal bsktest reintroduced
   o all examples now on full 'Produc' dataset

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/DESCRIPTION	2011-05-19 22:17:45 UTC (rev 113)
@@ -1,7 +1,7 @@
 Package: splm
 Title: Econometric Models for Spatial Panel Data
-Version: 0.9-02
-Date: 2011-05-06
+Version: 0.9-03
+Date: 2011-05-19
 Author: Giovanni Millo <giovanni.millo at generali.com>, Gianfranco Piras <gpiras at mac.com>
 Maintainer: Giovanni Millo <giovanni.millo at generali.com>
 Description: ML and GM estimation and diagnostic testing of econometric models for spatial panel data.

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/NAMESPACE	2011-05-19 22:17:45 UTC (rev 113)
@@ -6,9 +6,9 @@
 importFrom(MASS,ginv)
 
 
-export(bsktest, sphtest,
+export(bsktest, sphtest, bsjktest,
 effects.splm, print.effects.splm, write.effects.splm, 
-print.splm, spml, spfeml, spgm, spreml, summary.splm, sphtest, listw2dgCMatrix)
+print.splm, spml, spgm, summary.splm, sphtest, listw2dgCMatrix)
 
 
 
@@ -17,6 +17,7 @@
 S3method(effects, splm)
 S3method(print, effects.splm)
 S3method(bsktest, formula)
+S3method(bsjktest, formula)
 S3method(sphtest, formula)
 S3method(sphtest, splm)
 

Added: pkg/R/bsjktest.R
===================================================================
--- pkg/R/bsjktest.R	                        (rev 0)
+++ pkg/R/bsjktest.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -0,0 +1,5 @@
+`bsjktest` <-
+function(x,...){
+  UseMethod("bsjktest")
+}
+


Property changes on: pkg/R/bsjktest.R
___________________________________________________________________
Added: svn:executable
   + *

Added: pkg/R/bsjktest.formula.R
===================================================================
--- pkg/R/bsjktest.formula.R	                        (rev 0)
+++ pkg/R/bsjktest.formula.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -0,0 +1,42 @@
+`bsjktest.formula` <-
+function(x, data, index=NULL, listw, test=c("C.1","C.2","C.3","J"), ...){
+
+  ## transform listw if needed
+  if("listw" %in% class(listw)) {
+    w <- listw2mat(listw)
+  } else {
+    w <- listw
+  }
+
+  ## transform data if needed
+  if(!is.null(index)) {
+    require(plm)
+    data <- plm.data(data, index)
+    }
+
+  gindex <- dimnames(data)[[2]][1]
+  tindex <- dimnames(data)[[2]][2]
+
+  switch(match.arg(test), C.1 = {
+
+    bsjk = pbsjkSDtest(formula=x, data=data, w=w, index=index, ...)
+
+  }, C.2 = {
+
+    bsjk = pbsjkARtest(formula=x, data=data, w=w, index=index, ...)
+
+  }, C.3 = {
+
+    stop("C.3 test not yet available")
+    #bsjk = pbsjkREtest(formula=x, data=data, w=w, index=index, ...)
+
+  }, J = {
+
+    bsjk = pbsjkJtest(formula=x, data=data, w=w, index=index, ...)
+
+  })
+
+  return(bsjk)
+
+}
+


Property changes on: pkg/R/bsjktest.formula.R
___________________________________________________________________
Added: svn:executable
   + *

Added: pkg/R/pbsjkARtest.R
===================================================================
--- pkg/R/pbsjkARtest.R	                        (rev 0)
+++ pkg/R/pbsjkARtest.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -0,0 +1,139 @@
+`pbsjkARtest` <-
+function(formula, data, w, index=NULL, ...) {
+
+  ## performs Baltagi, Song, Jung and Koh C.2 test
+  ## for serial correlation conditional on RE and spatial corr.
+  ## Giovanni Millo, Trieste, this version compatible with spreml()
+  ## 19/03/2009
+
+  ## depends: spreml()>semREmod(), fdHess{nlme} for numerical hessians
+
+  require(nlme)
+
+
+  ## reorder data if needed
+  if(!is.null(index)) {
+    require(plm)
+    data <- plm.data(data, index)
+    }
+
+  gindex <- data[,1]
+  tindex <- data[,2]
+
+  ## for our purpose data has to be (re)ordered
+  ## by time, then group
+  data <- data[order(tindex, gindex),]
+
+  ## est. MLE SEM-RE model
+  mymod <- spreml(formula=formula, data=data, w=w,
+                  index=index, lag=FALSE, errors="semre", ...)
+
+  nt. <- dim(data)[[1]]
+  n. <- length(unique(gindex))
+  t. <- length(unique(tindex))
+
+  ## def. 'trace' function
+  tr<-function(x) sum(diag(x))
+
+  ## def. 'matrix square' function
+  msq<-function(x) x%*%x
+
+  ## make W matrix from listw object, if needed
+  if("listw" %in% class(w)) if(require(spdep)) w<-listw2mat(w)
+
+  ## retrieve restricted model's residuals ### substitute by a direct extraction
+  X<-model.matrix(formula, data)
+  y<-model.response(model.frame(formula,data))
+  beta0<-mymod$coefficients
+  u.hat<-as.numeric(y-X%*%beta0)
+
+  ## retrieve SEM coefficient from model coef
+  lambda <- mymod$errcomp["lambda"]
+
+  ## retrieve variance components sigma.e and sigma.mu from lme object
+  eta <- mymod$errcomp["phi"]  # pay attention to this renaming
+  sigma2tot <- as.numeric(crossprod(u.hat)/nt.)
+  sigma2e <- as.numeric(sigma2tot/(eta+1))
+  sigma2mu <- as.numeric(eta*sigma2e)
+
+  ## henceforth notation as in Baltagi, Song, Jung, Koh (JE 2007)
+
+  JaT<-matrix(1,nrow=t.,ncol=t.)/t.
+  It<-diag(1,t.)
+  Et<-It-JaT
+
+
+  B<-diag(1,n.)-lambda*w
+  BB<-crossprod(B)
+  BB.1 <- solve(BB)
+
+  wBBw<-crossprod(w,B)+crossprod(B,w)
+
+  Z0 <- solve( t. * sigma2mu * diag(1,n.) + sigma2e * BB.1 )
+
+  G<-matrix(0,ncol=t.,nrow=t.)
+  for(i in 2:t.) {
+    G[i-1,i]<-1
+    G[i,i-1]<-1
+    }
+
+  EGE <- Et%*%G%*%Et
+  JGE <- JaT%*%G%*%Et
+  EGJ <- Et%*%G%*%JaT
+  JGJ <- JaT%*%G%*%JaT
+
+
+  redspade <- 1/sigma2e^2*kronecker(EGE,BB) + 1/sigma2e*kronecker(JGE,Z0) +
+              1/sigma2e*kronecker(EGJ,Z0) + kronecker(JGJ,Z0%*%BB.1%*%Z0)
+
+  Dhat <- -(t.-1)/t. * (sigma2e * tr(Z0%*%BB.1) -n.) +
+          1/2 * sigma2e * crossprod(u.hat, redspade) %*% u.hat
+
+  ## information matrix:
+  d1<-tr( msq(Z0%*%BB.1) )
+  d2<-tr(Z0%*%BB.1%*%Z0)
+  d3<-tr( wBBw%*%BB.1 )
+  d4<-tr( Z0 %*% BB.1 %*% wBBw %*% BB.1 %*% Z0 %*% BB.1 )
+  d5<-tr( Z0 %*% BB.1 %*% wBBw %*% BB.1 %*% Z0 )
+  d6<-tr( msq( wBBw %*% BB.1 ) )
+  d7<-tr( msq( Z0 %*% BB.1 %*% wBBw %*% BB.1 ) )
+
+  j11<-(n.*(t.-1)/sigma2e^2 + d1)/2
+  j12<-t./2*d2
+  j13<-(t.-1)/t.*(sigma2e*d1-n./sigma2e)
+  j14<-((t.-1)/sigma2e*d3 + sigma2e*d4)/2
+  j22<-t.^2/2*tr(msq(Z0))
+  j23<-(t.-1)*sigma2e*d2
+  j24<-t./2*sigma2e*d5
+  j33<-n./t.^2 * (t.^3-3*t.^2+2*t.+2) + (2*(t.-1)^2*sigma2e^2)/t.^2*d1
+  j34<-(t.-1)/t. * (sigma2e^2*d4 - d3)
+  j44<-((t.-1)*d6 + sigma2e^2*d7)/2
+
+  Jtheta<-matrix(ncol=4,nrow=4)
+  Jtheta[1,]<-c(j11,j12,j13,j14)
+  Jtheta[2,]<-c(j12,j22,j23,j24)
+  Jtheta[3,]<-c(j13,j23,j33,j34)
+  Jtheta[4,]<-c(j14,j24,j34,j44)
+
+  J33.1<-solve(Jtheta)[3,3]
+
+  LMr.lm <- (Dhat^2) * J33.1
+
+  df.<-1
+  pval <- pchisq(LMr.lm,df=df.,lower.tail=FALSE)
+
+  names(LMr.lm)="LM"
+  names(df.)<-"df"
+
+  ##(insert usual htest features)
+  dname <- deparse(formula)
+  RVAL <- list(statistic = LMr.lm, parameter = df.,
+               method = "Baltagi, Song, Jung and Koh C.2 conditional test",
+               alternative = "serial corr. in error terms, sub RE and spatial dependence",
+               p.value = pval,
+               data.name =   dname)
+  class(RVAL) <- "htest"
+  return(RVAL)
+
+}
+


Property changes on: pkg/R/pbsjkARtest.R
___________________________________________________________________
Added: svn:executable
   + *

Added: pkg/R/pbsjkJtest.R
===================================================================
--- pkg/R/pbsjkJtest.R	                        (rev 0)
+++ pkg/R/pbsjkJtest.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -0,0 +1,79 @@
+`pbsjkJtest` <-
+function(formula, data, w, index=NULL, ...) {
+
+  ## performs Baltagi, Song, Jung and Koh J(oint) test
+  ## for RE, serial correlation and spatial corr.
+  ## Giovanni Millo, Trieste, this version: 19/03/2009
+
+  ## for our purpose data has to be (re)ordered
+  ## by time, then group (but this is cared for just below)
+
+  ## reorder data if needed
+  if(!is.null(index)) {
+    require(plm)
+    data <- plm.data(data, index)
+    }
+
+  gindex <- data[,1]
+  tindex <- data[,2]
+
+  ## for our purpose data has to be (re)ordered
+  ## by time, then group
+  data <- data[order(tindex, gindex),]
+
+  ## def. 'trace' function
+  tr<-function(x) sum(diag(x))
+
+  ## def. 'matrix square' function
+  msq<-function(x) x%*%x
+
+  ## make W matrix from listw object, if needed
+  if("listw" %in% class(w)) if(require(spdep)) w<-listw2mat(w)
+
+  ## retrieve restricted model's (OLS) residuals (ordered!)
+  X<-model.matrix(formula, data)
+  y<-model.response(model.frame(formula,data))
+  beta0<-lm(y~X-1)$coef
+  u.hat<-y-X%*%beta0
+
+  ## calc. data numerosities (do it better)
+  nt.<- length(y)
+  n.<- dim(w)[[1]]
+  t.<-nt./n.
+
+  ## henceforth notation as in Baltagi, Song, Jung, Koh (JE 2007)
+  Jt<-matrix(1,ncol=t.,nrow=t.)
+  In<-diag(1,n.)
+  It<-diag(1,t.)
+  G<-matrix(0,ncol=t.,nrow=t.)
+  for(i in 2:t.) {
+    G[i-1,i]<-1
+    G[i,i-1]<-1
+    }
+
+  ## NB do all this without Kronecker prods.!
+  A <- (crossprod(u.hat, kronecker(Jt, In)) %*% u.hat)/crossprod(u.hat)-1
+  F <- 1/2 * (crossprod(u.hat, kronecker(G, In)) %*% u.hat)/crossprod(u.hat)
+  H <- 1/2 * (crossprod(u.hat, kronecker(It, (t(w)+w))) %*% u.hat)/crossprod(u.hat)
+  b <- tr(msq(w+t(w)))/2
+
+  LMj <- n.*t.^2 / (2*(t.-1)*(t.-2)) * (A^2 - 4*A*F + 2*t.*F^2) + (n.^2*t.)/b*H^2
+
+  df.<-3
+  pval <- pchisq(LMj,df=df.,lower.tail=FALSE)
+
+  names(LMj)="LM"
+  names(df.)<-"df"
+
+  ##(insert usual htest features)
+  dname <- deparse(formula)
+  RVAL <- list(statistic = LMj, parameter = df.,
+               method = "Baltagi, Song, Jung and Koh joint test (J)",
+               alternative = "random effects or serial corr. or spatial dependence in error terms",
+               p.value = pval,
+               data.name =   dname)
+  class(RVAL) <- "htest"
+  return(RVAL)
+
+}
+


Property changes on: pkg/R/pbsjkJtest.R
___________________________________________________________________
Added: svn:executable
   + *

Added: pkg/R/pbsjkSDtest.R
===================================================================
--- pkg/R/pbsjkSDtest.R	                        (rev 0)
+++ pkg/R/pbsjkSDtest.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -0,0 +1,108 @@
+`pbsjkSDtest` <-
+function(formula, data, w, index=NULL, ...) {
+
+  ## performs Baltagi, Song, Jung and Koh C.1 test
+  ## for spatial dependence conditional on RE and serial corr.
+  ## Giovanni Millo, Trieste, this version 2: 19/03/2009
+
+  ## new interface for operation with pbsjktest2.R--> and
+  ## -->spreml.R
+
+  ## NB! not the same numbers as in the nlme-based version!!
+  ## ...but these look like fitting better with a Wald test
+  ## on semsrre
+
+  ## depends: spreml()>ssrREmod(), fdHess{nlme} for numerical hessians
+
+  require(nlme)
+
+  ## reorder data if needed
+  if(!is.null(index)) {
+    require(plm)
+    data <- plm.data(data, index)
+    }
+
+  gindex <- data[,1]
+  tindex <- data[,2]
+
+  ## for our purpose data has to be (re)ordered
+  ## by time, then group
+  data <- data[order(tindex, gindex),]
+
+  ## est. MLE AR-RE model
+  mymod <- spreml(formula=formula, data=data, w=w,
+                  index=index, lag=FALSE, errors="srre", ...)
+
+  ## def. 'trace' function
+  tr<-function(x) sum(diag(x))
+
+  nt. <- dim(data)[[1]]
+  n. <- length(unique(gindex))
+  t. <- length(unique(tindex))
+  Jt<-matrix(1,ncol=t.,nrow=t.)
+
+  ## make W matrix from listw object, if needed
+  if("listw" %in% class(w)) if(require(spdep)) w<-listw2mat(w)
+
+  ## retrieve restricted model's residuals ### substitute by a direct extraction
+  X<-model.matrix(formula, data)
+  y<-model.response(model.frame(formula,data))
+  beta0<-mymod$coefficients
+  u.hat<-as.numeric(y-X%*%beta0)
+
+  ## retrieve AR(1) coefficient
+  rho<-mymod$errcomp["psi"] # notice change in parm names in spreml
+
+  ## henceforth notation as in Baltagi, Song, Jung, Koh (JE 2007)
+
+  b<-tr(w%*%w+crossprod(w))
+
+  d2<-(1+rho)/(1-rho)+t.-1
+
+  ## retrieve variance components sigma.e and sigma.mu from lme object
+  sigma2tot<-sum(u.hat^2)/length(u.hat)
+  phi<- mymod$errcomp["phi"]  ## sigmatot^2=sigma.e^2*(phi+1)
+  sigma2.e<-sigma2tot/(phi+1)
+  sigma2.u<-sigma2tot-sigma2.e
+
+  sigma.e<-sqrt(sigma2.e)
+  sigma.u<-sqrt(sigma2.u)
+
+  c. <- (sigma.e^2 * sigma.u^2) / (d2*(1-rho)^2*sigma.u^2+sigma.e^2)
+
+  g. <- (1-rho)/sigma.e^2 * ( 2 + (t.-2)*(1-rho) )
+
+  V1<-matrix(ncol=t.,nrow=t.)
+  for(i in 1:t.) V1[i,]<-rho^abs(1:t.-i)
+
+  V <- sigma.e^2 * (1/(1-rho^2)) * V1
+  iV<-solve(V)
+  VJt <- solve(V,Jt)
+
+  bluestar<-(iV - 2*c. * VJt %*% iV +
+             c.^2 * VJt%*%VJt %*% iV)
+
+  bluespade<-kronecker(bluestar,(t(w)+w))
+
+  Dhat <- 1/2 * crossprod(u.hat, bluespade) %*% u.hat
+
+  LMl.rm <- (Dhat^2) / (b*(t. - 2*c.*g. + c.^2*g.^2))
+
+  df.<-1
+  pval <- pchisq(LMl.rm,df=df.,lower.tail=FALSE)
+
+  names(LMl.rm)="LM"
+  names(df.)<-"df"
+
+  ##(insert usual htest features)
+  dname <- deparse(formula)
+  RVAL <- list(statistic = LMl.rm, parameter = df.,
+               method = "Baltagi, Song, Jung and Koh C.1 conditional test",
+               alternative = "spatial dependence in error terms, sub RE and serial corr.",
+               p.value = pval,
+               data.name =   dname)
+  class(RVAL) <- "htest"
+  return(RVAL)
+
+}
+


Property changes on: pkg/R/pbsjkSDtest.R
___________________________________________________________________
Added: svn:executable
   + *

Modified: pkg/R/saremsrREmod.R
===================================================================
--- pkg/R/saremsrREmod.R	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/R/saremsrREmod.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -22,7 +22,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("phi", "rho", "lambda", "psi")
+    nam.errcomp <- c("phi", "psi", "rho", "lambda")
 
     ## initialize values for optimizer
     myparms0 <- coef0
@@ -146,11 +146,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/saremsrmod.R
===================================================================
--- pkg/R/saremsrmod.R	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/R/saremsrmod.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -22,7 +22,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("rho", "lambda", "psi")
+    nam.errcomp <- c("psi", "rho", "lambda")
 
     ## initialize values for optimizer
     myparms0 <- coef0
@@ -132,11 +132,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/sarsrREmod.R
===================================================================
--- pkg/R/sarsrREmod.R	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/R/sarsrREmod.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -25,7 +25,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("phi", "rho", "psi")
+    nam.errcomp <- c("phi", "psi", "lambda")
 
     ## initialize values for optimizer
     myparms0 <- coef0
@@ -161,11 +161,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/sarsrmod.R
===================================================================
--- pkg/R/sarsrmod.R	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/R/sarsrmod.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -25,7 +25,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("rho", "psi")
+    nam.errcomp <- c("psi","lambda")
 
     ## initialize values for optimizer
     myparms0 <- coef0
@@ -157,11 +157,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/semsrREmod.R
===================================================================
--- pkg/R/semsrREmod.R	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/R/semsrREmod.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -22,7 +22,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("phi", "rho", "lambda")
+    nam.errcomp <- c("phi", "psi", "rho")
 
     ## initialize values for optimizer
     myparms0 <- coef0

Modified: pkg/R/semsrmod.R
===================================================================
--- pkg/R/semsrmod.R	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/R/semsrmod.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -19,7 +19,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("rho", "lambda")
+    nam.errcomp <- c("psi", "rho")
 
     ## initialize values for optimizer
     myparms0 <- coef0

Modified: pkg/R/ssrREmod.R
===================================================================
--- pkg/R/ssrREmod.R	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/R/ssrREmod.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -22,7 +22,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("phi", "rho")
+    nam.errcomp <- c("phi", "psi")
 
     ## initialize values for optimizer
     myparms0 <- coef0

Modified: pkg/R/ssrmod.R
===================================================================
--- pkg/R/ssrmod.R	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/R/ssrmod.R	2011-05-19 22:17:45 UTC (rev 113)
@@ -22,7 +22,7 @@
 
     ## set names for final parms vectors
     nam.beta <- dimnames(X)[[2]]
-    nam.errcomp <- c("rho")
+    nam.errcomp <- c("psi")
 
     ## initialize values for optimizer
     myparms0 <- coef0

Added: pkg/man/bsjktest.Rd
===================================================================
--- pkg/man/bsjktest.Rd	                        (rev 0)
+++ pkg/man/bsjktest.Rd	2011-05-19 22:17:45 UTC (rev 113)
@@ -0,0 +1,42 @@
+\name{bsjktest}
+\alias{bsjktest}
+\alias{bsjktest.formula}
+
+\title{Baltagi, Song, Jung and Koh LM test for spatial panels}
+\description{
+  Baltagi, Song, Jung and Koh joint or conditional LM test for
+   spatial error correlation or serial correlation sub spatial, serial correlation and random effects in panel models
+}
+\usage{
+bsjktest(x,...)
+\method{bsjktest}{formula}(x, data, index=NULL, listw,
+test=c("C.1","C.2","C.3","J"), ...)
+}
+\arguments{
+\item{x}{an object of class  \code{formula}}
+  \item{data}{an object of class \code{\link{data.frame}} or \code{pdata.frame}. An optional data frame containing the variables
+  in the model. When the obect is a \code{\link{data.frame}}, the first two columns may contain the indexes. See \code{index}}
+  \item{index}{if not NULL (default), a character vector to identify the indexes among the columns of the \code{\link{data.frame}}}
+\item{listw}{either a \code{matrix} or an object of class \code{listw} created for example by \code{nb2listw}, representing the spatial structure}
+\item{test}{one of \code{c("C.1","C.2","C.3","J")}, the
+  test to be performed. "C.3" is not implemented yet.}
+\item{...}{additional arguments to be passed}
+}
+
+\value{
+an object of class \code{htest}
+}
+\references{Baltagi, B.H., Song, S.H., Jung B. and Koh, W. (2007)
+Testing panel data regression models with spatial and serial error correlation.
+\emph{Journal of Econometrics}, \bold{140}, 5-51.}
+\author{Giovanni Millo}
+\seealso{\code{\link{bsktest}}}
+
+\examples{
+data(Produc, package="Ecdat")
+data(usaww)
+fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp
+bsjktest(fm, data=Produc, listw = usaww, test="C.1")
+}
+
+\keyword{htest}

Modified: pkg/man/bsktest.Rd
===================================================================
--- pkg/man/bsktest.Rd	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/man/bsktest.Rd	2011-05-19 22:17:45 UTC (rev 113)
@@ -38,7 +38,7 @@
 data(usaww)
 fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp
 bsktest(fm,data=Produc, listw = mat2listw(usaww),
-  test="LM1")
+  test="LM1", standardize=TRUE)
 }
 
 \keyword{htest}

Modified: pkg/man/effects.splm.Rd
===================================================================
--- pkg/man/effects.splm.Rd	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/man/effects.splm.Rd	2011-05-19 22:17:45 UTC (rev 113)
@@ -1,5 +1,6 @@
 \name{effects.splm}
 \alias{effects.splm}
+\alias{print.effects.splm}
 \title{method for extracting fixed effects}
 
 \description{
@@ -48,19 +49,19 @@
 \author{ Gianfranco Piras \email{gpiras at mac.com}}
 
 \seealso{
-\code{\link{spfeml}} \code{print.effects.splm} \code{summary.effects.splm}
+\code{\link{spml}} \code{summary.effects.splm}
 }
 \examples{
 data(Produc, package = "Ecdat")
 data(usaww)
 fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
-lag <- spfeml(fm, data = Produc, listw = mat2listw(usaww), effects = "sptpfe", method = "eigen", quiet = TRUE) 
+lag <- spml(fm, data = Produc, listw = mat2listw(usaww), model="within", effect="twoways", lag=TRUE, method="eigen")
 summary(lag)
 eff <- effects(lag) 
 print(eff)
-err <- spfeml(fm, data = Produc, listw = mat2listw(usaww), model = "error", effects = "tpfe", method = "eigen", quiet = TRUE)
+err <- spml(fm, data = Produc, listw = mat2listw(usaww), model="within", effect="time", spatial.error="b", method="eigen")
 summary(err)
 eff <- effects(err) 
 print(eff)
 }
-\keyword{spatial}
\ No newline at end of file
+\keyword{spatial}

Modified: pkg/man/print.splm.Rd
===================================================================
--- pkg/man/print.splm.Rd	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/man/print.splm.Rd	2011-05-19 22:17:45 UTC (rev 113)
@@ -33,7 +33,7 @@
 }
 
 \seealso{
-  \code{\link{spreml}}, \code{\link{spgm}}, \code{\link{spreml}}
+  \code{\link{spml}}, \code{\link{spgm}}
 }
 \author{ Giovanni Millo \email{Giovanni\_Millo at Generali.com}, Gianfranco Piras\email{gpiras at mac.com}}
 
@@ -43,4 +43,4 @@
 GM<-spgm(log(gsp)~log(pcap)+log(pc)+log(emp)+unemp, data=Produc, listw = usaww, moments="fullweights", spatial.error= TRUE)
 summary(GM)
 }
-\keyword{spatial}
\ No newline at end of file
+\keyword{spatial}

Modified: pkg/man/splm-package.Rd
===================================================================
--- pkg/man/splm-package.Rd	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/man/splm-package.Rd	2011-05-19 22:17:45 UTC (rev 113)
@@ -77,7 +77,7 @@
 fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
 GM<-spgm(log(gsp)~log(pcap)+log(pc)+log(emp) + unemp, data = Produc, listw = usaww, moments = "fullweights", spatial.error = TRUE)
 summary(GM)
-respaterr <- spreml(fm, data = Produc, w = usaww, errors="semre")
+respaterr <- spml(fm, data = Produc, listw = mat2listw(usaww), model="random", spatial.error="b")
 summary(respaterr)
 
 }

Modified: pkg/man/spml.Rd
===================================================================
--- pkg/man/spml.Rd	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/man/spml.Rd	2011-05-19 22:17:45 UTC (rev 113)
@@ -72,7 +72,7 @@
 
 \author{Giovanni Millo}
 
-\seealso{\code{\link{spgm}}, \code{\link{spfeml}}}
+\seealso{\code{\link{spgm}}}
 
 \examples{
 data(Produc, package = "Ecdat")
@@ -87,4 +87,4 @@
 summary(respatlag)
 }
 
-\keyword{spatial}
\ No newline at end of file
+\keyword{spatial}

Modified: pkg/man/summary.splm.Rd
===================================================================
--- pkg/man/summary.splm.Rd	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/man/summary.splm.Rd	2011-05-19 22:17:45 UTC (rev 113)
@@ -38,7 +38,7 @@
 }
 
 \seealso{
-  \code{\link{spreml}}, \code{\link{spgm}}, \code{\link{effects}}
+  \code{\link{spml}}, \code{\link{spgm}}, \code{\link{effects}}
 }
 \author{ Giovanni Millo \email{Giovanni\_Millo at Generali.com}, Gianfranco Piras\email{gpiras at mac.com}}
 
@@ -49,4 +49,4 @@
 summary(GM)
 }
 
-\keyword{spatial}
\ No newline at end of file
+\keyword{spatial}

Modified: pkg/man/write.effects.splm.Rd
===================================================================
--- pkg/man/write.effects.splm.Rd	2011-05-16 20:28:51 UTC (rev 112)
+++ pkg/man/write.effects.splm.Rd	2011-05-19 22:17:45 UTC (rev 113)
@@ -41,20 +41,20 @@
 \author{ Gianfranco Piras \email{gpiras at mac.com}}
 
 \seealso{
-\code{\link{spfeml}}
+\code{\link{spml}}
 }
 \examples{
 data(Produc, package = "Ecdat")
 data(usaww)
 fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
-lag <- spfeml(fm, data = Produc, listw = mat2listw(usaww), effects = "sptpfe", method = "eigen", quiet = TRUE)
+lag <- spml(fm, data = Produc, listw = mat2listw(usaww), model="within", effect="twoways", lag=TRUE, method="eigen")
 summary(lag)
 eff <- effects(lag) 
-err <- spfeml(fm, data = Produc, listw = mat2listw(usaww), model = "error", effects = "tpfe", method = "eigen", quiet = TRUE)
+print(eff)
+err <- spml(fm, data = Produc, listw = mat2listw(usaww), model="within", effect="time", spatial.error="b", method="eigen")
 summary(err)
-eff <- effects(err)
-summary(eff)
+eff <- effects(err) 
 write.effects.splm(eff)
 }
 
-\keyword{spatial}
\ No newline at end of file
+\keyword{spatial}



More information about the Splm-commits mailing list