spat.corr.diagnostic {PrevMap} | R Documentation |
Diagnostics for residual spatial correlation
Description
This function performs two variogram-based tests for residual spatial correlation in real-valued and count (Binomial and Poisson) data.
Usage
spat.corr.diagnostic(
formula,
units.m = NULL,
coords,
data,
likelihood,
ID.coords = NULL,
n.sim = 200,
nAGQ = 1,
uvec = NULL,
plot.results = TRUE,
lse.variogram = FALSE,
kappa = 0.5,
which.test = "both"
)
Arguments
formula |
an object of class |
units.m |
vector of binomial denominators, or offset if the Poisson model is used. |
coords |
an object of class |
data |
an object of class "data.frame" containing the data. |
likelihood |
a character that can be set to "Gaussian","Binomial" or "Poisson" |
ID.coords |
vector of ID values for the unique set of spatial coordinates obtained from |
n.sim |
number of simulations used to perform the selected test(s) for spatial correlation. |
nAGQ |
integer scalar (passed to |
uvec |
a vector with values used to define the variogram binning. If |
plot.results |
if |
lse.variogram |
if |
kappa |
smothness parameter of the Matern function for the Gaussian process to approximate. The deafault is |
which.test |
a character specifying which test for residual spatial correlation is to be performed: "variogram", "test statistic" or "both". The default is |
Details
The function first fits a generalized linear mixed model using the for an outcome which, conditionally on i.i.d. random effects
, are mutually independent
GLMs with linear predictor
where is a vector of covariates which are specified through
formula
. Finally, the are assumed to be zero-mean Gaussian variables with variance
Variogram-based graphical diagnostic
This graphical diagnostic is performed by setting which.test="both"
or which.test="variogram"
. The output are 95
(see below lower.lim
and upper.lim
) that are generated under the assumption of spatial indepdence through the following steps
1. Fit a generalized linear mixed model as indicated by the equation above.
2. Obtain the mode, say , of the
conditioned on the data
.
3. Compute the empirical variogram using
4. Permute the locations specified in coords
, n.sim
time while holding the fixed.
5. For each of the permuted data-sets compute the empirical variogram based on the .
6. From the n.sim
variograms obtained in the previous step, compute the 95
If the observed variogram (obs.variogram
below), based on the un-permuted , falls within the 95
residual spatial correlation; if, instead, that partly falls outside the 95
Test for spatial independence
This diagnostic test is performed if which.test="both"
or which.test="test statistic"
. Let denote the empirical variogram based on
for the distance bin
.
The test statistic used for testing residual spatial correlation is
where is the number of pairs of data-points falling within the distance bin
(
n.bins
below) and is the estimate of
.
To obtain the distribution of the test statistic under the null hypothesis of spatial independence, we use the simulated empirical variograms as obtained in step 5 of the iterative procedure described in "Variogram-based graphical diagnostic."
The p-value for the test of spatial independence is then computed by taking the proportion of simulated values for
under the null the hypothesis that are larger than the value of
based on the original (un-permuted)
Value
An object of class "PrevMap.diagnostic" which is a list containing the following components:
obs.variogram
: a vector of length length(uvec)-1
containing the values of the variogram for each of
the distance bins defined through uvec
.
distance.bins
: a vector of length length(uvec)-1
containing the average distance within each of the distance bins
defined through uvec
.
n.bins
: a vector of length length(uvec)-1
containing the number of pairs of data-points falling within each distance bin.
lower.lim
: (available only if which.test="both"
or which.test="variogram"
) a vector of length length(uvec)-1
containing the lower limits of the 95
generated under the assumption of absence of spatial correlation at each fo the distance bins defined through uvec
.
upper.lim
: (available only if which.test="both"
or which.test="variogram"
) a vector of length length(uvec)-1
containing the upper limits of the 95
generated under the assumption of absence of spatial correlation at each fo the distance bins defined through uvec
.
mode.rand.effects
: the predictive mode of the random effects from the fitted non-spatial generalized linear mixed model.
p.value
: (available only if which.test="both"
or which.test="test statistic"
) p-value of the test for residual spatial correlation.
lse.variogram
: (available only if lse.variogram=TRUE
) a vector of length length(uvec)-1
containing the values of the estimated Matern variogram via a weighted least square fit.