Title: | Nonparametric Tests in Spatial Statistics |
---|---|
Description: | Nonparametric test of independence between a pair of spatial objects (random fields, point processes) based on random shifts with torus or variance correction. See Mrkvička et al. (2021) <doi:10.1016/j.spasta.2020.100430>, Dvořák et al. (2022) <doi:10.1111/insr.12503>, Dvořák and Mrkvička (2022) <arxiv:2210.05424>. |
Authors: | Jiří Dvořák [aut, cre] , Tomáš Mrkvička [ctb] |
Maintainer: | Jiří Dvořák <[email protected]> |
License: | GPL-3 |
Version: | 0.1.2 |
Built: | 2024-11-10 04:29:41 UTC |
Source: | https://github.com/jiri-dvorak/ntss |
Nonparametric test of independence between a pair of random fields based on random shifts. Either the torus correction or the variance correction can be used, see Mrkvička et al. (2021). The variance correction is recommended for random fields with nontrivial autocorrelations.
CC.test( covariateA, covariateB, test.points, N.shifts = 999, radius, correction, type = "Kendall", verbose = FALSE )
CC.test( covariateA, covariateB, test.points, N.shifts = 999, radius, correction, type = "Kendall", verbose = FALSE )
covariateA |
first random field (object of class |
covariateB |
second random field (object of class |
test.points |
point pattern providing the set of sampling points (object of class |
N.shifts |
integer, how many random shifts should be performed in the random shift test |
radius |
positive real number determining the radius of the disk on which the shift vectors are uniformly distributed |
correction |
which correction should be applied in the random shift test (possible choices are "torus" and "variance") |
type |
which test statistic should be used (possible choices are "Kendall", "Pearson" and "covariance") |
verbose |
logical value indicating whether auxiliary information should be printed and auxiliary figures plotted during the computation |
The test statistic can be either the sample covariance or the sample Kendall's or
Pearson's correlation coefficient. The choice of the test statistic is given
by the argument type
.
The torus correction can be applied for rectangular windows. On the other hand,
the variance correction is applicable both for rectangular and for irregular windows.
The choice of the correction is given
by the argument correction
. Based on the simulation studies in Mrkvička et al. (2021),
the variance correction is recommended for random fields with nontrivial autocorrelations.
The two realizations of the random fields (defined on the same domain) to be tested
should be supplied in the covariateA, covariateB
arguments
as objects of the class im
as used in the spatstat
package.
The pattern of sampling points in which the test statistic is evaluated
is given in the argument test.points
as an object of the class ppp
.
The shift vectors are generated from the
uniform distribution on the disk with radius given by the argument radius
and centered in the origin. The argument verbose
determines if
auxiliary information and plots should be provided.
The p-value of the random shift test of independence between a pair of random fields.
T. Mrkvička, J. Dvořák, J.A. González, J. Mateu (2021): Revisiting the random shift approach for testing in spatial statistics. Spatial Statistics 42, 100430.
library(spatstat) set.seed(123) elevation <- bei.extra$elev slope <- bei.extra$grad plot(elevation) plot(slope) test.points <- runifpoint(100, win=bei$window) out1 <- CC.test(covariateA=elevation, covariateB=slope, test.points=test.points, N.shifts=999, radius=250, type="Kendall", correction="torus", verbose=TRUE) out1 out2 <- CC.test(covariateA=elevation, covariateB=slope, test.points=test.points, N.shifts=999, radius=250, type="Kendall", correction="variance", verbose=TRUE) out2
library(spatstat) set.seed(123) elevation <- bei.extra$elev slope <- bei.extra$grad plot(elevation) plot(slope) test.points <- runifpoint(100, win=bei$window) out1 <- CC.test(covariateA=elevation, covariateB=slope, test.points=test.points, N.shifts=999, radius=250, type="Kendall", correction="torus", verbose=TRUE) out1 out2 <- CC.test(covariateA=elevation, covariateB=slope, test.points=test.points, N.shifts=999, radius=250, type="Kendall", correction="variance", verbose=TRUE) out2
Nonparametric test of independence between a point process and a random field (covariate of interest), taking into account the possible effect of nuisance covariates, see Dvořák and Mrkvička (2022). The test is based on random shifts. Either the torus correction or the variance correction can be used, see Mrkvička et al. (2021).
CWR.test( X, covariate.interest, covariates.nuisance, N.shifts = 999, radius, correction, type = "raw", nonparametric = TRUE, verbose = FALSE, bw.factor.rhonhat = 1 )
CWR.test( X, covariate.interest, covariates.nuisance, N.shifts = 999, radius, correction, type = "raw", nonparametric = TRUE, verbose = FALSE, bw.factor.rhonhat = 1 )
X |
point pattern dataset (object of class |
covariate.interest |
random field (object of class |
covariates.nuisance |
list of covariates (objects of class |
N.shifts |
integer, how many random shifts should be performed in the random shift test |
radius |
positive real number determining the radius of the disk on which the shift vectors are uniformly distributed |
correction |
which correction should be applied in the random shift test (possible choices are "torus" and "variance") |
type |
which type of residuals should be used when computing the test statistic (possible choices are "raw", "Pearson" and "inverse") |
nonparametric |
logical value indicating whether nonparametric residuals should be used when computing the test statistic |
verbose |
logical value indicating whether auxiliary information should be printed and auxiliary figures plotted during the computation |
bw.factor.rhonhat |
multiplicative factor used when determining the bandwidth in the nonparametric estimation of the intensity function depending on the nuisance covariates (defaults to 1) |
The test statistic is the covariate-weighted residual measure of the observation window, see the paper Dvořák and Mrkvička (2022). If no nuisance covariates are given, the null model assumes a constant intensity function of the point process. If one or more nuisance covariates are provided, the null model assumes an intensity function depending on the nuisance covariates (but not on the covariate of interest) and the residuals are constructed using this intensity function.
The residuals can be constructed in a nonparametric way (see Baddeley et al. (2012))
or in a parametric way (assuming a log-linear form of the intensity function
and using the ppm
function from the spatstat
package,
see Baddeley et al. (2015)). This choice is given by the argument nonparametric
.
The nonparametric residuals are recommended if the log-linear form of the intensity function
is not clearly justified.
Also, different types of residuals can be considered (raw, Pearson or inverse,
see Baddeley et al. (2015)). This choice is given by the argument type
.
The torus correction can be applied for rectangular windows. On the other hand,
the variance correction is applicable both for rectangular and for irregular windows.
The choice of the correction is given by the argument correction
.
Based on the simulation studies in Dvořák and Mrkvička (2022),
the torus and variance corrections perform almost equally well for the CWR test.
Hence, the torus correction is recommended for its smaller computational cost.
The observed point pattern should be supplied using the argument X
.
The realization of the covariate of interest should be supplied using
the argument covariate.interest
. The set of nuisance covariates should
be supplied as a list using the argument covariates.nuisance
. This list
can be empty if no nuisance covariates are considered.
The shift vectors are generated from the
uniform distribution on the disk with radius given by the argument radius
and centered in the origin. The argument verbose
determines if
auxiliary information and plots should be provided.
In case the observation window accompanying the point pattern is irregular,
it must be specified in the form of a binary mask due to the specific implementation of the test.
For details on binary masks see the help for the spatstat
function owin
.
The p-value of the random shift test of independence between a point process and a covariate, taking into account possible effects of nuisance covariates.
J. Dvořák, T. Mrkvička (2022): Nonparametric testing of the covariate significance for spatial point patterns under the presence of nuisance covariates. https://arxiv.org/abs/2210.05424
T. Mrkvička, J. Dvořák, J.A. González, J. Mateu (2021): Revisiting the random shift approach for testing in spatial statistics. Spatial Statistics 42, 100430.
A. Baddeley, E. Rubak, R. Turner (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman & Hall Interdisciplinary Statistics Series. CRC Press, Boca Raton, Florida.
A. Baddeley, Y.-M. Chang, Y. Song, R. Turner (2012) Nonparametric estimation of the dependence of a point process on spatial covariates. Statistics and Its Interface 5(2), 221?236.
library(spatstat) library(ks) # the point pattern X <- bei plot(X) # two covariates are available elevation <- bei.extra$elev slope <- bei.extra$grad plot(elevation) plot(slope) # test with no nuisance covariates, with only 99 shifts to speed up the computation out1 <- CWR.test(X, covariate.interest=elevation, covariates.nuisance=NULL, N.shifts = 99, verbose=TRUE, correction="torus", radius=250) out1 # test with one nuisance covariate, with only 99 shifts to speed up the computation out2 <- CWR.test(X, covariate.interest=elevation, covariates.nuisance=list(slope=slope), N.shifts = 99, verbose=TRUE, correction="torus", radius=250) out2
library(spatstat) library(ks) # the point pattern X <- bei plot(X) # two covariates are available elevation <- bei.extra$elev slope <- bei.extra$grad plot(elevation) plot(slope) # test with no nuisance covariates, with only 99 shifts to speed up the computation out1 <- CWR.test(X, covariate.interest=elevation, covariates.nuisance=NULL, N.shifts = 99, verbose=TRUE, correction="torus", radius=250) out1 # test with one nuisance covariate, with only 99 shifts to speed up the computation out2 <- CWR.test(X, covariate.interest=elevation, covariates.nuisance=list(slope=slope), N.shifts = 99, verbose=TRUE, correction="torus", radius=250) out2
Nonparametric test of independence between a point process and a random field (covariate) based on random shifts, see Dvořák et al. (2022). Either the torus correction or the variance correction can be used, see Mrkvička et al. (2021).
PC.test(X, covariate, N.shifts = 999, radius, correction, verbose = FALSE)
PC.test(X, covariate, N.shifts = 999, radius, correction, verbose = FALSE)
X |
point pattern dataset (object of class |
covariate |
random field (object of class |
N.shifts |
integer, how many random shifts should be performed in the random shift test |
radius |
positive real number determining the radius of the disk on which the shift vectors are uniformly distributed |
correction |
which correction should be applied in the random shift test (possible choices are "torus" and "variance") |
verbose |
logical value indicating whether auxiliary information should be printed and auxiliary figures plotted during the computation |
The test statistic is the mean covariate value observed at the points of the process, see the paper Dvořák et al. (2022).
The torus correction can be applied for rectangular windows. On the other hand,
the variance correction is applicable both for rectangular and for irregular windows.
The choice of the correction is given by the argument correction
.
Based on the simulation studies in Dvořák et al. (2022),
the variance correction is recommended since it does not exhibit the liberality of the torus correction.
The observed point pattern should be supplied using the
argument X
, the realization of the covariate should be supplied using
the argument covariate
.
The shift vectors are generated from the
uniform distribution on the disk with radius given by the argument radius
and centered in the origin. The argument verbose
determines if
auxiliary information and plots should be provided.
The p-value of the random shift test of independence between a point process and a covariate.
J. Dvořák, T. Mrkvička, J. Mateu, J.A. González (2022): Nonparametric testing of the dependence structure among points-marks-covariates in spatial point patterns. International Statistical Review 90(3), 592-621.
T. Mrkvička, J. Dvořák, J.A. González, J. Mateu (2021): Revisiting the random shift approach for testing in spatial statistics. Spatial Statistics 42, 100430.
library(spatstat) set.seed(123) elevation <- bei.extra$elev plot(elevation) out1 <- PC.test(X=bei, covariate=elevation, radius=250, correction="torus", verbose=TRUE) out1 out2 <- PC.test(X=bei, covariate=elevation, radius=250, correction="variance", verbose=TRUE) out2
library(spatstat) set.seed(123) elevation <- bei.extra$elev plot(elevation) out1 <- PC.test(X=bei, covariate=elevation, radius=250, correction="torus", verbose=TRUE) out1 out2 <- PC.test(X=bei, covariate=elevation, radius=250, correction="variance", verbose=TRUE) out2
Test of independence between marks and points of a stationary marked point process based on the comparison of the mark K-function and the K-function of the underlying point process, see Guan (2006).
PM.test(X, R, R.variogram)
PM.test(X, R, R.variogram)
X |
marked point pattern dataset (object of class |
R |
positive real number determining the domain for the (marked) K-function used for computing the test statistic |
R.variogram |
positive real number determining the domain for variogram estimation |
The test was proposed in Guan (2006) and used in Dvořák et al. (2022) as one of the tools to determine the dependence structure between points, marks and a covariate in a marked point process setting. The marked point process is assumed to be stationary here.
The observed marked point pattern should be supplied using the argument X
.
The upper limit of the domain for the (marked) K-function used for constructing the test statistic
is given by the argument R
. Furthermore, the variance used for constructing
the test statistic is determined using a fitted covariance model for the mark field.
In the given implementation, the exponential model for the covariance is assumed.
The model parameters are estimated by fitting the corresponding parametric model
to the empirical variogram by the least-squares approach, with the upper bound on
the variogram argument given by R.variogram
.
The p-value of the test of independence between marks and points of a stationary marked point process.
Y. Guan (2006): Tests for independence between marks and points of a marked point Process. Biometrics 62, 126-134.
J. Dvořák, T. Mrkvička, J. Mateu, J.A. González (2022): Nonparametric testing of the dependence structure among points-marks-covariates in spatial point patterns. International Statistical Review 90(3), 592-621.
library(spatstat) library(geoR) set.seed(123) X <- rpoispp(100) X <- X %mark% runif(n=X$n) out <- PM.test(X, R=0.1, R.variog=1) out
library(spatstat) library(geoR) set.seed(123) X <- rpoispp(100) X <- X %mark% runif(n=X$n) out <- PM.test(X, R=0.1, R.variog=1) out
Nonparametric test of independence between marks of a point process and a random field (covariate) based on random shifts, see Dvořák et al. (2022). Either the torus correction or the variance correction can be used, see Mrkvička et al. (2021).
PMC.test( X, covariate, N.shifts = 999, radius, correction, type = "Kendall", verbose = FALSE )
PMC.test( X, covariate, N.shifts = 999, radius, correction, type = "Kendall", verbose = FALSE )
X |
marked point pattern dataset (object of class |
covariate |
random field (object of class |
N.shifts |
integer, how many random shifts should be performed in the random shift test |
radius |
positive real number determining the radius of the disk on which the shift vectors are uniformly distributed |
correction |
which correction should be applied in the random shift test (possible choices are "torus" and "variance") |
type |
... which test statistic should be used (possible choices are "Kendall", "Pearson" and "covariance") |
verbose |
logical value indicating whether auxiliary information should be printed and auxiliary figures plotted during the computation |
The test statistic can be either the sample covariance or the sample Kendall's or Pearson's correlation coefficient, computed from the vector of marks and the vector of covariate values observed at the points of the process, see the paper Dvořák et al. (2022). These test statistics make the test sensitive to violation of independence between the marks and the covariate. On the other hand, the test can also be viewed as a test of independence between a marked point process and a covariate.
The torus correction can be applied for rectangular windows. On the other hand,
the variance correction is applicable both for rectangular and for irregular windows.
The choice of the correction is given by the argument correction
.
Based on the simulation studies in Dvořák et al. (2022),
the variance correction is recommended since it does not exhibit the liberality of the torus correction.
The choice of the test statistic is given
by the argument type
. The observed marked point pattern should be supplied using the
argument X
, the realization of the covariate should be supplied using
the argument covariate
.
The shift vectors are generated from the
uniform distribution on the disk with radius given by the argument radius
and centered in the origin. The argument verbose
determines if
auxiliary information and plots should be provided.
The p-value of the random shift test of independence between marks of a point process and a covariate.
J. Dvořák, T. Mrkvička, J. Mateu, J.A. González (2022): Nonparametric testing of the dependence structure among points-marks-covariates in spatial point patterns. International Statistical Review 90(3), 592-621.
T. Mrkvička, J. Dvořák, J.A. González, J. Mateu (2021): Revisiting the random shift approach for testing in spatial statistics. Spatial Statistics 42, 100430.
library(spatstat) set.seed(123) elevation <- bei.extra$elev slope <- bei.extra$grad plot(elevation) plot(slope) # use only part of the point pattern for this example Xun <- rthin(bei,0.05) # use elevation values as marks X <- Xun %mark% elevation[Xun] # use terrain gradient as covariate covariate <- slope out1 <- PMC.test(X=X, covariate=covariate, radius=250, correction="torus", type="Kendall", verbose=TRUE) out1 out2 <- PMC.test(X=X, covariate=covariate, radius=250, correction="variance", type="Kendall", verbose=TRUE) out2
library(spatstat) set.seed(123) elevation <- bei.extra$elev slope <- bei.extra$grad plot(elevation) plot(slope) # use only part of the point pattern for this example Xun <- rthin(bei,0.05) # use elevation values as marks X <- Xun %mark% elevation[Xun] # use terrain gradient as covariate covariate <- slope out1 <- PMC.test(X=X, covariate=covariate, radius=250, correction="torus", type="Kendall", verbose=TRUE) out1 out2 <- PMC.test(X=X, covariate=covariate, radius=250, correction="variance", type="Kendall", verbose=TRUE) out2
Nonparametric test of independence between a pair of point processes based on random shifts. Either the torus correction or the variance correction can be used (note that the variance correction is not yet implemented in this package but the corresponding source codes can be obtained from the authors upon request).
PP.test( X, Y, N.shifts = 999, radius, correction, statistic, rmax.K = NULL, verbose = FALSE )
PP.test( X, Y, N.shifts = 999, radius, correction, statistic, rmax.K = NULL, verbose = FALSE )
X |
first point pattern dataset (object of class |
Y |
second point pattern dataset (object of class |
N.shifts |
integer, how many random shifts should be performed in the random shift test |
radius |
positive real number determining the radius of the disk on which the shift vectors are uniformly distributed |
correction |
which correction should be applied in the random shift test (possible choices are "torus" and "variance") |
statistic |
which test statistic should be used (possible choices are "K12" and "ED12") |
rmax.K |
positive real number, for the cross K-function determines the maximum argument to be considered |
verbose |
logical value indicating whether auxiliary information should be printed and auxiliary figures plotted during the computation |
The test statistic is either the cross K-function K12 or the expectation of the cross nearest-neighbor distance ED12, see the paper Mrkvička et al. (2021). It is recommended to use the K12 statistic for regular and Poisson processes, while it is recommended to use ED12 for cluster processes due to the potential liberality of K12 in this case.
The two observed point patterns to be tested should be supplied using the
arguments X
and Y
. The shift vectors are generated from the
uniform distribution on the disk with radius given by the argument radius
and centered in the origin.
The test statistic is determined by the argument statistic
. For "K12", the test statistic
is functional, the stationary cross K-function. The range of arguments is from 0 to rmax.K
(there
is a sensible default). The outcome of the test is determined by the global envelope test in this case.
Alternatively, the statistic
can be set to "ED12", meaning that the test statistic is scalar,
the expectation of the cross nearest-neighbor distance. The outcome of the test is determined by the
classical univariate Monte Carlo test in this case.
The argument verbose
determines if auxiliary information and plots should be provided.
The p-value of the random shift test of independence between a pair of point processes.
T. Mrkvička, J. Dvořák, J.A. González, J. Mateu (2021): Revisiting the random shift approach for testing in spatial statistics. Spatial Statistics 42, 100430.
library(spatstat) library(GET) set.seed(123) X <- rpoispp(150) Y <- rpoispp(150) out1 <- PP.test(X=X, Y=Y, radius=0.5, statistic="K12", correction="torus", verbose=TRUE) out1 plot(out1$GET.outcome) out2 <- PP.test(X=X, Y=Y, radius=0.5, statistic="ED12", correction="torus", verbose=TRUE) out2
library(spatstat) library(GET) set.seed(123) X <- rpoispp(150) Y <- rpoispp(150) out1 <- PP.test(X=X, Y=Y, radius=0.5, statistic="K12", correction="torus", verbose=TRUE) out1 plot(out1$GET.outcome) out2 <- PP.test(X=X, Y=Y, radius=0.5, statistic="ED12", correction="torus", verbose=TRUE) out2
Correlation coefficient between a point process and a random field
(covariate of interest), taking into account the possible effect of nuisance covariates,
see Dvořák and Mrkvička (2022). The random shift test based on this test statistics
is given in the function tau.test
.
tau.est( X, covariate.interest, covariates.nuisance, bws, n.test.points = 1000, nonparametric = TRUE, verbose = FALSE, bw.factor.rhonhat = 1 )
tau.est( X, covariate.interest, covariates.nuisance, bws, n.test.points = 1000, nonparametric = TRUE, verbose = FALSE, bw.factor.rhonhat = 1 )
X |
point pattern dataset (object of class |
covariate.interest |
random field (object of class |
covariates.nuisance |
list of covariates (objects of class |
bws |
vector of positive real values from which the bandwidth is adaptively chosen if at least one nuisance covariate is present; if no nuisance covariates are present, the first value is used |
n.test.points |
the number of independent test points used in computing the test statistic value |
nonparametric |
logical value indicating whether nonparametric residuals should be used when computing the test statistic |
verbose |
logical value indicating whether auxiliary information should be printed and auxiliary figures plotted during the computation |
bw.factor.rhonhat |
multiplicative factor used when determining the bandwidth in the nonparametric estimation of the intensity function depending on the nuisance covariates (defaults to 1) |
This function computes the Kendall's correlation coefficient between the covariate of interest and the smoothed residual field, sampled at a given number of test points scattered independently in the observation window, see the paper Dvořák and Mrkvička (2022). If no nuisance covariates are given, a constant intensity function of the point process is assumed when constructing the residuals. If one or more nuisance covariates are provided, an intensity function depending on the nuisance covariates (but not on the covariate of interest) is assumed and the residuals are constructed using this intensity function.
For constructing the smoothed residual field an adaptive bandwidth selection
method can be used, see Dvořák and Mrkvička (2022). A vector of candidate
bandwidth values can be provided using the argument bws
.
The residuals can be constructed in a nonparametric way (see Baddeley et al. (2012))
or in a parametric way (using the ppm
function from the spatstat
package,
see Baddeley et al. (2015)). This choice is given by the argument nonparametric
.
The raw residuals are considered here.
The observed point pattern should be supplied using the argument X
.
The realization of the covariate of interest should be supplied using
the argument covariate.interest
. The set of nuisance covariates should
be supplied as a list using the argument covariates.nuisance
. This list
can be empty if no nuisance covariates are considered.
Value of the (partial) Kendall's correlation coefficient.
J. Dvořák, T. Mrkvička (2022): Nonparametric testing of the covariate significance for spatial point patterns under the presence of nuisance covariates. https://arxiv.org/abs/2210.05424
T. Mrkvička, J. Dvořák, J.A. González, J. Mateu (2021): Revisiting the random shift approach for testing in spatial statistics. Spatial Statistics 42, 100430.
A. Baddeley, E. Rubak, R. Turner (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman & Hall Interdisciplinary Statistics Series. CRC Press, Boca Raton, Florida.
A. Baddeley, Y.-M. Chang, Y. Song, R. Turner (2012) Nonparametric estimation of the dependence of a point process on spatial covariates. Statistics and Its Interface 5(2), 221?236.
library(spatstat) library(ks) # the point pattern X <- bei plot(X) # two covariates are available elevation <- bei.extra$elev slope <- bei.extra$grad plot(elevation) plot(slope) # candidate values for adaptive bandwidth selection bws <- seq(from=12.5, to=100, by=12.5) # no nuisance covariates out1 <- tau.est(X, covariate.interest=elevation, covariates.nuisance=NULL, bws=bws, verbose=TRUE) out1 # one nuisance covariate out2 <- tau.est(X, covariate.interest=elevation, covariates.nuisance=list(slope=slope), bws=bws, verbose=TRUE) out2
library(spatstat) library(ks) # the point pattern X <- bei plot(X) # two covariates are available elevation <- bei.extra$elev slope <- bei.extra$grad plot(elevation) plot(slope) # candidate values for adaptive bandwidth selection bws <- seq(from=12.5, to=100, by=12.5) # no nuisance covariates out1 <- tau.est(X, covariate.interest=elevation, covariates.nuisance=NULL, bws=bws, verbose=TRUE) out1 # one nuisance covariate out2 <- tau.est(X, covariate.interest=elevation, covariates.nuisance=list(slope=slope), bws=bws, verbose=TRUE) out2
Nonparametric test of independence between a point process and a random field
(covariate of interest), taking into account the possible effect of nuisance covariates,
see Dvořák and Mrkvička (2022).
The test is based on random shifts. Either the torus correction or the variance
correction can be used, see Mrkvička et al. (2021).
This test has lower power than the test based on the covariate-weighted residuals
(see the function CWR.test
), but it is still included for the sake of completeness.
Also, the test statistic of tau.test
can be used to quantify
the partial correlation between the point process and the covariate of interest, taking into
account the possible effect of nuisance covariates, see also the function tau.est
.
tau.test( X, covariate.interest, covariates.nuisance, N.shifts = 999, radius, correction, bws, n.test.points = 1000, nonparametric = TRUE, verbose = FALSE, bw.factor.rhonhat = 1 )
tau.test( X, covariate.interest, covariates.nuisance, N.shifts = 999, radius, correction, bws, n.test.points = 1000, nonparametric = TRUE, verbose = FALSE, bw.factor.rhonhat = 1 )
X |
point pattern dataset (object of class |
covariate.interest |
random field (object of class |
covariates.nuisance |
list of covariates (objects of class |
N.shifts |
integer, how many random shifts should be performed in the random shift test |
radius |
positive real number determining the radius of the disk on which the shift vectors are uniformly distributed |
correction |
which correction should be applied in the random shift test (possible choices are "torus" and "variance") |
bws |
vector of positive real values from which the bandwidth is adaptively chosen if at least one nuisance covariate is present; if no nuisance covariates are present, the first value is used |
n.test.points |
the number of independent test points used in computing the test statistic value |
nonparametric |
logical value indicating whether nonparametric residuals should be used when computing the test statistic |
verbose |
logical value indicating whether auxiliary information should be printed and auxiliary figures plotted during the computation |
bw.factor.rhonhat |
multiplicative factor used when determining the bandwidth in the nonparametric estimation of the intensity function depending on the nuisance covariates (defaults to 1) |
The test statistic is the Kendall's correlation coefficient between the covariate of interest and the smoothed residual field, sampled at a given number of test points scattered independently in the observation window, see the paper Dvořák and Mrkvička (2022). If no nuisance covariates are given, the null model assumes a constant intensity function of the point process. If one or more nuisance covariates are provided, the null model assumes an intensity function depending on the nuisance covariates (but not on the covariate of interest) and the residuals are constructed using this intensity function.
For constructing the smoothed residual field an adaptive bandwidth selection
method can be used, see Dvořák and Mrkvička (2022). A vector of candidate
bandwidth values can be provided using the argument bws
.
The residuals can be constructed in a nonparametric way (see Baddeley et al. (2012))
or in a parametric way (using the ppm
function from the spatstat
package,
see Baddeley et al. (2015)). This choice is given by the argument nonparametric
.
The raw residuals are considered here.
The torus correction can be applied for rectangular windows. On the other hand,
the variance correction is applicable both for rectangular and for irregular windows.
The choice of the correction is given by the argument correction
.
Based on the simulation studies in Dvořák and Mrkvička (2022),
the variance correction is recommended since it does not exhibit the liberality of the torus correction.
The observed point pattern should be supplied using the argument X
.
The realization of the covariate of interest should be supplied using
the argument covariate.interest
. The set of nuisance covariates should
be supplied as a list using the argument covariates.nuisance
. This list
can be empty if no nuisance covariates are considered.
The shift vectors are generated from the
uniform distribution on the disk with radius given by the argument radius
and centered in the origin. The argument verbose
determines if
auxiliary information and plots should be provided.
In case the observation window accompanying the point pattern is irregular,
it must be specified in the form of a binary mask due to the specific implementation of the test.
For details on binary masks see the help for the spatstat
function owin
.
The p-value of the random shift test of independence between a point process and a covariate, taking into account possible effects of nuisance covariates.
J. Dvořák, T. Mrkvička (2022): Nonparametric testing of the covariate significance for spatial point patterns under the presence of nuisance covariates. https://arxiv.org/abs/2210.05424
T. Mrkvička, J. Dvořák, J.A. González, J. Mateu (2021): Revisiting the random shift approach for testing in spatial statistics. Spatial Statistics 42, 100430.
A. Baddeley, E. Rubak, R. Turner (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman & Hall Interdisciplinary Statistics Series. CRC Press, Boca Raton, Florida.
A. Baddeley, Y.-M. Chang, Y. Song, R. Turner (2012) Nonparametric estimation of the dependence of a point process on spatial covariates. Statistics and Its Interface 5(2), 221?236.
library(spatstat) library(ks) # the point pattern X <- bei plot(X) # two covariates are available elevation <- bei.extra$elev slope <- bei.extra$grad plot(elevation) plot(slope) # candidate values for adaptive bandwidth selection bws <- seq(from=12.5, to=100, by=12.5) # test with no nuisance covariates, with only 99 shifts to speed up the computation out1 <- tau.test(X, covariate.interest=elevation, covariates.nuisance=NULL, bws=bws, N.shifts = 99, verbose=TRUE, correction="torus", radius=250) out1 # test with one nuisance covariate, with only 99 shifts to speed up the computation out2 <- tau.test(X, covariate.interest=elevation, covariates.nuisance=list(slope=slope), bws=bws, N.shifts = 99, verbose=TRUE, correction="torus", radius=250) out2
library(spatstat) library(ks) # the point pattern X <- bei plot(X) # two covariates are available elevation <- bei.extra$elev slope <- bei.extra$grad plot(elevation) plot(slope) # candidate values for adaptive bandwidth selection bws <- seq(from=12.5, to=100, by=12.5) # test with no nuisance covariates, with only 99 shifts to speed up the computation out1 <- tau.test(X, covariate.interest=elevation, covariates.nuisance=NULL, bws=bws, N.shifts = 99, verbose=TRUE, correction="torus", radius=250) out1 # test with one nuisance covariate, with only 99 shifts to speed up the computation out2 <- tau.test(X, covariate.interest=elevation, covariates.nuisance=list(slope=slope), bws=bws, N.shifts = 99, verbose=TRUE, correction="torus", radius=250) out2