Description Usage Arguments Details Value References See Also Examples
This function estimates the cross K-function between two sets, C and D, of (homogenous or nonhomogeneous) point processes in time. It is evaluated in a grid of distances r, and it can be optionally plotted. A test to assess the independence between the sets of processes, based on the cross K-function, is also implemented.
It calls the auxiliary functions NHKaux, NHKaux2, NHKaux3 and Kenv, not intended for users.
1 2 3 |
lambdaC |
A matrix of positive values. Each column is the intensity vector of one of the point processes in C. If there is only one process in C, it can be a vector or even a numeric value if the process is homogeneous. |
lambdaD |
A matrix of positive values. Each column is the intensity vector of one of the point process in D. If there is only one process in D, it can be a vector or even a numeric value if the process is homogeneous. |
T |
Numeric value. Length of the observed period. It only must be specified
if all the processes are homogeneous, that is if the number of rows in |
posC |
Numeric vector. Occurrence times of the points in all the point processes in C. |
typeC |
Numeric vector with the same length as |
posD |
Numeric vector. Occurrence times of the points in all the point processes in D. |
typeD |
Numeric vector with the same length as |
r |
Optional. Numeric vector. Grid values where the K-function must be evaluated. If it is NULL, a default vector is used; see Details. |
test |
Optional. Logical flag. If it is TRUE, a test of independence and a 95% envelope for the K-function are calculated. |
typeEst |
Optional. Two possible values: 1 or 2, which determines which one of the two available estimators of the function K_{ij} has to be used; see Details. |
nTrans |
Optional. Numeric value. Only used if |
conf |
Optional. Numeric value in (0,1). Confidence level of the envelope for the K-function. |
rTest |
Optional. Numeric value. Maximum value of r used to calculate the test statistc, see Details. |
typePlot |
Optional. Character string. If it is "Kfun" or "Kest" a plot of the values \hat K_{xy}(r) or \hat K_{xy}(r)/2r is shown. With any other value, no plot is carried out. |
tit |
Optional. Title to be used in the plot of the K-function. |
cores |
Optional. Number of cores of the computer to be used in the calculations. |
fixed.seed |
An integer or NULL. If it is an integer, that is the value used to set the seed in random generation processes. It it is NULL, a random seed is used. |
... |
Further arguments to be passed to the function |
The information about the processes is provided by arguments posC
, the vector of all the occurrence times
in the processes in C, and typeC
, the vector of the code of the point process in set C
where each point in posC
has occurred; the second set D is characterized analogously by
typeD
and posD
.
This function estimates the cross K function between two sets, C and D, of (homogenous or nonhomogeneous) point processes. Two different estimators are available, see Cebrian et al (2020) for details. The cross K-function measures the dependence between two point processes (or two sets of point processes) and counts the expected number of points in any of the processes in D, within a given distance of a point in any of the processes in C, adjusted for time varying intensity in the case of nonhomogenous processes. The cross K-function of independent Poisson processes is the length of the considered intervals, K_{CD}(r)=2r. Then, values K_{CD}(r)/2r>1 indicate attraction between the processes, while values lower than 1 indicate repulsion.
If argument r
is NULL, the following r-grid is used to evaluate the function
r1<-max(20, floor(T/20))
r<-seq(1,r1,by=2)
if (length(r)>200) r<-seq(1,r1,length.out=200)
Testing independence:
In order to test the independence hypothesis using this function, a test based on a Lotwick-Silverman approach, see Lotwick and Silverman (1982), is implemented. This test provides a nonparametric way to test independence given the marginal intensities of the processes. Using the Lotwick-Silverman approach, not only the p-value of the test but also an envelope for the K(r) values is calculated. The test statistic is based on the mean of values K(r)/(2r) evaluated in a given grid of r values.
In point processes, dependence often appears between close observations, and with high r values it is more difficult that the
K-function is able to discriminate between dependent and independent processes.
By this reason, the argument rTest
allows us to fix a maximum value of r
so that only K(r) estimations for r<rTest will be used to
calculate the test statistic. The value rTest
is drawn in the plot of the K-function
as a vertical grey line.
A list with elements:
r |
Vector of values r where the cross K-function is estimated. |
NHKr |
Estimated values of K_{ij}(r). |
KenvL |
Lower bounds of the envelope ofK_{ij}(r). |
KenvU |
Upper bounds of the envelope of K_{ij}(r). |
KStatOb |
Observed value of the test statistic. |
KStatTr |
Sample of the values of the test statistic obtained by random translations. |
pv |
P-value of the test. |
T |
Length of the observed period of the processes. |
Cebrian, A.C., Abaurrea, J. and Asin, J. (2020). Testing independence between two point processes in time. Journal of Simulation and Computational Statistics.
Lotwick, H.W. and Silverman, B.W. (1982). Methods for analysing Spatial processes of several types of points. J.R. Statist. Soc. B, 44(3), pp. 406-13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | set.seed(122)
lambda1<-runif(100, 0.05, 0.1)
set.seed(121)
lambda2<-runif(100, 0.01, 0.2)
pos1<-simNHPc(lambda=lambda1, fixed.seed=123)$posNH
pos2<-simNHPc(lambda=lambda2, fixed.seed=123)$posNH
aux<-NHK(lambdaC=lambda1, lambdaD=lambda2, posC=pos1, posD=pos2, typePlot='Kest',
nTrans=200, cores=1, typeEst=2, fixed.seed=120)
aux$pv
#Sets with two processes
#pos3<-simNHPc(lambda=lambda1, fixed.seed=321)$posNH
#pos4<-simNHPc(lambda=lambda2, fixed.seed=321)$posNH
#aux<-NHK(lambdaC=cbind(lambda1,lambda2), lambdaD=cbind(lambda1,lambda2), posC=c(pos1,pos2),
# typeC=c(rep(1, length(pos1)), rep(2, length(pos2))), posD=c(pos3, pos4),
# typeD=c(rep(1, length(pos3)), rep(2, length(pos4))), typeplot='Kest', fixed.seed=120)
#aux$pv
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.