[Splm-commits] r32 - pkg
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Oct 13 16:06:03 CEST 2009
Author: gpiras
Date: 2009-10-13 16:06:03 +0200 (Tue, 13 Oct 2009)
New Revision: 32
Removed:
pkg/clmltest.model.R
Log:
eliminate all functions erroneously uploaded
Deleted: pkg/clmltest.model.R
===================================================================
--- pkg/clmltest.model.R 2009-10-13 14:05:41 UTC (rev 31)
+++ pkg/clmltest.model.R 2009-10-13 14:06:03 UTC (rev 32)
@@ -1,86 +0,0 @@
-`clmltest.model` <-
-function(x, listw, index){
- ## depends on:
- ## listw2dgCMatrix.R
- ## REmod.R
- ## spreml.R
-if(!inherits(x,"splm")) stop("argument should be an object of class splm")
-frm<-x$call
-if(x$type != "random effects ML") stop("argument should be of type random effects ML")
-
- if(is.null(index)) stop("index should be specified to retrieve information on time and cross-sectional dimentions")
-
- if(!inherits(listw,"listw")) stop("object w should be of class listw")
-
-
-
- ind <- index[,1]
- tind <- index[,2]
-
-if(names(x$coefficients)[1]=="(Intercept)") X<-data.frame(cbind(rep(1,ncol(x$model)), x$model[,-1]))
-else X<-x$model[,-1]
- y<-x$model[,1]
- eML<-x$residuals
-
- ## reduce index accordingly
-
- ## reorder data by cross-sections, then time
- oo<-order(tind,ind)
- X<-X[oo,]
- y<-y[oo]
-
- ## det. number of groups and df
- N<-length(unique(ind))
- k<-dim(X)[[2]]
- ## det. max. group numerosity
- T<-max(tapply(X[,1],ind,length))
- ## det. total number of obs. (robust vs. unbalanced panels)
- NT<-length(ind)
-###maximum likelihood estimation under the null hypothesis that lambda is equal to zero. extract the residuals.
- indic<-seq(1,T)
- inde<-as.numeric(rep(indic,each=N)) ####indicator to get the cross-sectional observations
- ind1<-seq(1,N)
- inde1<-as.numeric(rep(ind1,T)) ####indicator to get the time periods observations
-
- eme<-tapply(eML,inde1,mean)
- emme<-eML - rep(eme,T)
- sigmav<-crossprod(eML,emme)/(N*(T-1)) ####estimate of the variance component sigma_v
- sigma1<-crossprod(eML,rep(eme,T))/N ####estimate of the variance component sigma_1
- c1<-sigmav/sigma1^2
- c2<-1/sigmav
- c1e<-as.numeric(c1)*eML
- Wst<-listw2dgCMatrix(listw) ###transform the listw object in a sparse matrix
- Ws<-t(Wst) ### this is the real W since listw2dgCMatrix generate W'
- WpsW<-Wst+Ws
-yybis<-function(q){ #### for very big dimension of the data this can be changed looping over the rows and columns of W or either the listw object
- wq<-(WpsW)%*%q
- wq<-as.matrix(wq)
- }
- Wc1e<-unlist(tapply(eML,inde,yybis)) #### (W'+W)*u
- sumWc1e<-tapply(Wc1e,inde1,sum)
- prod1<-as.numeric(c1)*rep(sumWc1e,T)/T
- prod2<-as.numeric(c2)* (Wc1e - rep(sumWc1e,T)/T)
- prod<-prod1+prod2
- D<-1/2*crossprod(eML,prod) ###calculates D in the notation of the paper.
- W2<-Ws%*%Ws ####generate W^2
- WW<-crossprod(Ws) ####generate W'*W
-tr<-function(R) sum(diag(R))
- b<-tr(W2+WW) ###generates b (same notation as the paper)
- LMl1<-D^2/(((T-1)+as.numeric(sigmav)^2/as.numeric(sigma1)^2)*b) ###conditional LM test for lambda equal to zero
- LMlstar<-sqrt(LMl1) ###one-sided version
- statistics<-LMlstar
- pval <- pnorm(LMlstar, lower.tail=FALSE)
-
- names(statistics)="LM*-lambda"
- method<- "Baltagi, Song and Koh LM*-lambda conditional LM test (assuming sigma^2_mu >= 0)"
- #alt<-"serial corr. in error terms, sub RE and spatial dependence"
- ##(insert usual htest features)
- dname <- deparse(formula)
- RVAL <- list(statistic = statistics,
- method = method,
- p.value = pval, data.name=deparse(frm), alternative="Spatial autocorrelation")
- class(RVAL) <- "htest"
- return(RVAL)
-
-}
-
More information about the Splm-commits
mailing list