[Splm-commits] r253 - in pkg: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Feb 17 16:53:29 CET 2023
Author: gpiras
Date: 2023-02-17 16:53:29 +0100 (Fri, 17 Feb 2023)
New Revision: 253
Modified:
pkg/DESCRIPTION
pkg/NAMESPACE
pkg/R/impacts.splm.R
pkg/R/ivsplm.R
pkg/R/spgm.R
pkg/man/spml.Rd
Log:
eliminate some printing
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2023-02-16 11:21:42 UTC (rev 252)
+++ pkg/DESCRIPTION 2023-02-17 15:53:29 UTC (rev 253)
@@ -7,6 +7,6 @@
person("Roger", "Bivand", role = c("ctb"), email = "Roger.Bivand at nhh.no", comment=c(ORCID="0000-0003-2392-6140")))
Description: ML and GM estimation and diagnostic testing of econometric models for spatial panel data.
Depends: R (>= 2.12.0)
-Imports: plm, maxLik, MASS, bdsmatrix, ibdreg, nlme, Matrix, spam, methods, spatialreg (>= 1.2-1), spdep (>= 1.2-1)
+Imports: plm, maxLik, MASS, bdsmatrix, ibdreg, nlme, Matrix, spam, methods, spatialreg (>= 1.2-1), spdep (>= 1.2-1), stringr
License: GPL-2
LazyLoad: yes
Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE 2023-02-16 11:21:42 UTC (rev 252)
+++ pkg/NAMESPACE 2023-02-17 15:53:29 UTC (rev 253)
@@ -11,8 +11,8 @@
importFrom(plm, pmodel.response)
importFrom(plm, pdim)
importFrom(nlme, fdHess, lme)
+importFrom(stringr, str_remove)
-
#if (packageVersion("spdep") < 1.2) {
# import(spdep, except=c(do_ldet, eigen_setup, trW, impacts.gmsar, impacts))
# importFrom(spatialreg, do_ldet, eigen_setup, trW, impacts)
@@ -53,7 +53,7 @@
export(bsktest, sphtest, bsjktest, vcov.splm,
effects.splm, print.effects.splm, slag,
print.splm, spml, spgm, summary.splm, sphtest,
-listw2dgCMatrix, spreml, rwtest, slmtest)
+listw2dgCMatrix, spreml, rwtest, slmtest, impacts)
@@ -68,6 +68,7 @@
S3method(sphtest, formula)
S3method(sphtest, splm)
S3method(impacts, splm)
+S3method(impacts, splm_GM)
S3method(slag, pseries)
S3method(rwtest, formula)
S3method(rwtest, panelmodel)
Modified: pkg/R/impacts.splm.R
===================================================================
--- pkg/R/impacts.splm.R 2023-02-16 11:21:42 UTC (rev 252)
+++ pkg/R/impacts.splm.R 2023-02-17 15:53:29 UTC (rev 253)
@@ -1,5 +1,290 @@
-impacts.splm <- function(obj, listw = NULL, time = NULL, ..., tr=NULL, R=200, type="mult", empirical=FALSE, Q=NULL){
+impacts <- function(obj, ...){
+ UseMethod("impacts", obj)
+}
+
+
+
+impacts.splm_GM <- function(obj, ..., tr=NULL,
+ R=NULL, listw=NULL,
+ type = "mult",
+ time = NULL,
+ evalues=NULL, tol=1e-6,
+ empirical=FALSE, Q=NULL,
+ KPformula = FALSE, prt = TRUE) {
+
+ object <- obj
+
+ if(is.null(listw) && is.null(tr)) stop("either listw or tr should be provided")
+ if (!is.null(object$endo)) stop("impacts for model
+ with additional endogenous
+ variables not yet available in splm")
+
+ if(!is.null(listw) ){
+ if(!inherits(listw,c("listw", "Matrix", "matrix"))) stop("listw format unknown")
+ if(inherits(listw,"listw")) Ws <- listw2dgCMatrix(listw)
+ if(inherits(listw,"matrix")) Ws <- Matrix(listw)
+ if(inherits(listw,"Matrix")) Ws <- listw
+
+ if(all(rowSums(Ws) != rep(1,Ws at Dim[1]))) stop("Only row-standardised weights supported")
+ if(is.null(time) && is.null(tr)) stop("time periods should be provided")
+ }
+
+
+
+ if(is.null(tr)){
+
+ s.lws <- kronecker(Diagonal(time), Ws)
+ tr <- trW(s.lws, type= type)
+
+ }
+
+
+ if(object$nfimpacts == "lag_gm"){
+
+ if(isTRUE(KPformula)){
+
+ stop("KP formula not yet implemented")
+ # if(is.null(tr)){
+ # if(is.null(evalues)) evalues <- eigen(object$listw)$values
+ # }
+ # if(isTRUE(object$Durbin) | inherits(object$Durbin, "formula")) vc_impacts_formula_lag_mixed(object, evalues, tr, prt)
+ # else vc_impacts_formula_lag(object, evalues, tr, prt)
+ }
+ else{
+
+ if(isTRUE(object$Durbin) | inherits(object$Durbin, "formula")){
+
+ type <- "mixed"
+ interval <- c(-1,0.999)
+
+ coefs <- drop(object$coefficients)
+ # print(coefs)
+ p2 <- length(coefs)
+ lambda <- coefs[1]
+ #print(lambda)
+ beta <- coefs[2:p2]
+ #print(beta)
+ p <- length(beta)
+ p1 <- p + 1
+ names(beta) <- names(object$coefficients)[2:p2]
+ #print(names(beta))
+ icept <- grep("(Intercept)", names(beta))
+ iicept <- length(icept) > 0L
+ n <- length(object$residuals)
+
+ irho <- 1
+ drop2beta <- 1
+
+ if((lambda > interval[2] ) | (lambda < interval[1])) warning("Value of the spatial parameter outside of parameter space")
+
+
+ dvars <- NULL
+ if (iicept) b1 <- beta[-icept]
+ else b1 <- beta
+ p <- length(b1)
+ #print(names(beta))
+ dn <- grep("lag_", names(beta)) #which of the names of beta has "lag_"
+ #print(dn)
+ dc <- beta[dn] # betas that are lagged
+ #print(dc)
+ beta1 <- beta[-dn] # all the betas (and)including the lagged)
+ #print(beta1)
+ xb <- beta1[which(names(beta1) %in% stringr::str_remove(names(dc),"lag_") )]
+ #print(order(names(xb)))
+ xb <- xb[order(names(xb))]
+ l_xb <- length(xb)
+ if(length(which(names(beta1) %in% stringr::str_remove(names(dc),"lag_") ))>=1) xo <- beta1[ -which(names(beta1) %in% stringr::str_remove(names(dc),"lag_") )]
+ else xo <- beta1
+
+
+ gamma <- dc[which( stringr::str_remove(names(dc),"lag_") %in% names(beta1))]
+ gamma <- gamma[order(names(gamma))]
+ l_gamma <- length(gamma)
+
+ if(length(which(stringr::str_remove(names(dc),"lag_") %in% names(beta1)))>=1) don <- dc[-which( stringr::str_remove(names(dc),"lag_") %in% names(beta1))]
+ else don <- dc
+ l_don <- length(don)
+
+
+
+ if (iicept) {
+ xo <- xo[-icept]
+ l_xo <- length(xo)
+ if(l_xb != 0){
+ b2 <- c(xo, xb, rep(0, l_don), rep(0, l_xo), gamma, don)
+ bnames <- c(names(xo), sort(names(xb)), names(don))
+ }
+ else{
+ b2 <- c(xo, rep(0, l_don), rep(0, l_xo), don)
+ bnames <- c(names(xo), names(don))
+ }
+ P <- matrix(b2, ncol = 2)
+ }
+ else {
+ xo <- xo
+ l_xo <- length(xo)
+ if(l_xb != 0){
+ b2 <- c(xo, xb, rep(0, l_don), rep(0, l_xo), gamma, don)
+ bnames <- c(names(xo), sort(names(xb)), names(don))
+ }
+ else{
+ b2 <- c(xo, rep(0, l_don), rep(0, l_xo), don)
+ bnames <- c(names(xo), names(don))
+ }
+ P <- matrix(b2, ncol = 2)
+ }
+ #print(P)
+
+ if(!is.null(R)){
+
+ #first build the zero fills
+ if (l_xo != 0 && l_don != 0 && l_xb !=0) {
+ zero_fill <- list(1: l_xo, (l_xo+1):(l_xo+ l_xb), l_don,
+ l_xo, (l_xo + l_xb+1): (l_xo + l_xb+l_gamma),
+ (l_xo + l_xb+l_gamma+1):(l_xo + l_xb+l_gamma+l_don))
+ l_zero_fill <- 6
+ }
+
+ if(l_xo != 0 && l_don == 0 && l_xb != 0) {
+ zero_fill <- list(1: l_xo, (l_xo+1):(l_xo+ l_xb),
+ l_xo, (l_xo + l_xb+1): (l_xo + l_xb+l_gamma))
+
+ l_zero_fill <- 5
+ }
+ if(l_xo == 0 && l_don != 0 && l_xb !=0) {
+ zero_fill <- list(1: l_xb, l_don,(l_xb+1): (l_xb+l_gamma), (l_xb+l_gamma+1):( l_xb+l_gamma+l_don))
+ l_zero_fill <- 4
+ }
+
+ if(l_xo != 0 && l_don != 0 && l_xb ==0) {
+ zero_fill <- list(1: l_xo, l_don,
+ l_xo, (l_xo+1):(l_xo +l_don))
+ l_zero_fill <- 3
+ }
+
+ # if(l_xo == 0 && l_don != 0 && l_xb ==0){
+ # zero_fill <- list(l_don, 1: l_don)
+ # l_zero_fill <- 2
+ #
+ # }
+
+ # print(class(zero_fill))
+ attr(zero_fill, "l_zero_fill") <- l_zero_fill
+ # print(l_zero_fill)
+
+ if(iicept) {
+ mu <- c(lambda, beta[1], xo, xb, gamma, don)
+ m0 <- c(xo, xb, gamma, don)
+ }
+ else{
+ mu <- c(lambda, xo, xb, gamma, don)
+ m0 <- c(xo, xb, gamma, don)
+ }
+
+ # print(mu)
+ #print(object$vcov)
+ Sigma <- object$vcov[match(names(mu), rownames(object$vcov)),match(names(mu), rownames(object$vcov)) ]
+
+ #print(Sigma)
+ }
+ ####CHECK THE
+ # if (!requireNamespace("spatialreg", quietly=TRUE))
+ # stop("install spatialreg")
+ # res <- spatialreg::intImpacts(rho=lambda, beta=beta, P=P, n=n, mu=mu,
+ # Sigma=Sigma, irho=irho, drop2beta=drop2beta, bnames=bnames,
+ # interval=interval, type = type, tr=tr, R=R, listw=listw, evalues=evalues,
+ # tol=tol, empirical=empirical, Q=Q, icept=icept, iicept=iicept, p=p,
+ # zero_fill = zero_fill)
+
+ res <- spatialreg::intImpacts(rho=lambda, beta=beta, P=P, n=n, mu=mu,
+ Sigma=Sigma, irho=irho, drop2beta=drop2beta, bnames=bnames,
+ interval=interval, type = type, tr=tr, R=R, listw=NULL,
+ evalues=NULL,
+ tol=tol, empirical=empirical, Q=Q, icept=icept, iicept=iicept, p=p,
+ zero_fill = zero_fill)
+ }
+
+
+ else{
+
+ type <- "lag"
+ if (is.null(object$interval)) interval <- c(-1,0.999)
+
+ coefs <- drop(object$coefficients)
+ p2 <- length(coefs)
+ lambda <- coefs[1]
+ beta <- coefs[2:p2]
+ names(beta) <- rownames(object$coefficients)[2:p2]
+ p <- length(beta)
+ p1 <- p + 1
+
+ if((lambda > interval[2] ) | (lambda < interval[1])) warning("Value of the spatial parameter outside of parameter space")
+
+ icept <- grep("(Intercept)", names(beta))
+ iicept <- length(icept) > 0L
+ zero_fill <- NULL
+ dvars <- NULL
+
+ if (iicept) {
+ P <- matrix(beta[-icept], ncol=1)
+ bnames <- names(beta[-icept])
+ } else {
+ P <- matrix(beta, ncol=1)
+ bnames <- names(beta)
+ }
+
+ n <- length(object$residuals)
+ mu <- NULL
+ Sigma <- NULL
+
+ if (!is.null(R)) {
+ mu <- c(lambda, beta)
+ Sigma <- object$vcov[match(names(mu), rownames(object$vcov)),match(names(mu), rownames(object$vcov))]
+ }
+
+ irho <- length(beta) + 1
+ drop2beta <- length(beta) + 1
+
+ # if (!requireNamespace("spatialreg", quietly=TRUE))
+ # stop("install spatialreg")
+ # res <- spatialreg::intImpacts(rho=lambda, beta=beta, P=P, n=n, mu=mu,
+ # Sigma=Sigma, irho=irho, drop2beta=drop2beta, bnames=bnames,
+ # interval=interval, type = type, tr=tr, R=R, listw=listw, evalues=evalues,
+ # tol=tol, empirical=empirical, Q=Q, icept=icept, iicept=iicept, p=p)
+ #
+
+ res <- spatialreg::intImpacts(rho=lambda, beta=beta, P=P, n=n, mu=mu,
+ Sigma=Sigma, irho=irho, drop2beta=drop2beta, bnames=bnames,
+ interval=interval, type = type, tr=tr, R=R, listw=NULL,
+ evalues=NULL,
+ tol=tol, empirical=empirical, Q=Q, icept=icept, iicept=iicept, p=p,
+ zero_fill = zero_fill)
+ }
+
+ # if (!requireNamespace("spatialreg", quietly=TRUE))
+ # stop("install spatialreg")
+
+
+ attr(res, "iClass") <- class(object)
+
+ res
+ }
+ }
+
+ else stop("impacts for sarar not yet implemented")
+
+
+}
+
+
+
+impacts.splm <- function(obj, listw = NULL,
+ time = NULL, ...,
+ tr = NULL, R = 200,
+ type = "mult",
+ empirical = FALSE, Q = NULL){
+
if(is.null(listw) && is.null(tr)) stop("either listw or tr should be provided")
@@ -17,7 +302,9 @@
}
-if(is.na(match(obj$type, c("fixed effects lag","fixed effects sarar","random effects ML", "fixed effects GM","lag GM","fixed effects GM")))) stop("object type not recognized")
+if(is.na(match(obj$type, c("fixed effects lag","fixed effects sarar",
+ "random effects ML", "fixed effects GM","lag GM",
+ "fixed effects GM")))) stop("object type not recognized")
if(obj$type == "fixed effects lag"){
@@ -26,7 +313,7 @@
obj$data <- as.vector(obj$model)
obj$s2 <- obj$sigma2
obj$secstep_var <- obj$vcov
-imp <- impacts(obj, tr=tr, R=R, ...)
+imp <- spatialreg::impacts(obj, tr=tr, R=R, ...)
}
@@ -39,7 +326,7 @@
obj$data <- as.vector(obj$model)
obj$s2 <- obj$sigma2
obj$secstep_var <- obj$vcov[-2,-2]
-imp <- impacts(obj, tr=tr, R=R,...)
+imp <- spatialreg::impacts(obj, tr=tr, R=R,...)
}
@@ -57,7 +344,7 @@
obj$secstep_var <- matrix(0,nrow(obj$vcov)+1,nrow(obj$vcov)+1)
obj$secstep_var[1,1] <- obj$vcov.arcoef
obj$secstep_var[(2:(nrow(obj$vcov)+1)),(2:(nrow(obj$vcov)+1))] <- obj$vcov
-imp <- impacts(obj, tr=tr, R=R, ...)
+imp <- spatialreg::impacts(obj, tr=tr, R=R, ...)
}
else stop("Impacts Estimates are not available for Error Model")
Modified: pkg/R/ivsplm.R
===================================================================
--- pkg/R/ivsplm.R 2023-02-16 11:21:42 UTC (rev 252)
+++ pkg/R/ivsplm.R 2023-02-17 15:53:29 UTC (rev 253)
@@ -143,6 +143,6 @@
result$legacy <- FALSE
result$listw_style <- NULL
result$call <- match.call()
-
+ result$nfimpacts <- "lag_gm"
result
}
Modified: pkg/R/spgm.R
===================================================================
--- pkg/R/spgm.R 2023-02-16 11:21:42 UTC (rev 252)
+++ pkg/R/spgm.R 2023-02-17 15:53:29 UTC (rev 253)
@@ -97,7 +97,8 @@
results$legacy <- c(lag, spatial.error)
results$endog <- endog
results$est.meth <- "GM"
-class(results) <- c("splm")
+results$Durbin <- Durbin
+class(results) <- c("splm","splm_GM")
results
}
@@ -181,12 +182,18 @@
names(biv)<-Znames
+#print(length(biv))
+#print(Znames)
+#print(dim(varb))
+colnames(varb) <- rownames(varb) <- Znames[-which(is.na(biv))]
if(any(is.na(biv))) biv<-biv[-which(is.na(biv))]
-else biv<-biv
+else biv <- biv
+#print(length(biv))
+
result <- list(coefficients = biv, vcov = varb, sse = sse,
residuals = as.numeric(ehat), df = df, Zp = Zp, readout = readout)
Modified: pkg/man/spml.Rd
===================================================================
--- pkg/man/spml.Rd 2023-02-16 11:21:42 UTC (rev 252)
+++ pkg/man/spml.Rd 2023-02-17 15:53:29 UTC (rev 253)
@@ -1,102 +1,102 @@
-\name{spml}
-\alias{spml}
-\title{Spatial Panel Model by Maximum Likelihood}
-\description{Maximum likelihood (ML) estimation of spatial panel models, possibly with fixed or random effects.}
-
-
-\usage{
-spml(formula, data, index=NULL, listw, listw2=listw, na.action,
- model=c("within","random","pooling"),
- effect=c("individual","time","twoways"),
- lag=FALSE, spatial.error=c("b","kkp","none"),
- ...)
-}
-
-\arguments{
- \item{formula}{a symbolic description of the model to be estimated}
- \item{data}{an object of class \code{data.frame} or \code{pdata.frame}. A data frame containing the variables
- in the model. When the object is a \code{data.frame}, the first two columns shall contain the indexes, unless otherwise specified. See \code{index}}
- \item{index}{if not NULL (default), a character vector to identify the indexes among the columns of the \code{data.frame}}
- \item{listw}{an object of class \code{listw} or a \code{matrix}. It represents the spatial weights to be used in estimation.}
- \item{listw2}{an object of class \code{listw} or a
- \code{matrix}. Second of set spatial weights for estimation, if
- different from the first (e.g., in a 'sarar' model).}
- \item{na.action}{see \pkg{spdep} for more details.}
- \item{model}{one of \code{c("within", "random", "pooling").}}
- \item{effect}{one of \code{c("individual","time","twoways")}; the
- effects introduced in the model.}
- \item{lag}{default=\code{FALSE}. If \code{TRUE}, a spatial lag of the dependent variable is added.}
- \item{spatial.error}{one of \code{c("b","kkp","none")}. The type of
- spatial error in the specification, if any. See details.}
- \item{...}{additional argument to pass over to other functions}
-}
-\details{
- The models are estimated by two-step Maximum Likelihood.
- Further optional parameters to be passed on to the estimator may be:
-pvar: if \code{TRUE} the \code{pvar} function is called
-hess: if \code{TRUE} use numerical Hessian instead of GLS for the
-standard errors of the estimates
-quiet: if \code{FALSE} report function and parameters values during
-optimization
-initval: one of \code{c("zeros", "estimate")}, the initial values for
- the parameters. If \code{"zeros"} a vector of zeros is used. if
- \code{"estimate"} the initial values are retreived from the estimation
- of the nested specifications. Alternatively, a numeric vector can be
- specified.
- x.tol: Tolerance. See \code{nlminb} for details.
- rel.tol: Relative tolerance. See \code{nlminb} for details.
-}
-\value{
- An object of class \code{"splm"}.
- \item{coefficients}{coefficients estimate of the model parameters }
- \item{arcoef}{the coefficient for the spatial lag on \code{y}}
- \item{errcomp}{the estimates of the error variance components}
- \item{vcov}{the asymptotic variance covariance matrix of the estimated coefficients}
- \item{vcov.arcoef}{the asymptotic variance of the
- estimated spatial lag parameter}
- \item{vcov.errcomp}{the asymptotic variance covariance matrix of the
- estimated error covariance parameters}
- \item{type}{'random effects ML'}
- \item{residuals}{the model residuals}
- \item{fitted.values}{the fitted values, calculated as \eqn{\hat{y}=X \hat{\beta}}}
- \item{sigma2}{GLS residuals variance}
- \item{model}{the matrix of the data used}
- \item{call}{the call used to create the object}
- \item{logLik}{the value of the log likelihood function at the optimum }
- \item{errors}{the value of the \code{errors} argument}
-}
-\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.
-
-Millo, G., Piras, G. (2012)
-splm: Spatial Panel Data Models in R.
-\emph{Journal of Statistical Software}, \bold{47(1)}, 1--38.
-URL http://www.jstatsoft.org/v47/i01/.
-}
-
-\author{Giovanni Millo}
-
-\seealso{\code{spgm}}
-
-\examples{
-data(Produc, package = "plm")
-data(usaww)
-fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
-## the two standard specifications (SEM and SAR) one with FE
-## and the other with RE:
-## fixed effects panel with spatial errors
-fespaterr <- spml(fm, data = Produc, listw = spdep::mat2listw(usaww),
- model="within", spatial.error="b", Hess = FALSE)
-summary(fespaterr)
-## random effects panel with spatial lag
-respatlag <- spml(fm, data = Produc, listw = spdep::mat2listw(usaww),
- model="random", spatial.error="none", lag=TRUE)
-summary(respatlag)
-## calculate impact measures
-impac1 <- spatialreg::impacts(respatlag, listw = spdep::mat2listw(usaww, style = "W"), time = 17)
-summary(impac1, zstats=TRUE, short=TRUE)
-}
-
-\keyword{spatial}
+\name{spml}
+\alias{spml}
+\title{Spatial Panel Model by Maximum Likelihood}
+\description{Maximum likelihood (ML) estimation of spatial panel models, possibly with fixed or random effects.}
+
+
+\usage{
+spml(formula, data, index=NULL, listw, listw2=listw, na.action,
+ model=c("within","random","pooling"),
+ effect=c("individual","time","twoways"),
+ lag=FALSE, spatial.error=c("b","kkp","none"),
+ ...)
+}
+
+\arguments{
+ \item{formula}{a symbolic description of the model to be estimated}
+ \item{data}{an object of class \code{data.frame} or \code{pdata.frame}. A data frame containing the variables
+ in the model. When the object is a \code{data.frame}, the first two columns shall contain the indexes, unless otherwise specified. See \code{index}}
+ \item{index}{if not NULL (default), a character vector to identify the indexes among the columns of the \code{data.frame}}
+ \item{listw}{an object of class \code{listw} or a \code{matrix}. It represents the spatial weights to be used in estimation.}
+ \item{listw2}{an object of class \code{listw} or a
+ \code{matrix}. Second of set spatial weights for estimation, if
+ different from the first (e.g., in a 'sarar' model).}
+ \item{na.action}{see \pkg{spdep} for more details.}
+ \item{model}{one of \code{c("within", "random", "pooling").}}
+ \item{effect}{one of \code{c("individual","time","twoways")}; the
+ effects introduced in the model.}
+ \item{lag}{default=\code{FALSE}. If \code{TRUE}, a spatial lag of the dependent variable is added.}
+ \item{spatial.error}{one of \code{c("b","kkp","none")}. The type of
+ spatial error in the specification, if any. See details.}
+ \item{...}{additional argument to pass over to other functions}
+}
+\details{
+ The models are estimated by two-step Maximum Likelihood.
+ Further optional parameters to be passed on to the estimator may be:
+pvar: if \code{TRUE} the \code{pvar} function is called
+hess: if \code{TRUE} use numerical Hessian instead of GLS for the
+standard errors of the estimates
+quiet: if \code{FALSE} report function and parameters values during
+optimization
+initval: one of \code{c("zeros", "estimate")}, the initial values for
+ the parameters. If \code{"zeros"} a vector of zeros is used. if
+ \code{"estimate"} the initial values are retreived from the estimation
+ of the nested specifications. Alternatively, a numeric vector can be
+ specified.
+ x.tol: Tolerance. See \code{nlminb} for details.
+ rel.tol: Relative tolerance. See \code{nlminb} for details.
+}
+\value{
+ An object of class \code{"splm"}.
+ \item{coefficients}{coefficients estimate of the model parameters }
+ \item{arcoef}{the coefficient for the spatial lag on \code{y}}
+ \item{errcomp}{the estimates of the error variance components}
+ \item{vcov}{the asymptotic variance covariance matrix of the estimated coefficients}
+ \item{vcov.arcoef}{the asymptotic variance of the
+ estimated spatial lag parameter}
+ \item{vcov.errcomp}{the asymptotic variance covariance matrix of the
+ estimated error covariance parameters}
+ \item{type}{'random effects ML'}
+ \item{residuals}{the model residuals}
+ \item{fitted.values}{the fitted values, calculated as \eqn{\hat{y}=X \hat{\beta}}}
+ \item{sigma2}{GLS residuals variance}
+ \item{model}{the matrix of the data used}
+ \item{call}{the call used to create the object}
+ \item{logLik}{the value of the log likelihood function at the optimum }
+ \item{errors}{the value of the \code{errors} argument}
+}
+\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.
+
+Millo, G., Piras, G. (2012)
+splm: Spatial Panel Data Models in R.
+\emph{Journal of Statistical Software}, \bold{47(1)}, 1--38.
+URL http://www.jstatsoft.org/v47/i01/.
+}
+
+\author{Giovanni Millo}
+
+\seealso{\code{spgm}}
+
+\examples{
+data(Produc, package = "plm")
+data(usaww)
+fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
+## the two standard specifications (SEM and SAR) one with FE
+## and the other with RE:
+## fixed effects panel with spatial errors
+fespaterr <- spml(fm, data = Produc, listw = spdep::mat2listw(usaww),
+ model="within", spatial.error="b", Hess = FALSE)
+summary(fespaterr)
+## random effects panel with spatial lag
+respatlag <- spml(fm, data = Produc, listw = spdep::mat2listw(usaww),
+ model="random", spatial.error="none", lag=TRUE)
+summary(respatlag)
+## calculate impact measures
+#impac1 <- impacts.splm(respatlag, listw = spdep::mat2listw(usaww, #style = "W"), time = 17)
+#summary(impac1, zstats=TRUE, short=TRUE)
+}
+
+\keyword{spatial}
More information about the Splm-commits
mailing list