[R-sig-Geo] density from spatstat less than zero

Rolf Turner r.turner at auckland.ac.nz
Fri Oct 16 00:34:59 CEST 2015


See inline below.

On 15/10/15 06:35, Christopher W. Ryan wrote:
> Hello. I'm a longtime user of R and subscriber to R-help, but new to
> R-sig-geo.  I'm running R 3.1.3 and spatstat 1.41-1 on Windows XP.

If you upgrade to the most recent version of spatstat (in order to do 
which you will need to upgrade to R 3.2.2) you will find that 
density.ppp() now has an argument "positive" which defaults to FALSE.
Setting this argument equal to TRUE should solve your problem.

> I have a point pattern consisting of about 26,000 points, in an area as
> follows:
>
> Window: polygonal boundary
> single connected closed polygon with 133 vertices
> enclosing rectangle: [370698.1, 476022.1] x [4649777, 4732634] units
> Window area = 6525710000 square units
>
> It is clearly inhomogeneous, with most points clustered in the region's
> central city, and very few of them in the vast rural areas.
>
> The density() command from spatstat with all default values gives a
> density that is overly-smoothed for my purposes. Using density()
> command, with all default values except sigma=bw.diggle or sigma=bw.ppl,
> yields densities that are, to the eye, a better match for the point
> pattern, but some of the density values are less than zero, although
> this is not apparent when I plot() the density.

The negative values that you get are very small in magnitude; they are 
really just numerical noise (unless something *really* funny --- and I 
cannot imagine what --- is going on).

Look at

ddd <- density.(X,sigma=bw.diggle)
min(ddd)

to see just how tiny the negative values are.

> The same happens if I
> use the default sigma and set adjust to much of anything less than 1.
>
> Any ideas why, and how to avoid the negative values?

See the start of this message.

> My apologies for not including a minimal working example. Including the
> entire point pattern would be cumbersome. Whittling it down to 100 or so
> points still yields the same problem, but I think that changes the game
> and would not be a true reflection of my situation.

A whittled down example would have been perfectly "valid", but in this 
case an example was not actually needed.

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-sig-Geo mailing list