View source: R/GeoTestIndependence.R
| GeoTestIndependence | R Documentation |
Performs a parametric bootstrap likelihood-ratio test of spatial independence against a spatially dependent random-field model. Under the null hypothesis, the observations at distinct sites are fitted using the marginal independence likelihood. Under the alternative hypothesis, a full spatial likelihood is fitted with the nugget proportion estimated below its independence boundary. The bootstrap is required because the null hypothesis corresponds to a boundary point and the spatial correlation parameters are not identified under the null.
GeoTestIndependence(data, coordx,
start, fixed = NULL,
corrmodel = "Matern",
model = "Gaussian",
optimizer = "bobyqa",
optimizer_ind = "Nelder-Mead",
lower = NULL, upper = NULL,
X = NULL, n = 1,
distance = "Eucl", radius = 1,
anisopars = NULL,
est.aniso = c(FALSE, FALSE),
sparse = FALSE,
B = 1000,
parallel = TRUE,
ncores = NULL,
progress = TRUE,
seed = NULL)
data |
Numeric vector of observations. |
coordx |
Matrix or object coercible to a matrix containing the spatial
coordinates. The number of rows must equal |
start |
Non-empty named list containing the parameters to be estimated
under the spatial alternative. It must include, either directly or through
|
fixed |
Optional named list containing parameters kept fixed under the
spatial alternative. Parameters cannot occur in both |
corrmodel |
Correlation model used under the spatial alternative. The
default is |
model |
Marginal model for the observations. The default is
|
optimizer |
Optimization method passed to |
optimizer_ind |
Optimization method used for the marginal independence
fit under |
lower, upper |
Optional named lists of lower and upper bounds for the
parameters estimated under the spatial alternative. Names must refer only to
parameters in |
X |
Optional design matrix for the mean or marginal regression model.
Its number of rows must equal |
n |
Model-specific parameter passed to |
distance |
Distance metric passed to |
radius |
Positive radius used for spherical or geodesic distances. The
default is |
anisopars |
Optional list of anisotropy parameters passed to the spatial fit under the alternative. |
est.aniso |
Logical vector of length two indicating whether the
anisotropy angle and ratio are estimated under the alternative. The default is
|
sparse |
Logical value passed to the full-likelihood spatial fit. The
default is |
B |
Number of parametric bootstrap replications. The default is
|
parallel |
Logical value indicating whether the bootstrap fits should be evaluated in parallel when the required packages are available. |
ncores |
Number of worker processes. If |
progress |
Logical value indicating whether progress bars should be displayed through progressr. |
seed |
Optional finite numeric seed. When supplied, the previous global random-number-generator state is restored when the function exits. |
The test compares
H_0: \text{absence of spatial dependence}
with
H_1: \text{a spatially dependent random-field model}.
Under H_0, the function fits
GeoFit(..., likelihood = "Marginal", type = "Independence"). Only
marginal and regression parameters are estimated. Spatial correlation
parameters and the nugget proportion are absent from the null fit because they
are not identified under independence.
The null fit uses optimizer_ind; if necessary, a
"Nelder-Mead" fallback is attempted. The optimizer associated with the
selected null fit is returned in optimizer_independence.
Under H_1, the function fits
GeoFit(..., likelihood = "Full", type = "Standard") using
corrmodel. The nugget parameter is estimated on
[0,1). Independence is represented by the boundary
\texttt{nugget}=1, where the spatial correlation contribution vanishes.
The upper optimization bound is internally set to a value immediately below
one because GeoFit requires nugget < 1.
The observed likelihood-ratio statistic is
\Lambda_{obs}=2\{\ell_1-\ell_0\},
where \ell_0 is the maximized independence log-likelihood and
\ell_1 is the maximized full spatial log-likelihood. If the unrestricted
spatial fit reaches the independence boundary, the statistic is set to zero
and the function returns pvalue = 1 without running the bootstrap.
The usual chi-squared likelihood-ratio approximation is not used because the
null value is on the boundary and the spatial correlation parameters are not
identified under H_0. Instead, the null distribution is approximated by
parametric bootstrap. The bootstrap p-value is
\widehat p =
\frac{1+\sum_{b=1}^{B_{valid}}
I(\Lambda_b^*\geq\Lambda_{obs})}
{B_{valid}+1}.
Bootstrap datasets are generated exactly independently at the observed sites.
Because GeoSim does not accept nugget = 1, the implementation
uses an auxiliary GenWend correlation model with compact support equal
to one half of the minimum inter-site distance. Consequently, all off-diagonal
correlations at the observed locations are exactly zero. This auxiliary model
is used only as a simulation device; the fitted null model remains the marginal
independence model.
The observed parameter estimates are used as starting values in the bootstrap
refits. If the first spatial fit fails to attain at least the independence
log-likelihood, adaptive fallback fits are attempted using alternative initial
values for nugget. When the best spatial fit is numerically equivalent
to the null fit, the bootstrap statistic is treated as a boundary value equal
to zero.
When parallel = TRUE, bootstrap fits are evaluated with
future.apply. Each simulated dataset is written temporarily to a separate
RDS file so that workers do not receive the complete simulation object. The
user's previous future plan, progressr handlers, and random-number-
generator state are restored on exit.
The current implementation is restricted to univariate models with a single
nugget proportion named nugget. It compares the independence likelihood
only with the full spatial likelihood. It does not directly compare the
independence likelihood with a pairwise composite likelihood, because the two
criteria are not on the same scale.
An invisible list with components:
lambda_obs |
Observed likelihood-ratio statistic. |
pvalue |
Parametric bootstrap p-value. |
nugget_hat |
Estimated nugget proportion under the spatial alternative. |
boundary_observed |
Logical value indicating whether the unrestricted spatial fit was classified as an independence-boundary solution. |
optimizer_independence |
Optimizer used by the selected independence fit
under |
optimizer_spatial |
Optimizer used for the full spatial fit under
|
seed |
Seed supplied by the user, or |
B_requested |
Requested number of bootstrap replications. |
bootstrap_successful |
Number of valid bootstrap replications. |
bootstrap_failed |
Number of failed bootstrap replications. |
bootstrap_success_rate |
Fraction of successful bootstrap replications.
This is |
fallback_observed |
Logical value indicating whether adaptive starting values were required for the observed spatial fit. |
fallback_bootstrap |
Number of bootstrap replications in which adaptive starting values were used for the spatial fit. |
boundary_bootstrap |
Number of valid bootstrap replications classified as independence-boundary solutions. |
simulation_support |
Compact-support value used by the auxiliary
|
B_rep |
Vector of valid bootstrap likelihood-ratio statistics. |
fit_H0 |
|
fit_H1 |
|
For Gaussian random fields, the null hypothesis is equivalent to mutual independence of the observations at distinct spatial locations. For non-Gaussian models, the interpretation as independence requires that zero latent spatial dependence imply independence in the corresponding observed random-field construction.
A small bootstrap p-value indicates evidence of spatial dependence. For
final analyses, a value such as B = 999 or larger is recommended.
Moreno Bevilacqua moreno.bevilacqua89@gmail.com https://sites.google.com/view/moreno-bevilacqua/home
GeoFit,
GeoSim,
GeoDistances,
GeoTestsupp_space,
GeoTestIsotropy
## Not run:
library(GeoModels)
set.seed(3)
N <- 300
coords <- cbind(runif(N), runif(N))
X <- cbind(1, runif(N))
param <- list(
mean = 0.2,
mean1 = -0.5,
sill = 1,
nugget = 0,
scale = 0.2 / 3,
smooth = 0.5
)
data <- GeoSim(
coordx = coords,
corrmodel = "Matern",
model = "Gaussian",
param = param,
X = X
)$data
start <- list(
mean = 0,
mean1 = 0,
sill = 1,
nugget = 0.1,
scale = 0.1
)
fixed <- list(smooth = 0.5)
lower <- list(
mean = -Inf,
mean1 = -Inf,
sill = 1e-6,
nugget = 0,
scale = 1e-6
)
upper <- list(
mean = Inf,
mean1 = Inf,
sill = Inf,
nugget = 1,
scale = 1
)
ans <- GeoTestIndependence(
data = data,
coordx = coords,
X = X,
start = start,
fixed = fixed,
corrmodel = "Matern",
model = "Gaussian",
optimizer = "bobyqa",
optimizer_ind = "Nelder-Mead",
lower = lower,
upper = upper,
B = 199,
parallel = TRUE,
seed = 123
)
ans$pvalue
ans$lambda_obs
ans$nugget_hat
ans$bootstrap_success_rate
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.