[R-sig-Geo] spatstat kstest

Rolf Turner r.turner at auckland.ac.nz
Sun Feb 10 09:34:05 CET 2013


Sorry to be so slow to respond, but I am having a great deal of
difficulty in understanding what you are asking.

To attempt to answer your questions, at least partially, the "projections"
onto the axes of the point pattern being analysed are completely
irrelevant.  Investigating these projections does not arise in any way
when invoking kstest().   The test is *NOT* a test about these projections.

The function kstest() tests the *null* hypothesis that the observed pattern
was generated by CSR (i.e. by a constant intensity Poisson process).   The
alternative hypothesis is in effect that the intensity is dependent upon the
specified covariate.

The test is effected by comparing the empirical distribution of the values
of the covariate at the points of the pattern with the distribution that 
these
values would have under the null hypothesis, i.e. a uniform distribution.
If the first argument to kstest() is the pattern under consideration then
the "raw" values of the covariate are used.  If the first argument is a 
*model*
fitted to the pattern, then (as the online help says):
> The values of the covariate at all locations in the observation window 
> are evaluated,
> weighted according to the point process intensity of the fitted model, 
> and compiled
> into a cumulative distribution function F using ewcdf. 

In the latter case the function is testing the null hypothesis that the 
model fits adequately
versus there being a dependence upon the specified covariate which is 
not accounted
for by the model.

To return to the simpler setting where the first argument is the pattern 
then,
if the specified covariate is the x-coordinate of the points, the empirical
distribution of these x-coordinates is compared with the uniform 
distribution.
However the test is not "about" these x-coordinates.  These coordinates are
simply used as a means to detect whether the intensity is constant as 
opposed
to varying with x.

The Cartesian coordinates are only one pair of choices of specified 
covariate
upon which the intensity of the underlying process might depend. 
Strictly speaking
the choice of "specified covariate" should be made a priori --- before 
the data are
collected or inspected --- and should be made on the basis of sound 
scientific
conjectures about the nature of the underlying process.  This rule is of 
course
breached more often than it is observed.

To gain some insight into what the test is doing you should try 
experimenting with
simulated data.  I.e. simulate a pattern with dependence upon 
covariates, fit correct
and incorrect models to the pattern, and apply the kstest() function to 
both the
correct and incorrect models, with various choices of covariate.

     cheers,

         Rolf Turner


On 02/08/2013 04:00 PM, Hiroshi Saito wrote:
> Dear Rolf,
>
> Unfortunately, the data I have is under nondisclosure agreement.
> Therefore, I hesitate to offer.
>
> Let X={(x1,y1),(x2,y2),..} be the data set, and X_x={x1,x2,...} be its
> projection to the x-axis.
> Try, for example,
> fit <- ppm(X, ~x+y+I(x^2)+I(y^2), Poisson())
> (that is, the inhomogeneous Poisson process with the intensity
> \lambda(x,y)=exp(a+bx+cy+dx^2+ey^2))
> and test
> kstest(fit, covariate="x")
>
> In my understanding, this is the KS-test whether X_x and the
> inhomogeneous Poisson process with the intensity \lambda(x)=\int
> \lambda(x,y)dy.
> Am I wrong ?
>
> What I would like to say is that kstest is not a function of the test of
> the agreement between the model defined over (x,y) and the data set on
> the plane, but the function of the test of the agreement between the
> projected model and the projected model on a one-dimensional space.
> Am I wrong?
>
> Even so, you may have a good way to use kstest to test the two
> dimensional data by, for example, appropriately setting the covariate in
> kstest.
> If so, please give me some pieces of advice.
>
> Regards,
> Hiroshi Saito
>
> On Fri, 08 Feb 2013 13:51:55 +1300
> Rolf Turner <r.turner at auckland.ac.nz> wrote:
>
>> Can you please give a *reproducible* example (including code and data,
>> possibly provided using dput()) illustrating just exactly what is the
>> problem
>> that you are trying to solve?
>>
>>       cheers,
>>
>>           Rolf Turner
>>
>> On 02/08/2013 01:48 PM, Hiroshi Saito wrote:
>>> Dear sir,
>>>
>>> I am analyzing a spatial point data set.
>>> I would like to test how fit the model fitted by ppm is.
>>> For this objective, I used kstest.
>>> Unfortunately, however, I am not sure that the test actually tests the
>>> fit of the model for the data set on the two dimensional space.
>>> For example, if I set the covariate = x, it means (in my understanding)
>>> that the projection of the data set to the x-axis is tested.
>>> Is it possible to test the fit by appropriately setting the covariate?
>>>
>>> Please give me some pieces of advice how I test the fit.
>>> I need to test the method for the model including inhomogeneous Poisson
>>> model.
>>> If there is no appropriate method, I would like to develop.



More information about the R-sig-Geo mailing list