rwtest {splm}R Documentation

Randomization-based test of spatial dependence for panel models

Description

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

Usage

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"), ...)
                          

Arguments

x

an object of class formula, panelmodel, or pseries (depending on the respective interface) describing the model to be tested

data

a data.frame

w

a n x n matrix describing proximity between individuals, with w_ij = a where a is any number such that as.logical(a)==TRUE, if i,j are neighbours, 0 or any number b such that as.logical(b)==FALSE elsewhere. Only the lower triangluar part (without diagonal) of w after coercing by as.logical() is evaluated for neighbouring information (but w can be symmetric). See also Details and Examples.

index

an optional numerical index, in case data has to be formatted by plm.data

model

an optional character string indicating which type of model to estimate; if left to NULL, the original heterogeneous specification of Pesaran is used

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

  • "rho" for the average correlation coefficient,

  • "cd" for Pesaran's CD statistic, or

  • "sclm" for the scaled version of Breusch and Pagan's LM statistic,

alternative

the alternative hypothesis for the test, defaulting to (asymmetric) twosided,

...

further arguments to be passed on to plm, such as e.g. effect or random.method

Details

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.

Value

An object of class "htest".

Author(s)

Giovanni Millo

References

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.

Examples

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)

[Package splm version 1.6-5 Index]