Description Usage Arguments Details Value Author(s) References Examples
The function calculate the Kelejian and Piras J-test for spatial models. Both models (under the null and under the alternative) can be specified with additional endogenous variables, and additional instruments. The model under the null allows for heteroskedasticity as well as spatial autocorrelation:
y=λ W y + X β + u
u=Re
with
e ~ N(0,σ^2_i)
Note that when R reduces to an identity matrix, the error term, while still heteroskedastic, is not spatially autocorrelated. On the other hand, when the σ^2_i are all the same (and R is an identity matrix) than the error term is neither heteroskedastic nor autocorrelated.
1 2 3 4 5 |
H0model |
Formula object for the specification of the model under the null |
H1model |
Formula object for the specification of the model under the alternative |
data |
an object of class data.frame. An optional data frame containing the variables in the model. |
listw0 |
an object of class |
listw1 |
an object of class |
endogH0 |
additional endogenous variables under the null model. Default |
endogH1 |
additional endogenous variables under the alternative model. Default |
instrumentsH0 |
external instruments for the null model. Default |
instrumentsH1 |
external instruments for the alternative model. Default |
lag.instr |
should the external instruments be spatially lagged? |
model |
one of |
het |
default FALSE: if TRUE uses the methods developed for heteroskedasticity |
na.action |
a function which indicates what should happen when the data contains missing values. See lm for details. |
HAC |
perform the HAC estimator of Kelejian and Prucha, 2007 on the null (and augmented) model. |
distance |
an object of class |
type |
One of |
bandwidth |
"variable" (default) - or numeric when a fixed bandwidth is specified by the user. |
In order to calculate the J-test, the function follows a few steps:
The alternative model is estimated by S2SLS.
Based on the estimated parameters in the previous step, obtain a prediction based on the alternative models of the dependent vector in the null model. The predictor is based on the right hand side of the model.
Use these predicted values of the dependent variable based on the alternative models into the null model to obtain the augmented model.
Estimate the augmented model by 2SLS using all of the instruments relating to the null model as well as all of the instruments relating to the alternative models.
Test for the statistical significance of the predicted value. If it is not significant, accept the null model. If it is significant, reject the null and conclude that the true model is the alternative models.
The output is an object of class sphet
where the last row of the table of coefficients is the prediction.
When the model is heteroskedastic as well as spatially autocorrelated, an HAC procedure is employed. The default sets the bandwith for each observation to the maximum distance for that observation (i.e. the max of each element of the list of distances).
Six different kernel functions are implemented:
'Epanechnikov'
: K(z) = 1-z^2
'Triangular'
: K(z) = 1-z
'Bisquare'
: K(z) = (1-z^2)^2
'Parzen'
: K(z) = 1-6z^2+6 |z|^3 if z ≤q 0.5 and
K(z) = 2(1-|z|)^3 if 0.5 < z ≤q 1
'TH'
(Tukey - Hanning): K(z) = \frac{1+ \cos(π z)}{2}
'Rectangular'
: K(z) = 1
'QS'
(Quadratic Spectral): K(z) = \frac{25}{12π^2z^2}
(\frac{\sin(6π z)/5)}{6π z/5} - \cos(6π z)/5)).
If the kernel type is not one of the six implemented, the function will terminate with an error message. The spatial two stage least square estimator is based on the matrix of instruments H=[X,WX,W^2X^2].
A list object of class sphet
coefficients |
Generalized Spatial two stage least squares coefficient estimates of δ and GM estimator for ρ. |
var |
variance-covariance matrix of the estimated coefficients |
s2 |
GS2SLS residuals variance |
residuals |
GS2SLS residuals |
yhat |
difference between GS2SLS residuals and response variable |
call |
the call used to create this object |
model |
the model matrix of data |
method |
|
Gianfranco Piras gpiras@mac.com
Kelejian and Piras (2017). Spatial Econometrics. Academic Press. ISBN: 978-0-12-813387-3
Gianfranco Piras (2010). sphet: Spatial Models with Heteroskedastic Innovations in R. Journal of Statistical Software, 35(1), 1-21. http://www.jstatsoft.org/v35/i01/.
Roger Bivand, Gianfranco Piras (2015). Comparing Implementations of Estimation Methods for Spatial Econometrics. Journal of Statistical Software, 63(18), 1-36. http://www.jstatsoft.org/v63/i18/.
1 2 3 4 5 6 7 8 9 10 11 12 13 | library(spdep)
library(sphet)
data(boston)
boslw <- nb2listw(boston.soi)
Bos.Knn <- knearneigh(boston.utm, k = 5)
bos.nb <- knn2nb(Bos.Knn)
boslw2 <- nb2listw(bos.nb)
fm <- log(MEDV) ~ CRIM + ZN + INDUS + CHAS
fm2 <- log(MEDV) ~ CRIM + ZN + INDUS + RM + AGE
test <- kpjtest(fm, fm2, data = boston.c, listw0 = boslw, listw1 = boslw2, model = "lag")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.