Title: | Econometric Models for Spatial Panel Data |
---|---|
Description: | ML and GM estimation and diagnostic testing of econometric models for spatial panel data. |
Authors: | Giovanni Millo [aut, cre], Gianfranco Piras [aut], Roger Bivand [ctb] |
Maintainer: | Giovanni Millo <[email protected]> |
License: | GPL-2 |
Version: | 1.6-5 |
Built: | 2024-12-15 07:41:29 UTC |
Source: | CRAN |
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
bsjktest(x,...) ## S3 method for class 'formula' bsjktest(x, data, index=NULL, listw, test=c("C.1","C.2","C.3","J"), ...)
bsjktest(x,...) ## S3 method for class 'formula' bsjktest(x, data, index=NULL, listw, test=c("C.1","C.2","C.3","J"), ...)
x |
an object of class |
data |
a |
index |
either NULL (default) or a character vector to identify the indexes among the columns of the |
listw |
either a |
test |
one of |
... |
additional arguments to be passed |
an object of class htest
Giovanni Millo
Baltagi, B.H., Song, S.H., Jung B. and Koh, W. (2007) Testing panel data regression models with spatial and serial error correlation. Journal of Econometrics, 140, 5-51.
bsktest
data(Produc, package="plm") data(usaww) fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp bsjktest(fm, data=Produc, listw = usaww, test="C.1")
data(Produc, package="plm") data(usaww) fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp bsjktest(fm, data=Produc, listw = usaww, test="C.1")
Baltagi, Song and Koh marginal or conditional LM test for spatial error correlation or random effects in panel models
bsktest(x,...) ## S3 method for class 'formula' bsktest(x, data, index=NULL, listw, test=c("LMH","LM1","LM2","CLMlambda","CLMmu"), standardize=FALSE, method = "eigen", ...)
bsktest(x,...) ## S3 method for class 'formula' bsktest(x, data, index=NULL, listw, test=c("LMH","LM1","LM2","CLMlambda","CLMmu"), standardize=FALSE, method = "eigen", ...)
x |
a |
data |
a |
index |
either NULL (default) or a character vector to identify the indexes among the columns of the |
listw |
a |
test |
one of |
standardize |
whether to standardize the test statistic or not (applies only to LM1 and LM2) |
method |
select a method for ML in "CLMmu". the default is "eigen" |
... |
additional arguments to be passed |
an object of class htest
Gianfranco Piras
Baltagi, B.H., Song, S.H. and Koh, W. (2003) Testing panel data regression models with spatial error correlation. Journal of Econometrics, 117, 123–150.
Millo, G., Piras, G. (2012) splm: Spatial Panel Data Models in R. Journal of Statistical Software, 47(1), 1–38. URL http://www.jstatsoft.org/v47/i01/.
sphtest
data(Produc, package="plm") data(usaww) fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp bsktest(fm,data=Produc, listw = spdep::mat2listw(usaww), test="LM1")
data(Produc, package="plm") data(usaww) fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp bsktest(fm,data=Produc, listw = spdep::mat2listw(usaww), test="LM1")
Methods used for extracting fixed effects from objects of class splm
where type
is one of
"fixed effects lag" or "fixed effects error"
## S3 method for class 'splm' effects(object,...)
## S3 method for class 'splm' effects(object,...)
object |
an object of class |
... |
additional arguments to be passed over |
If the argument object
is not of class splm
the function will terminate with an error.
If the argument object
is of class splm
but type
is not one of
"fixed effects lag" or "fixed effects error",
the function will terminate with an error.
An object of class effects.splm
res |
a list whose elements are various type of fixed effects and the intercept (when present) |
Gianfranco Piras
Elhorst, J.P. (2003) Specification and estimation of spatial panel data models, International Regional Science Review, 26, pages 244–268.
Elhorst, J.P. (2009) Spatial panel data models, In Fischer, M.M. and Getis, A. (eds), Handbook of Applied Spatial Analysis Springer, Berlin.
spml
summary.effects.splm
data(Produc, package = "plm") data(usaww) fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp err <- spml(fm, data = Produc, listw = spdep::mat2listw(usaww), model="within") summary(err) eff <- effects(err) print(eff)
data(Produc, package = "plm") data(usaww) fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp err <- spml(fm, data = Produc, listw = spdep::mat2listw(usaww), model="within") summary(err) eff <- effects(err) print(eff)
A panel of 103 observations
number of observations : 515
observation : provinces
country : Italy
data(Insurance)
data(Insurance)
A dataframe containing :
the province code according to Istat
the year of observation
real per capita premiums in 2000 euros, non-life insurance excluding mandatory motor third-party liability
real per-capita GDP
real per-capita bank deposits
population density per square Km
real interest rate on lending to families and small enterprises
density of insurance agencies per 1000 inhabitants
share of people with second grade schooling or more
share of value added, agriculture
average number of family members
judicial inefficiency index: average years to settle first degree of civil case
survey result to the question "do you trust others?"
year dummies
macroregional dummy
macroregional dummy
macroregional dummy
macroregional dummy
macroregional dummy (Sicily and Sardinia)
Giovanni Millo
Giovanni Millo and Gaetano Carmeci, (2011) “Non-life insurance consumption in Italy: a sub-regional panel data analysis”, Journal of Geographical Systems, 13:273–298.
Spatial weights matrix of the 103 Italian provinces as in 1992-2005.
data(itaww)
data(itaww)
A matrix with elements different from zero if province i and j are neighbors. Weights are row-standardized. Messina and Reggio Calabria, divided by the Messina Strait, are considered neighbours.
Giovanni Millo
Interface between Matrix class objects and weights list
listw2dgCMatrix(listw, zero.policy = NULL)
listw2dgCMatrix(listw, zero.policy = NULL)
listw |
a |
zero.policy |
See |
Matrix class object: a sparse Matrix
Gianfranco Piras
data(columbus, package="spdep") listw<-spdep::nb2listw(col.gal.nb) spW<-listw2dgCMatrix(listw)
data(columbus, package="spdep") listw<-spdep::nb2listw(col.gal.nb) spW<-listw2dgCMatrix(listw)
Method to print objects of class summary.splm
and splm
## S3 method for class 'splm' print(x, digits = max(3,getOption("digits") -3), ...)
## S3 method for class 'splm' print(x, digits = max(3,getOption("digits") -3), ...)
x |
an object of class |
digits |
minimal number of significant digits, see |
... |
additional arguments to be passed |
The summary function summary.splm
returns an objects of class 'splm'
organized in a coefficient matrix.
Also a matrix for the error components, or the spatial coefficients will be generated depending on the estimated model.
Giovanni Millo, Gianfranco Piras
spml
, spgm
data(Produc, package = "plm") data(usaww) spremod<-spml(log(gsp)~log(pcap)+log(pc)+log(emp)+unemp, data=Produc, listw = spdep::mat2listw(usaww), model="random", lag=TRUE, spatial.error="none") summary(spremod)
data(Produc, package = "plm") data(usaww) spremod<-spml(log(gsp)~log(pcap)+log(pc)+log(emp)+unemp, data=Produc, listw = spdep::mat2listw(usaww), model="random", lag=TRUE, spatial.error="none") summary(spremod)
yearly observations of 171 farms
number of observations : 1026
country : Indonesia
economic topic : producer behavior
econometrics topic : error component
data(RiceFarms)
data(RiceFarms)
A dataframe containing :
the farm identifier
the growing season
the total area cultivated with rice, measured in hectares
land status, on of 'owner'
(non sharecroppers, owner operators or leasholders or both), 'share'
(sharecroppers), 'mixed'
(mixed of the two previous status)
one of 'trad'
(traditional varieties), 'high'
(high yielding varieties) and 'mixed'
(mixed varieties)
bIMAS is an intensification program ; one of 'no'
(non-bimas famer), 'yes'
(bimas farmer) or 'mixed'
(part but not all of farmer's land was registered to be in the bimas program)
seed in kilogram
urea in kilogram
phosphate in kilogram
pesticide cost in Rupiah
price of seed in Rupiah per kg
price of urea in Rupiah per kg
price of phosphate in Rupiah per kg
hired labor in hours
family labor in hours
total labor (excluding harvest labor)
labor wage in Rupiah per hour
gross output of rice in kg
net output, gross output minus harvesting cost (paid in terms of rice)
price of rough rice in Rupiah per Kg
one of 'wargabinangun'
, 'langan'
, 'gunungwangi'
, 'malausma'
, 'sukaambit'
, 'ciwangi'
Journal of Applied Econometrics Data Archive.
Qu Feng and William C. Horrace, (2012) “Alternative Measures of Technical Efficiency: Skew, Bias and Scale”, Journal of Applied Econometrics, forthcoming.
Horrace, W.C. and P. Schmidt (1996) “Confidence statements for efficiency estimates from stochastic frontier models”, Journal of Productivity Analysis, 7, 257–282.
Spatial weights matrix of the 171 farms in the Indonesian Rice Farming example. Farms in the same village (out of six) are considered contiguous.
data(riceww)
data(riceww)
A matrix with elements different from zero if farms i and j are neighbors. Farms are considered neighbors if in the same village. Weights are row-standardized.
Giovanni Millo, data provided by Yves Croissant
Randomization-based test of spatial dependence for panel models, robust to global dependence induced by common factors and to persistence (serial correlation) in the data
rwtest(x, ...) ## S3 method for class 'formula' rwtest(x, data, w, index = NULL, model = NULL, replications = 99, seed=NULL, order=1, mc=1, test = c("rho", "cd", "sclm"), alternative=c("twosided", "onesided", "symmetric"), ...) ## S3 method for class 'panelmodel' rwtest(x, w, replications = 99, seed=NULL, order=1, mc=1, test = c("rho", "cd", "sclm"), alternative=c("twosided", "onesided", "symmetric"), ...) ## S3 method for class 'pseries' rwtest(x, w, replications = 99, seed=NULL, order=1, mc=1, test = c("rho", "cd", "sclm"), alternative=c("twosided", "onesided", "symmetric"), ...)
rwtest(x, ...) ## S3 method for class 'formula' rwtest(x, data, w, index = NULL, model = NULL, replications = 99, seed=NULL, order=1, mc=1, test = c("rho", "cd", "sclm"), alternative=c("twosided", "onesided", "symmetric"), ...) ## S3 method for class 'panelmodel' rwtest(x, w, replications = 99, seed=NULL, order=1, mc=1, test = c("rho", "cd", "sclm"), alternative=c("twosided", "onesided", "symmetric"), ...) ## S3 method for class 'pseries' rwtest(x, w, replications = 99, seed=NULL, order=1, mc=1, test = c("rho", "cd", "sclm"), alternative=c("twosided", "onesided", "symmetric"), ...)
x |
an object of class |
data |
a |
w |
a |
index |
an optional numerical index, in case |
model |
an optional character string indicating which type of
model to estimate;
if left to |
replications |
the number of Monte Carlo randomizations of the neighbourhood matrix (default: 99), |
seed |
the optional random seed, |
order |
the order of neighbourhood to test for, |
mc |
the number of parallel threads to execute; defaults to 1 (serial execution); is limited to the number of execution cores actually available, and depends on operating system support. |
test |
the type of test statistic to be returned. One of
|
alternative |
the alternative hypothesis for the test, defaulting to (asymmetric) twosided, |
... |
further arguments to be passed on to |
This test is meant as a generalization of Pesaran's spatial dependence test "CD(p)" for robustness against global dependence (perhaps of the factor type) and persistence in the data, both of which the original test does not tolerate.
The procedure can be applied to model residuals as well as to
individual pseries
.
See the comments in pcdtest
as for the different methods.
Space is defined supplying a proximity matrix (elements coercible to
logical
) with argument w
which provides information on
whether any pair of individuals are neighbours or not. If
order=1
, only first-order neighbouring pairs will be used in
computing the test; else, w
will be transformed in the
neighbourhood matrix of the appropriate order. The matrix need not be
binary, so commonly used “row–standardized” matrices can be employed
as well. nb
objects from spdep must instead be transformed
into matrices by spdep's function nb2mat
before using.
Notice that the "rho"
and "cd"
tests are permutationally
equivalent.
The test is suitable also for unbalanced panels.
The test on a pseries
is the same as a test on a pooled
regression model of that variable on a constant,
i.e. rwtest(some_pseries)
is equivalent to
rwtest(plm(some_var ~ 1, data = some_pdata.frame, model =
"pooling")
and also equivalent to rwtest(some_var ~ 1, data =
some_data)
, where some_var
is the variable name in the data
which corresponds to some_pseries
.
An object of class "htest"
.
Giovanni Millo
Millo, G. (2016), A simple randomization test for spatial dependence in the presence of common factors and serial correlation, (unpublished), xx(x), pp. xxx–xxx. Pesaran, M.H. (2004), General Diagnostic Tests for Cross Section Dependence in Panels, CESifo Working Paper 1229. Pesaran, M.H. (2015), Testing Weak Cross–Sectional Dependence in Large Panels, Econometric Reviews, 34(6-10), pp. 1089–1117.
data(Produc, package = "plm") data(usaww) fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp ## test on heterogeneous model (separate time series regressions) rwtest(fm, data = Produc, w=usaww, index = c("state", "year")) ## test on two-way fixed effects homogeneous model rwtest(fm, data = Produc, w=usaww, index = c("state", "year"), model = "within", effect = "twoways") ## test on panelmodel object library(plm) g <- plm(fm, data = Produc) rwtest(g, w=usaww) ## test on pseries, higher-order neighbourhood pprod <- pdata.frame(Produc) rwtest(pprod$gsp, w=usaww, order=3)
data(Produc, package = "plm") data(usaww) fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp ## test on heterogeneous model (separate time series regressions) rwtest(fm, data = Produc, w=usaww, index = c("state", "year")) ## test on two-way fixed effects homogeneous model rwtest(fm, data = Produc, w=usaww, index = c("state", "year"), model = "within", effect = "twoways") ## test on panelmodel object library(plm) g <- plm(fm, data = Produc) rwtest(g, w=usaww) ## test on pseries, higher-order neighbourhood pprod <- pdata.frame(Produc) rwtest(pprod$gsp, w=usaww, order=3)
Spatial lagging method for vectors or pseries
objects.
## S3 method for class 'pseries' slag(x, listw, maxlag, ...) ## Default S3 method: slag(x, listw, maxlag, index, ...)
## S3 method for class 'pseries' slag(x, listw, maxlag, ...) ## Default S3 method: slag(x, listw, maxlag, index, ...)
x |
an object of class |
listw |
an object of class |
maxlag |
the spatial lag order (including lower) |
index |
the default method needs a well-specified index |
... |
additional arguments to be passed |
a pseries
Giovanni Millo
data(Produc, package="plm") data(usaww) usalw <- spdep::mat2listw(usaww) fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp+slag(log(pcap), listw=usalw) slxmod <- spreml(fm, data=Produc, w = usaww, model="pooling", lag=FALSE, errors="ols")
data(Produc, package="plm") data(usaww) usalw <- spdep::mat2listw(usaww) fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp+slag(log(pcap), listw=usalw) slxmod <- spreml(fm, data=Produc, w = usaww, model="pooling", lag=FALSE, errors="ols")
Locally robust LM tests for spatial lag (error) correlation sub spatial error (lag) correlation in panel models
slmtest(x,...) ## S3 method for class 'formula' slmtest(formula, data, listw, model="pooling", test=c("lme","lml","rlme","rlml"), index=NULL, ...) ## S3 method for class 'plm' slmtest(x, listw, test=c("lme","lml","rlme","rlml"), ...)
slmtest(x,...) ## S3 method for class 'formula' slmtest(formula, data, listw, model="pooling", test=c("lme","lml","rlme","rlml"), index=NULL, ...) ## S3 method for class 'plm' slmtest(x, listw, test=c("lme","lml","rlme","rlml"), ...)
formula |
an object of class |
data |
a |
x |
an object of class |
listw |
either a |
model |
a character value specifying the transformation to be applied to the data. |
test |
one of |
index |
either NULL (default) or a character vector to identify the indexes among the columns of the |
... |
additional arguments to be passed |
This tests are panel versions of the locally robust LM tests of Anselin et al. (1996), based on a pooling assumption: i.e., they do not allow for any kind of individual effect. Therefore it is advisable to employ a within transformation whenever individual effects cannot be ruled out.
It must be kept in mind that these locally robust procedures have been designed for situations in which the "other" effect is not of substantial magnitude, and can behave suboptimally otherwise.
Four tests are available to be chosen through the test
argument: "lml"
for "LM lag" and, respectively, "lme"
for "LM error" are the standard, non-robust versions, obtained simply
pooling the cross-sectional versions; "rlml"
and "rlme"
are, respectively, the locally robust test for lag, allowing for a
spatial error; and for error, allowing for a spatial lag.
The model
argument, specified according to the standards of
plm
, is passed on internally and employed to determine the panel
data transformation to be applied before calculating the test. Defaults
to "pooling"
(no transformation).
an object of class htest
Giovanni Millo
Anselin, L., Bera, A.K., Florax, R. and Yoon, M.J. (1996) Simple diagnostic tests for spatial dependence. Regional Science and Urban Economics, 26(1), 77-104. Elhorst, J.P. (2014) Spatial Panel data Models, in Spatial Econometrics (Springer) 37-93.
data(Produc, package="plm") data(usaww) fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp ## robust LM test for spatial error sub spatial lag ## model on original data, pooling hypothesis slmtest(fm, data=Produc, listw = usaww, test="rlme") ## model on within-transformed (time-demeaned) data, ## eliminates individual effects slmtest(fm, data=Produc, listw = usaww, test="rlme", model="within")
data(Produc, package="plm") data(usaww) fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp ## robust LM test for spatial error sub spatial lag ## model on original data, pooling hypothesis slmtest(fm, data=Produc, listw = usaww, test="rlme") ## model on within-transformed (time-demeaned) data, ## eliminates individual effects slmtest(fm, data=Produc, listw = usaww, test="rlme", model="within")
GM estimation of panel data models with spatially correlated errors components of the form:
where , and the variance components
and
are estimated by GM, and the model coefficients by a Feasible GLS estimator. The model can also include
additional (other than the spatial lag) endogenous variables.
spgm(formula, data=list(), index=NULL, listw = NULL, listw2 = NULL, Durbin = FALSE, model = c("within", "random"), lag = FALSE, spatial.error = TRUE, moments = c("initial", "weights", "fullweights"), endog = NULL, instruments = NULL, lag.instruments = FALSE, verbose = FALSE, method = c("w2sls", "b2sls", "g2sls", "ec2sls"), control = list(), optim.method = "nlminb", pars = NULL)
spgm(formula, data=list(), index=NULL, listw = NULL, listw2 = NULL, Durbin = FALSE, model = c("within", "random"), lag = FALSE, spatial.error = TRUE, moments = c("initial", "weights", "fullweights"), endog = NULL, instruments = NULL, lag.instruments = FALSE, verbose = FALSE, method = c("w2sls", "b2sls", "g2sls", "ec2sls"), control = list(), optim.method = "nlminb", pars = NULL)
formula |
a description of the model to be fit. The details of model specification are given
for |
data |
an object of class |
index |
if not NULL (default), a character vector to identify the indexes among the columns of the |
listw |
an object of class |
.
listw2 |
an object of class |
Durbin |
default |
model |
One of |
lag |
if |
spatial.error |
a logic vector. If |
moments |
|
endog |
additional endogenous variables. Default |
instruments |
external instruments. Default |
lag.instruments |
should the external instruments be spatially lagged? |
verbose |
default |
method |
One of |
control |
a list of control parameters for the optimization |
optim.method |
default set to |
pars |
initial values of the parameter |
The function is a very general interface to estimate various nested specifications of the
general model including additional endogenous variables described above.
When both spatial.error
and lag
are FALSE
the model reduces to a
panel data model with an additional endogeneous variable. The function then uses ivsplm
to perform the Instrumental Variables and two-stage least squares for panel data model. method = "w2sls"
corresponds to the fixed effects estimator, method = "b2sls"
to the between effects model,
method = "g2sls"
to the GLS random effects model, and method = "ec2sls"
to the Baltagi's
EC2SLS.
When spatial.error
is TRUE
and lag
is FALSE
the model is one with spatially autocorrelated
error components. If effects
is "random"
, the Kapoor et al. (2007) GM estimator is performed and
the residuals in the first step come from an OLS regression.
When moments
is "initial"
, the initial estimator is calculated. This first set
of GM estimators is based only on a subset of the moments conditions and assigns
equal weigths to each of them.
When moments
is "fullweights"
, the second set of GM estimators is calculated. This estimator
is based on the full set of moments conditions. It also involves the expression for the variance
covariance matrix of the sample moments calculated under the assumption of
normally distributed innovations. The calculation of the trace terms in the expression
of the variance covariance matrix of the sample moments
uses codes from the Matrix
package.
When moments
is"weights"
, the third set of GM estimator is used. This is motivated by computational
issues. The procedure is analogous to the second one but uses a simplified expression for the
variance covariance matrix of the sample moments.
If effects
is "fixed"
, the initial
estimator is a within estimator and the moments conditions of Kapoor et al. (2007) are modified accordingly.
Finally, when both spatial.error
and lag
are TRUE
the complete model is estimated (with or without
additional endogenous variables). OLS residuals are no longer consistent because of the spatially lagged dependent variable.
If effects
is "random"
, two initial estimators are computed: a within two-stage least squares
and a between two stage least squares. The two sets of corresponding residuals are used in the spatial generalized moments estimator
(GM) where the moments conditions of Kapoor et al. (2007) are again modified accordingly.
If effects
is "fixed"
, the initial
estimator is a within two stage least squares estimator and the moments conditions of Kapoor et al. (2007) are modified accordingly.
Note that for the random effects models, is not reported.
is reported instead.
However, a value for
can easily be obtained from:
The function also produces an estimate for which is a
function of the variance components.
An object of class "splm"
.
coefficients |
GLS coefficients estimate of the model parameters |
vcov |
the variance covariance matrix of the estimated coefficients |
residuals |
the GLS residuals |
fitted.values |
difference between response variable and residuals |
sigma2 |
GLS residuals variance |
type |
'a description of the model estimated' |
rho |
a vector including the spatial parameter and the variance components (see Details) |
model |
the matrix of the data used |
call |
the call used to create the object |
Gianfranco Piras
Kapoor, M., Kelejian, H.H. and Prucha, I.R. (2007) Panel data model with spatially correlated error components, Journal of Econometrics, 140, pages 97–130.
Mutl, J., and Pfaffermayr, M. (2011) The Hausman test in a Cliff and Ord panel model, Econometrics Journal, 14, pages 48–76.
Kelejian, H.H. and Prucha, I.R. (1999) A Generalized Moments Estimator for the Autoregressive Parameter in a Spatial Model, International Economic Review, 40, pages 509–533.
Kelejian, H.H. and Prucha, I.R. (1999) A Generalized Spatial Two Stage Least Square Procedure for Estimating a Spatial Autoregressive Model with Autoregressive Disturbances, Journal of Real Estate Finance and Economics, 17, pages 99–121.
Millo, G., Piras, G. (2012) splm: Spatial Panel Data Models in R. Journal of Statistical Software, 47(1), 1–38. URL http://www.jstatsoft.org/v47/i01/.
library(splm) library(plm) data(Produc) data(usaww) ########SPATIAL LAG MODEL###### #no space no endog: error use plm ## Not run: GM_lag_b2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = FALSE, method = "b2sls", listw = usaww) ## End(Not run) #no space but endog GM_b2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap), method = "b2sls", instruments = ~log(hwy), listw = usaww) summary(GM_b2sls_e) GM_g2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap), method = "g2sls", instruments = ~log(hwy), listw = usaww) summary(GM_g2sls_e) GM_ec2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap), method = "ec2sls", instruments = ~log(hwy), listw = usaww) summary(GM_ec2sls_e) GM_w2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap), method = "w2sls", instruments = ~log(hwy), listw = usaww) summary(GM_w2sls_e) #SPATIAL LAG MODEL GM_lag_b2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, method = "b2sls", listw = usaww) summary(GM_lag_b2sls) GM_lag_g2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, method = "g2sls", listw = usaww) summary(GM_lag_g2sls) GM_lag_ec2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, method = "ec2sls", listw = usaww) summary(GM_lag_ec2sls) GM_lag_w2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, listw = usaww, method = "w2sls") summary(GM_lag_w2sls) #endogenous GM_lag_b2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, endog = ~ log(pcap), method = "b2sls", instruments = ~log(hwy), listw = usaww) summary(GM_lag_b2sls_e) GM_lag_g2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, endog = ~ log(pcap), method = "g2sls", instruments = ~log(hwy), listw = usaww) summary(GM_lag_g2sls_e) GM_lag_ec2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, endog = ~ log(pcap), method = "ec2sls", instruments = ~log(hwy), listw = usaww) summary(GM_lag_ec2sls_e) GM_lag_w2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, endog = ~ log(pcap), method = "w2sls", instruments = ~log(hwy), listw = usaww) summary(GM_lag_w2sls_e) ########SPATIAL ERROR MODEL###### GM_error_within <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, model = "within", listw = usaww) summary(GM_error_within) GM_error_random <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, model = "random", listw = usaww) summary(GM_error_random) GM_error_within_fw <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, model = "within", listw = usaww, moments = "fullweights") summary(GM_error_within_fw) GM_error_random_w <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, model = "random", listw = usaww, moments = "fullweights") summary(GM_error_random_w) #endogenous GM_error_within_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, endog = ~ log(pcap), model = "within", instruments = ~log(hwy), listw = usaww) summary(GM_error_within_e) GM_error_random_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, endog = ~ log(pcap), model = "random", instruments = ~log(hwy), listw = usaww) summary(GM_error_random_e) ########SARAR MODEL###### GM_sarar_within <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, model = "within", listw = usaww) summary(GM_sarar_within) GM_sarar_random <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, model = "random", listw = usaww) summary(GM_sarar_random) GM_sarar_within_fw <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, model = "within", listw = usaww, moments = "fullweights") summary(GM_sarar_within_fw) GM_sarar_random_fw <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, model = "random", listw = usaww, moments = "fullweights") summary(GM_sarar_random_fw) #endogenous GM_sarar_within_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, endog = ~ log(pcap), model = "within", instruments = ~log(hwy), listw = usaww) summary(GM_sarar_within_e) GM_sarar_random_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, endog = ~ log(pcap), model = "random", instruments = ~log(hwy), listw = usaww) summary(GM_sarar_random_e)
library(splm) library(plm) data(Produc) data(usaww) ########SPATIAL LAG MODEL###### #no space no endog: error use plm ## Not run: GM_lag_b2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = FALSE, method = "b2sls", listw = usaww) ## End(Not run) #no space but endog GM_b2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap), method = "b2sls", instruments = ~log(hwy), listw = usaww) summary(GM_b2sls_e) GM_g2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap), method = "g2sls", instruments = ~log(hwy), listw = usaww) summary(GM_g2sls_e) GM_ec2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap), method = "ec2sls", instruments = ~log(hwy), listw = usaww) summary(GM_ec2sls_e) GM_w2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap), method = "w2sls", instruments = ~log(hwy), listw = usaww) summary(GM_w2sls_e) #SPATIAL LAG MODEL GM_lag_b2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, method = "b2sls", listw = usaww) summary(GM_lag_b2sls) GM_lag_g2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, method = "g2sls", listw = usaww) summary(GM_lag_g2sls) GM_lag_ec2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, method = "ec2sls", listw = usaww) summary(GM_lag_ec2sls) GM_lag_w2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, listw = usaww, method = "w2sls") summary(GM_lag_w2sls) #endogenous GM_lag_b2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, endog = ~ log(pcap), method = "b2sls", instruments = ~log(hwy), listw = usaww) summary(GM_lag_b2sls_e) GM_lag_g2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, endog = ~ log(pcap), method = "g2sls", instruments = ~log(hwy), listw = usaww) summary(GM_lag_g2sls_e) GM_lag_ec2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, endog = ~ log(pcap), method = "ec2sls", instruments = ~log(hwy), listw = usaww) summary(GM_lag_ec2sls_e) GM_lag_w2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = FALSE, endog = ~ log(pcap), method = "w2sls", instruments = ~log(hwy), listw = usaww) summary(GM_lag_w2sls_e) ########SPATIAL ERROR MODEL###### GM_error_within <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, model = "within", listw = usaww) summary(GM_error_within) GM_error_random <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, model = "random", listw = usaww) summary(GM_error_random) GM_error_within_fw <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, model = "within", listw = usaww, moments = "fullweights") summary(GM_error_within_fw) GM_error_random_w <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, model = "random", listw = usaww, moments = "fullweights") summary(GM_error_random_w) #endogenous GM_error_within_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, endog = ~ log(pcap), model = "within", instruments = ~log(hwy), listw = usaww) summary(GM_error_within_e) GM_error_random_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = FALSE, spatial.error = TRUE, endog = ~ log(pcap), model = "random", instruments = ~log(hwy), listw = usaww) summary(GM_error_random_e) ########SARAR MODEL###### GM_sarar_within <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, model = "within", listw = usaww) summary(GM_sarar_within) GM_sarar_random <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, model = "random", listw = usaww) summary(GM_sarar_random) GM_sarar_within_fw <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, model = "within", listw = usaww, moments = "fullweights") summary(GM_sarar_within_fw) GM_sarar_random_fw <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, model = "random", listw = usaww, moments = "fullweights") summary(GM_sarar_random_fw) #endogenous GM_sarar_within_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, endog = ~ log(pcap), model = "within", instruments = ~log(hwy), listw = usaww) summary(GM_sarar_within_e) GM_sarar_random_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc, lag = TRUE, spatial.error = TRUE, endog = ~ log(pcap), model = "random", instruments = ~log(hwy), listw = usaww) summary(GM_sarar_random_e)
Hausman specification test for spatial panel data models
sphtest(x, ...) ## S3 method for class 'formula' sphtest(x, data, index = NULL, listw, spatial.model = c("lag", "error", "sarar"), method = c("ML", "GM"), errors = c("KKP", "BSK"),...) ## S3 method for class 'splm' sphtest(x, x2, ...)
sphtest(x, ...) ## S3 method for class 'formula' sphtest(x, data, index = NULL, listw, spatial.model = c("lag", "error", "sarar"), method = c("ML", "GM"), errors = c("KKP", "BSK"),...) ## S3 method for class 'splm' sphtest(x, x2, ...)
x |
an object of class |
x2 |
an object of class |
data |
an object of class |
index |
if not NULL (default), a character vector to identify the indexes among the columns of the |
listw |
an object of class |
spatial.model |
one of |
method |
one of |
errors |
one of |
... |
additional arguments to be passed |
an object of class htest
Gianfranco Piras
Millo, G., Piras, G. (2012) splm: Spatial Panel Data Models in R. Journal of Statistical Software, 47(1), 1–38. URL http://www.jstatsoft.org/v47/i01/.
spgm
data(Produc, package="plm") data(usaww) fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp test1<-sphtest(fm,data=Produc, listw = spdep::mat2listw(usaww), spatial.model = "error", method="GM") test1 mod1<- spgm(fm, data=Produc, listw = usaww, model = "random", spatial.error = TRUE, moments="fullweights") mod2<- spgm(fm, data=Produc, listw = usaww, model = "within", spatial.error = TRUE) test2<-sphtest(mod1, mod2) test2
data(Produc, package="plm") data(usaww) fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp test1<-sphtest(fm,data=Produc, listw = spdep::mat2listw(usaww), spatial.model = "error", method="GM") test1 mod1<- spgm(fm, data=Produc, listw = usaww, model = "random", spatial.error = TRUE, moments="fullweights") mod2<- spgm(fm, data=Produc, listw = usaww, model = "within", spatial.error = TRUE) test2<-sphtest(mod1, mod2) test2
Maximum likelihood (ML) estimation of spatial panel models, possibly with fixed or random effects.
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"), ...) ## S3 method for class 'splm_ML' impacts(obj, listw = NULL, time = NULL, ..., tr = NULL, R = 200, type = "mult", empirical = FALSE, Q = NULL) ## S3 method for class 'splm_GM' impacts(obj, ..., tr=NULL, R=NULL, listw=NULL, type = "mult", time = NULL, evalues=NULL, tol=1e-6, empirical=FALSE, Q=NULL, KPformula = FALSE, prt = TRUE)
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"), ...) ## S3 method for class 'splm_ML' impacts(obj, listw = NULL, time = NULL, ..., tr = NULL, R = 200, type = "mult", empirical = FALSE, Q = NULL) ## S3 method for class 'splm_GM' impacts(obj, ..., tr=NULL, R=NULL, listw=NULL, type = "mult", time = NULL, evalues=NULL, tol=1e-6, empirical=FALSE, Q=NULL, KPformula = FALSE, prt = TRUE)
formula |
a symbolic description of the model to be estimated |
data |
an object of class |
index |
if not NULL (default), a character vector to identify the indexes among the columns of the |
listw |
an object of class |
listw2 |
an object of class |
na.action |
see spdep for more details. |
model |
one of |
effect |
one of |
lag |
default= |
spatial.error |
one of |
... |
additional argument to pass over to other functions |
obj |
fitted model object |
time |
??time?? |
tr |
A vector of traces of powers of the spatial weights matrix created using 'trW', for approximate impact measures |
R |
If given, simulations are used to compute distributions for the impact measures, returned as 'mcmc' objects |
type |
Either "mult" (default) for powering a sparse matrix (with moderate or larger N, the matrix becomes dense, and may lead to swapping), or "MC" for Monte Carlo simulation of the traces (the first two simulated traces are replaced by their analytical equivalents), or "moments" to use the looping space saving algorithm proposed by Smirnov and Anselin (2009) - for "moments", 'W' must be symmetric, for row-standardised weights through a similarity transformation |
empirical |
Argument passed to 'mvrnorm' (default FALSE) |
Q |
default NULL, else an integer number of cumulative power series impacts to calculate if 'tr' is given |
evalues |
vector of eigenvalues of spatial weights matrix for impacts calculations |
tol |
Argument passed to 'mvrnorm' |
KPformula |
not yet implemented |
prt |
not yet implemented |
The models are estimated by two-step Maximum Likelihood.
Further optional parameters to be passed on to the estimator may be:
pvar: if TRUE
the pvar
function is called
hess: if TRUE
use numerical Hessian instead of GLS for the
standard errors of the estimates
quiet: if FALSE
report function and parameters values during
optimization
initval: one of c("zeros", "estimate")
, the initial values for
the parameters. If "zeros"
a vector of zeros is used. if
"estimate"
the initial values are retreived from the estimation
of the nested specifications. Alternatively, a numeric vector can be
specified.
x.tol: Tolerance. See nlminb
for details.
rel.tol: Relative tolerance. See nlminb
for details.
An object of class "splm"
.
coefficients |
coefficients estimate of the model parameters |
arcoef |
the coefficient for the spatial lag on |
errcomp |
the estimates of the error variance components |
vcov |
the asymptotic variance covariance matrix of the estimated coefficients |
vcov.arcoef |
the asymptotic variance of the estimated spatial lag parameter |
vcov.errcomp |
the asymptotic variance covariance matrix of the estimated error covariance parameters |
type |
'random effects ML' |
residuals |
the model residuals |
fitted.values |
the fitted values, calculated as |
sigma2 |
GLS residuals variance |
model |
the matrix of the data used |
call |
the call used to create the object |
logLik |
the value of the log likelihood function at the optimum |
errors |
the value of the |
Giovanni Millo
Baltagi, B.H., Song, S.H., Jung B. and Koh, W. (2007) Testing panel data regression models with spatial and serial error correlation. Journal of Econometrics, 140, 5-51.
Millo, G., Piras, G. (2012) splm: Spatial Panel Data Models in R. Journal of Statistical Software, 47(1), 1–38. URL http://www.jstatsoft.org/v47/i01/.
spgm
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)
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)
Maximum likelihood (ML) estimation of spatial panel models with random effects and serial error correlation.
spreml(formula, data, index = NULL, w, w2=w, lag = FALSE, errors = c("semsrre", "semsr", "srre", "semre", "re", "sr", "sem","ols", "sem2srre", "sem2re", "semgre"), pvar = FALSE, hess = FALSE, quiet = TRUE, initval = c("zeros", "estimate"), x.tol = 1.5e-18, rel.tol = 1e-15, ...)
spreml(formula, data, index = NULL, w, w2=w, lag = FALSE, errors = c("semsrre", "semsr", "srre", "semre", "re", "sr", "sem","ols", "sem2srre", "sem2re", "semgre"), pvar = FALSE, hess = FALSE, quiet = TRUE, initval = c("zeros", "estimate"), x.tol = 1.5e-18, rel.tol = 1e-15, ...)
formula |
a symbolic description of the model to be estimated |
data |
an object of class |
index |
if not NULL (default), a character vector to identify the indexes among the columns of the |
w |
an object of class |
w2 |
an object of class |
lag |
default= |
errors |
Specifies the error covariance structure. See details. |
pvar |
legacy parameter here only for compatibility. |
hess |
default= |
quiet |
default= |
initval |
one of |
x.tol |
control parameter for tolerance. See |
rel.tol |
control parameter for relative tolerance. See |
... |
additional arguments to pass over to other functions, e.g. |
Second-level wrapper for estimation of random effects models
with serial and spatial correlation. The specifications without serial
correlation (no "sr" in errors
) can be called through
spml
, the extended ones only through spreml
.
The models are estimated by two-step Maximum Likelihood.
Abbreviations in errors
correspond to: "sem"
Anselin-Baltagi type spatial autoregressive error: if
present, random effects are not spatially correlated; "sem2"
Kapoor, Kelejian and Prucha-type spatial autoregressive error model
with spatially correlated random effects; "sr"
serially
correlated remainder errors; "re"
random effects; "ols"
spherical errors (usually combined with lag=T
).
The optimization method
can be passed on as optional
parameter. Default is "nlminb"
; all constrained optimization
methods from maxLik
are allowed ("BFGS", "NM", "SANN"
)
but the latter two are still experimental.
An object of class "splm"
.
coefficients |
coefficients estimate of the model parameters |
arcoef |
the coefficient for the spatial lag on |
errcomp |
the estimates of the error variance components |
vcov |
the asymptotic variance covariance matrix of the estimated coefficients |
vcov.arcoef |
the asymptotic variance of the estimated spatial lag parameter |
vcov.errcomp |
the asymptotic variance covariance matrix of the estimated error covariance parameters |
type |
'random effects ML' |
residuals |
the model residuals |
fitted.values |
the fitted values, calculated as |
sigma2 |
GLS residuals variance |
model |
the matrix of the data used |
call |
the call used to create the object |
logLik |
the value of the log likelihood function at the optimum |
errors |
the value of the |
Giovanni Millo
Millo, G. (2014) Maximum likelihood estimation of spatially and serially correlated panels with random effects. Computational Statistics and Data Analysis, 71, 914–933.
spml
data(Produc, package = "plm") data(usaww) fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp ## random effects panel with spatial lag and serial error correlation ## optimization method set to "BFGS" sarsrmod <- spreml(fm, data = Produc, w = usaww, errors="sr", lag=TRUE, method="BFGS") summary(sarsrmod)
data(Produc, package = "plm") data(usaww) fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp ## random effects panel with spatial lag and serial error correlation ## optimization method set to "BFGS" sarsrmod <- spreml(fm, data = Produc, w = usaww, errors="sr", lag=TRUE, method="BFGS") summary(sarsrmod)
Method for summarizing the results of objects of class 'splm'
## S3 method for class 'splm' summary(object,...)
## S3 method for class 'splm' summary(object,...)
object |
an object of class |
... |
additional arguments to be passed |
The summary function summary.splm
returns an objects of class 'splm'
organized in a coefficient matrix.
Also a matrix for the error components, or the spatial coefficients will be generated depending on the estimated model.
When the 'splm'
is produced by
the function 'spsegm', the summary
will be generated looping over the number
of equations in the system.
An object of class 'summary.splm'
Giovanni Millo, Gianfranco Piras
spml
, spgm
data(Produc, package = "plm") data(usaww) GM <- spgm(log(gsp)~log(pcap)+log(pc)+log(emp)+unemp, data=Produc, listw=usaww, moments = "fullweights", spatial.error = TRUE) summary(GM)
data(Produc, package = "plm") data(usaww) GM <- spgm(log(gsp)~log(pcap)+log(pc)+log(emp)+unemp, data=Produc, listw=usaww, moments = "fullweights", spatial.error = TRUE) summary(GM)
Spatial weights matrix of the 48 continental US States based on the queen contiguity criterium.
data(usaww)
data(usaww)
A matrix with elements different from zero if state i and j are neighbors. Weights are row standardized. According to the queen contiguity criterium, Arizona and Colorado are considered neighbours.
Giovanni Millo
splm
objectsCovariance extractor method for splm
objects. Seldom used as
such but needed, e.g., for
interoperability with testing functions in lmtest and car.
## S3 method for class 'splm' vcov(object, ...)
## S3 method for class 'splm' vcov(object, ...)
object |
an object of class |
... |
additional arguments to be passed; currently not used |
a covariance matrix of beta coefficients
Giovanni Millo
Zeileis, A. (2006) Object-Oriented Computation of Sandwich Estimators. Journal of Statistical Software, 16(9), 1-16.
## not run: ## data(Produc, package="plm") ## data(usaww) ## fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp ## sarremod <- spml(fm, data=Produc, listw = spdep::mat2listw(usaww), ## model="random", lag=TRUE, spatial.error="none") ## ## compact representation of betas ## library(lmtest) ## coeftest(sarremod) ## ## linear hypothesis test ## library(car) ## lht(sarremod, "log(pcap)=log(pc)")
## not run: ## data(Produc, package="plm") ## data(usaww) ## fm <- log(gsp)~log(pcap)+log(pc)+log(emp)+unemp ## sarremod <- spml(fm, data=Produc, listw = spdep::mat2listw(usaww), ## model="random", lag=TRUE, spatial.error="none") ## ## compact representation of betas ## library(lmtest) ## coeftest(sarremod) ## ## linear hypothesis test ## library(car) ## lht(sarremod, "log(pcap)=log(pc)")