Top Banner
Spatial point patterns SSAI Course 2017 – 1 Advanced R course on spatial point patterns Adrian Baddeley / Ege Rubak Curtin University / Aalborg University SSAI 2017
181

Adrian Baddeley / Ege Rubak - spatstat

Dec 25, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Adrian Baddeley / Ege Rubak - spatstat

Spatial point patterns SSAI Course 2017 – 1

Advanced R course on spatial point patterns

Adrian Baddeley / Ege Rubak

Curtin University / Aalborg University

SSAI 2017

Page 2: Adrian Baddeley / Ege Rubak - spatstat

Plan of Workshop

Spatial point patterns SSAI Course 2017 – 2

1. Introduction

2. Inhomogeneous Intensity

3. Intensity dependent on a covariate

4. Fitting Poisson models

5. Marked point patterns

6. Correlation

7. Envelopes and Monte Carlo tests

8. Spacing and nearest neighbours

9. Cluster and Cox models

10. Gibbs models

11. Multitype summary functions and models

Page 3: Adrian Baddeley / Ege Rubak - spatstat

The slides are a summary

Spatial point patterns SSAI Course 2017 – 3

These slides are a summary of

the most important concepts

in the workshop.

Page 4: Adrian Baddeley / Ege Rubak - spatstat

The slides are a summary

Spatial point patterns SSAI Course 2017 – 3

These slides are a summary of

the most important concepts

in the workshop.

Use them for review/reminder

Page 5: Adrian Baddeley / Ege Rubak - spatstat

Spatial point patterns SSAI Course 2017 – 4

Types of spatial data

Page 6: Adrian Baddeley / Ege Rubak - spatstat

Types of spatial data

Spatial point patterns SSAI Course 2017 – 5

Three basic types of spatial data:

Page 7: Adrian Baddeley / Ege Rubak - spatstat

Types of spatial data

Spatial point patterns SSAI Course 2017 – 5

Three basic types of spatial data:

� geostatistical

Page 8: Adrian Baddeley / Ege Rubak - spatstat

Types of spatial data

Spatial point patterns SSAI Course 2017 – 5

Three basic types of spatial data:

� geostatistical

� regional

Page 9: Adrian Baddeley / Ege Rubak - spatstat

Types of spatial data

Spatial point patterns SSAI Course 2017 – 5

Three basic types of spatial data:

� geostatistical

� regional

� point pattern

Page 10: Adrian Baddeley / Ege Rubak - spatstat

Geostatistical data

Spatial point patterns SSAI Course 2017 – 6

GEOSTATISTICAL DATA:

The quantity of interest has a value at any location, . . .

Page 11: Adrian Baddeley / Ege Rubak - spatstat

Geostatistical data

Spatial point patterns SSAI Course 2017 – 7

. . . but we only measure the quantity at certain sites. These values are our data.

Page 12: Adrian Baddeley / Ege Rubak - spatstat

Regional data

Spatial point patterns SSAI Course 2017 – 8

REGIONAL DATA:

The quantity of interest is only defined for regions. It is measured/reported for certain fixed regions.

Page 13: Adrian Baddeley / Ege Rubak - spatstat

Point pattern data

Spatial point patterns SSAI Course 2017 – 9

POINT PATTERN DATA:

The main interest is in the locations of all occurrences of some event (e.g. tree deaths, meteorite

impacts, robberies). Exact locations are recorded.

Page 14: Adrian Baddeley / Ege Rubak - spatstat

Points with marks

Spatial point patterns SSAI Course 2017 – 10

Points may also carry data (e.g. tree heights, meteorite composition)

Page 15: Adrian Baddeley / Ege Rubak - spatstat

Point pattern or geostatistical data?

Spatial point patterns SSAI Course 2017 – 11

POINT PATTERN OR GEOSTATISTICAL DATA?

Page 16: Adrian Baddeley / Ege Rubak - spatstat

Explanatory vs. response variables

Spatial point patterns SSAI Course 2017 – 12

Response variable: the quantity that we want to “predict” or

“explain”

Explanatory variable: quantity that can be used to “predict” or

“explain” the response.

Page 17: Adrian Baddeley / Ege Rubak - spatstat

Point pattern or geostatistical data?

Spatial point patterns SSAI Course 2017 – 13

Geostatistics treats the spatial locations as explanatory variables and the values

attached to them as response variables.

Spatial point pattern statistics treats the spatial locations, and the values

attached to them, as the response.

Page 18: Adrian Baddeley / Ege Rubak - spatstat

Point pattern or geostatistical data?

Spatial point patterns SSAI Course 2017 – 14

“Temperature is increasing as we move from South to North” — geostatistics

“Trees become less abundant as we move from South to North” — point pattern

statistics

Page 19: Adrian Baddeley / Ege Rubak - spatstat

Spatial point patterns SSAI Course 2017 – 15

Software Overview

Page 20: Adrian Baddeley / Ege Rubak - spatstat

Software overview

Spatial point patterns SSAI Course 2017 – 16

For information on spatial statistics software in R:

Page 21: Adrian Baddeley / Ege Rubak - spatstat

Software overview

Spatial point patterns SSAI Course 2017 – 16

For information on spatial statistics software in R:

� go to cran.r-project.org

Page 22: Adrian Baddeley / Ege Rubak - spatstat

Software overview

Spatial point patterns SSAI Course 2017 – 16

For information on spatial statistics software in R:

� go to cran.r-project.org

� find Task Views

Page 23: Adrian Baddeley / Ege Rubak - spatstat

Software overview

Spatial point patterns SSAI Course 2017 – 16

For information on spatial statistics software in R:

� go to cran.r-project.org

� find Task Views --- Spatial

Page 24: Adrian Baddeley / Ege Rubak - spatstat

GIS software

Spatial point patterns SSAI Course 2017 – 17

GIS = Geographical Information System

Page 25: Adrian Baddeley / Ege Rubak - spatstat

GIS software

Spatial point patterns SSAI Course 2017 – 17

GIS = Geographical Information System

ArcInfo

Page 26: Adrian Baddeley / Ege Rubak - spatstat

GIS software

Spatial point patterns SSAI Course 2017 – 17

GIS = Geographical Information System

ArcInfo proprietary esri.com

Page 27: Adrian Baddeley / Ege Rubak - spatstat

GIS software

Spatial point patterns SSAI Course 2017 – 17

GIS = Geographical Information System

ArcInfo proprietary esri.com

GRASS open source grass.osgeo.org

Page 28: Adrian Baddeley / Ege Rubak - spatstat

GRASS

Spatial point patterns SSAI Course 2017 – 18

Page 29: Adrian Baddeley / Ege Rubak - spatstat

Recommendations

Spatial point patterns SSAI Course 2017 – 19

Recommendations:

Page 30: Adrian Baddeley / Ege Rubak - spatstat

Recommendations

Spatial point patterns SSAI Course 2017 – 19

Recommendations:

For visualisation of spatial data, especially for presentation

graphics, use a GIS.

Page 31: Adrian Baddeley / Ege Rubak - spatstat

Recommendations

Spatial point patterns SSAI Course 2017 – 19

Recommendations:

For visualisation of spatial data, especially for presentation

graphics, use a GIS.

For statistical analysis of spatial data, use R.

Page 32: Adrian Baddeley / Ege Rubak - spatstat

Recommendations

Spatial point patterns SSAI Course 2017 – 19

Recommendations:

For visualisation of spatial data, especially for presentation

graphics, use a GIS.

For statistical analysis of spatial data, use R.

Establish two-way communication between GIS and R,

either through a direct software interface, or by

reading/writing files in mutually acceptable format.

Page 33: Adrian Baddeley / Ege Rubak - spatstat

Putting the pieces together

Spatial point patterns SSAI Course 2017 – 20

RGIS

Page 34: Adrian Baddeley / Ege Rubak - spatstat

Putting the pieces together

Spatial point patterns SSAI Course 2017 – 21

RGIS

Inte

rfac

e

Interface between R and GIS (online or offline)

Page 35: Adrian Baddeley / Ege Rubak - spatstat

Putting the pieces together

Spatial point patterns SSAI Course 2017 – 22

RGIS

spatial

data

supportInte

rfac

e

Support for spatial data: data structures, classes, methods

Page 36: Adrian Baddeley / Ege Rubak - spatstat

R packages supporting spatial data

Spatial point patterns SSAI Course 2017 – 23

R packages supporting spatial data classes:

sp generic

maps polygon maps

spatstat point patterns

Page 37: Adrian Baddeley / Ege Rubak - spatstat

Putting the pieces together

Spatial point patterns SSAI Course 2017 – 24

RGIS

analysis

spatial

data

supportInte

rfac

e

Capabilities for statistical analysis

Page 38: Adrian Baddeley / Ege Rubak - spatstat

Putting the pieces together

Spatial point patterns SSAI Course 2017 – 25

RGIS

analysis

spatial

data

support

analysis

analysis

Inte

rfac

e

Multiple packages for different analyses

Page 39: Adrian Baddeley / Ege Rubak - spatstat

Statistical functionality

Spatial point patterns SSAI Course 2017 – 26

R packages for geostatistical data

gstat classical geostatistics

geoR model-based geostatistics

RandomFields stochastic processes

akima interpolation

Page 40: Adrian Baddeley / Ege Rubak - spatstat

Statistical functionality

Spatial point patterns SSAI Course 2017 – 26

R packages for geostatistical data

gstat classical geostatistics

geoR model-based geostatistics

RandomFields stochastic processes

akima interpolation

R packages for regional data

spdep spatial dependence

spgwr geographically weighted regression

Page 41: Adrian Baddeley / Ege Rubak - spatstat

Statistical functionality

Spatial point patterns SSAI Course 2017 – 26

R packages for geostatistical data

gstat classical geostatistics

geoR model-based geostatistics

RandomFields stochastic processes

akima interpolation

R packages for regional data

spdep spatial dependence

spgwr geographically weighted regression

R packages for point patterns

spatstat parametric modelling, diagnostics

splancs nonparametric, space-time

Page 42: Adrian Baddeley / Ege Rubak - spatstat

Spatial point patterns SSAI Course 2017 – 27

Spatial point patterns

Page 43: Adrian Baddeley / Ege Rubak - spatstat

Software

Spatial point patterns SSAI Course 2017 – 28

The R package spatstat supports statistical analysis for spatialpoint patterns.

Page 44: Adrian Baddeley / Ege Rubak - spatstat

Point patterns

Spatial point patterns SSAI Course 2017 – 29

A point pattern dataset gives the locations of objects/events occurring in a study region.

The points could represent trees, animal nests, earthquake epicentres, petty crimes, domiciles of

new cases of influenza, galaxies, etc.

Page 45: Adrian Baddeley / Ege Rubak - spatstat

Marks

Spatial point patterns SSAI Course 2017 – 30

The points may have extra information called marks attached to them. The mark represents an

“attribute” of the point.

Page 46: Adrian Baddeley / Ege Rubak - spatstat

Marks

Spatial point patterns SSAI Course 2017 – 30

The points may have extra information called marks attached to them. The mark represents an

“attribute” of the point.

The mark variable could be categorical, e.g. species or disease status:

on

off

off

on

Page 47: Adrian Baddeley / Ege Rubak - spatstat

Continuous marks

Spatial point patterns SSAI Course 2017 – 31

The mark variable could be continuous, e.g. tree diameter:

20

40

60

Page 48: Adrian Baddeley / Ege Rubak - spatstat

Covariates

Spatial point patterns SSAI Course 2017 – 32

Our dataset may also include covariates — any data that we treat as explanatory, rather than as

part of the ‘response’.

Covariate data may be a spatial function Z(u) defined at all spatial locations u, e.g. altitude, soil

pH, displayed as a pixel image or a contour plot:

125 125 130

130

130

130

135

135

135

140

140

140

145

145 150

150

155

Page 49: Adrian Baddeley / Ege Rubak - spatstat

Covariates

Spatial point patterns SSAI Course 2017 – 33

Covariate data may be another spatial pattern such as another point pattern, or a line segment

pattern, e.g. a map of geological faults:

Page 50: Adrian Baddeley / Ege Rubak - spatstat

Spatial point patterns SSAI Course 2017 – 34

Intensity

Page 51: Adrian Baddeley / Ege Rubak - spatstat

Intensity

Spatial point patterns SSAI Course 2017 – 35

‘Intensity’ is the average density of points (expected number of points per unit area).

Intensity may be constant (‘uniform’) or may vary from location to location (‘non-uniform’ or

‘inhomogeneous’).

uniform

inhomogeneous

Page 52: Adrian Baddeley / Ege Rubak - spatstat

Swedish Pines data

Spatial point patterns SSAI Course 2017 – 36

> data(swedishpines)

> P <- swedishpines

> plot(P)

Page 53: Adrian Baddeley / Ege Rubak - spatstat

Quadrat counts

Spatial point patterns SSAI Course 2017 – 37

Divide study region into rectangles (‘quadrats’) of equal size, and count points in each rectangle.Q <- quadratcount(P, nx=3, ny=3)

Q

plot(Q, add=TRUE)

P

+

+

+

+

+

+

+

+

+

+

+

+

+

++

+

+

++

+

+

+

++

+

+

+

+

++

+

+

+

+

+

+

+

+

+

+

+

++

+

++

+

+

++

++

+

+

+

+

+

+

+

+

+

+

+

+

+

++

++

+

+

8 6 7

8 11 9

5 6 11

Page 54: Adrian Baddeley / Ege Rubak - spatstat

χ2 test of uniformity

Spatial point patterns SSAI Course 2017 – 38

If the points have uniform intensity, and are completely random, then the quadrat counts should be

Poisson random numbers with constant mean.

Page 55: Adrian Baddeley / Ege Rubak - spatstat

χ2 test of uniformity

Spatial point patterns SSAI Course 2017 – 38

If the points have uniform intensity, and are completely random, then the quadrat counts should be

Poisson random numbers with constant mean.

Use the χ2 goodness-of-fit test statistic

X2 =∑ (observed − expected)2

expected

Page 56: Adrian Baddeley / Ege Rubak - spatstat

χ2 test of uniformity

Spatial point patterns SSAI Course 2017 – 38

If the points have uniform intensity, and are completely random, then the quadrat counts should be

Poisson random numbers with constant mean.

Use the χ2 goodness-of-fit test statistic

X2 =∑ (observed − expected)2

expected

> quadrat.test(P, nx=3, ny=3)

Chi-squared test of CSR using quadrat counts

data: P

X-squared = 4.6761, df = 8, p-value = 0.7916

Page 57: Adrian Baddeley / Ege Rubak - spatstat

χ2 test of uniformity

Spatial point patterns SSAI Course 2017 – 39

> QT <- quadrat.test(P, nx=3, ny=3)

> plot(P)

> plot(QT, add=TRUE)

8 6 7

8 11 9

5 6 11

7.9 7.9 7.9

7.9 7.9 7.9

7.9 7.9 7.9

0.04 −0.67 −0.32

0.04 1.1 0.4

−1 −0.67 1.1

Page 58: Adrian Baddeley / Ege Rubak - spatstat

Kernel smoothing

Spatial point patterns SSAI Course 2017 – 40

Kernel smoothed intensity

λ̃(u) =

n∑

i=1

κ(u− xi)

where κ(u) is the kernel function and x1, . . . , xn are the data points.

Page 59: Adrian Baddeley / Ege Rubak - spatstat

Kernel smoothing

Spatial point patterns SSAI Course 2017 – 40

Kernel smoothed intensity

λ̃(u) =

n∑

i=1

κ(u− xi)

where κ(u) is the kernel function and x1, . . . , xn are the data points.

1. replace each data point by a square of chocolate

Page 60: Adrian Baddeley / Ege Rubak - spatstat

Kernel smoothing

Spatial point patterns SSAI Course 2017 – 40

Kernel smoothed intensity

λ̃(u) =

n∑

i=1

κ(u− xi)

where κ(u) is the kernel function and x1, . . . , xn are the data points.

1. replace each data point by a square of chocolate

2. melt chocolate with hair dryer

Page 61: Adrian Baddeley / Ege Rubak - spatstat

Kernel smoothing

Spatial point patterns SSAI Course 2017 – 40

Kernel smoothed intensity

λ̃(u) =

n∑

i=1

κ(u− xi)

where κ(u) is the kernel function and x1, . . . , xn are the data points.

1. replace each data point by a square of chocolate

2. melt chocolate with hair dryer

3. resulting landscape is a kernel smoothed estimate of intensity function

Page 62: Adrian Baddeley / Ege Rubak - spatstat

Kernel smoothing

Spatial point patterns SSAI Course 2017 – 41

den <- density(P, sigma=15)

plot(den)

plot(P, add=TRUE)

0.0

04

0.0

06

0.0

08

0.0

10

.01

2+

+

+

+

+

+

+

+

+

+

+

+

+

++

+

+

++

+

+

+

++

+

+

+

+

++

+

+

+

+

+

+

+

+

+

+

+

++

+

+

+

+

+

+

+

++

+

+

+

+

+

+

+

+

+

+

+

+

+

++

++

+

+

Page 63: Adrian Baddeley / Ege Rubak - spatstat

Modelling intensity

Spatial point patterns SSAI Course 2017 – 42

A more searching analysis involves fitting models that describe how

the point pattern intensity λ(u) depends on spatial location u or on

spatial covariates Z(u).

Page 64: Adrian Baddeley / Ege Rubak - spatstat

Modelling intensity

Spatial point patterns SSAI Course 2017 – 42

A more searching analysis involves fitting models that describe how

the point pattern intensity λ(u) depends on spatial location u or on

spatial covariates Z(u).

Intensity is modelled using a “log link”.

Page 65: Adrian Baddeley / Ege Rubak - spatstat

Modelling intensity

Spatial point patterns SSAI Course 2017 – 43

COMMAND INTENSITY

ppm(P ~1) log λ(u) = β0

Page 66: Adrian Baddeley / Ege Rubak - spatstat

Modelling intensity

Spatial point patterns SSAI Course 2017 – 43

COMMAND INTENSITY

ppm(P ~1) log λ(u) = β0

β0, β1, . . . denote parameters to be estimated.

Page 67: Adrian Baddeley / Ege Rubak - spatstat

Modelling intensity

Spatial point patterns SSAI Course 2017 – 43

COMMAND INTENSITY

ppm(P ~1) log λ(u) = β0

ppm(P ~x) log λ((x, y)) = β0 + β1x

β0, β1, . . . denote parameters to be estimated.

Page 68: Adrian Baddeley / Ege Rubak - spatstat

Modelling intensity

Spatial point patterns SSAI Course 2017 – 43

COMMAND INTENSITY

ppm(P ~1) log λ(u) = β0

ppm(P ~x) log λ((x, y)) = β0 + β1x

ppm(P ~x + y) log λ((x, y)) = β0 + β1x+ β2y

β0, β1, . . . denote parameters to be estimated.

Page 69: Adrian Baddeley / Ege Rubak - spatstat

Swedish Pines data

Spatial point patterns SSAI Course 2017 – 44

> ppm(P ~1)

Stationary Poisson process

Uniform intensity: 0.007

Page 70: Adrian Baddeley / Ege Rubak - spatstat

Swedish Pines data

Spatial point patterns SSAI Course 2017 – 45

> ppm(P ~x+y)

Nonstationary Poisson process

Trend formula: ~x + y

Fitted coefficients for trend formula:

(Intercept) x y

-5.1237 0.00461 -0.00025

Page 71: Adrian Baddeley / Ege Rubak - spatstat

Modelling intensity

Spatial point patterns SSAI Course 2017 – 46

COMMAND INTENSITY

ppm(P ~polynom(x,y,3)) exp(3rd order polynomial in x and y)

Page 72: Adrian Baddeley / Ege Rubak - spatstat

Modelling intensity

Spatial point patterns SSAI Course 2017 – 46

COMMAND INTENSITY

ppm(P ~polynom(x,y,3)) exp(3rd order polynomial in x and y)

ppm(P ~I(y > 18)) different constants above and below

the line y = 18

Page 73: Adrian Baddeley / Ege Rubak - spatstat

Fitted intensity

Spatial point patterns SSAI Course 2017 – 47

fit <- ppm(P ~x+y)

lam <- predict(fit)

plot(lam)The predict method computes fitted values of intensity function λ(u) at a grid of locations.

lam

0.0

06

0.0

07

0.0

08

0.0

09

Page 74: Adrian Baddeley / Ege Rubak - spatstat

Likelihood ratio test

Spatial point patterns SSAI Course 2017 – 48

fit0 <- ppm(P ~1)

fit1 <- ppm(P ~polynom(x,y,2))

anova(fit0, fit1, test="Chi")

Page 75: Adrian Baddeley / Ege Rubak - spatstat

Likelihood ratio test

Spatial point patterns SSAI Course 2017 – 48

fit0 <- ppm(P ~1)

fit1 <- ppm(P ~polynom(x,y,2))

anova(fit0, fit1, test="Chi")Analysis of Deviance Table

Model 1: ~1 Poisson

Model 2: ~x + y + I(x^2) + I(x * y) + I(y^2) Poisson

Npar Df Deviance Pr(>Chi)

1 1

2 6 5 7.4821 0.1872

Page 76: Adrian Baddeley / Ege Rubak - spatstat

Likelihood ratio test

Spatial point patterns SSAI Course 2017 – 48

fit0 <- ppm(P ~1)

fit1 <- ppm(P ~polynom(x,y,2))

anova(fit0, fit1, test="Chi")Analysis of Deviance Table

Model 1: ~1 Poisson

Model 2: ~x + y + I(x^2) + I(x * y) + I(y^2) Poisson

Npar Df Deviance Pr(>Chi)

1 1

2 6 5 7.4821 0.1872

The p-value 0.19 exceeds 0.05 so the log-quadratic spatial trend is not significant.

Page 77: Adrian Baddeley / Ege Rubak - spatstat

Residuals

Spatial point patterns SSAI Course 2017 – 49

diagnose.ppm(fit0, which="smooth")

−0.003

−0.002

−0.002

−0.001

−0.001

0

0

0.001 0.001

0.0

02

0.002

0.0

03

0.0

04

0.0

05

Smoothed raw residuals

Page 78: Adrian Baddeley / Ege Rubak - spatstat

Spatial point patterns SSAI Course 2017 – 50

Spatial covariates

Page 79: Adrian Baddeley / Ege Rubak - spatstat

Spatial covariates

Spatial point patterns SSAI Course 2017 – 51

A spatial covariate is a function Z(u) of spatial location.

Page 80: Adrian Baddeley / Ege Rubak - spatstat

Spatial covariates

Spatial point patterns SSAI Course 2017 – 51

A spatial covariate is a function Z(u) of spatial location.

� geographical coordinates

Page 81: Adrian Baddeley / Ege Rubak - spatstat

Spatial covariates

Spatial point patterns SSAI Course 2017 – 51

A spatial covariate is a function Z(u) of spatial location.

� geographical coordinates

� terrain altitude

Page 82: Adrian Baddeley / Ege Rubak - spatstat

Spatial covariates

Spatial point patterns SSAI Course 2017 – 51

A spatial covariate is a function Z(u) of spatial location.

� geographical coordinates

� terrain altitude

� soil pH

Page 83: Adrian Baddeley / Ege Rubak - spatstat

Spatial covariates

Spatial point patterns SSAI Course 2017 – 51

A spatial covariate is a function Z(u) of spatial location.

� geographical coordinates

� terrain altitude

� soil pH

� distance from location u to another feature

Page 84: Adrian Baddeley / Ege Rubak - spatstat

Spatial covariates

Spatial point patterns SSAI Course 2017 – 51

A spatial covariate is a function Z(u) of spatial location.

� geographical coordinates

� terrain altitude

� soil pH

� distance from location u to another feature

125 125 130

130

130

130

135

135

135

140

140

140

145

145 150

150

155

Page 85: Adrian Baddeley / Ege Rubak - spatstat

Covariates

Spatial point patterns SSAI Course 2017 – 52

Covariate data may be another spatial pattern such as another point pattern, or a line segment

pattern:

Page 86: Adrian Baddeley / Ege Rubak - spatstat

Covariate effects

Spatial point patterns SSAI Course 2017 – 53

For a point pattern dataset with covariate data, we typically

� investigate whether the intensity depends on the covariates

� allow for covariate effects on intensity before studying dependence between

points

Page 87: Adrian Baddeley / Ege Rubak - spatstat

Example: Queensland copper data

Spatial point patterns SSAI Course 2017 – 54

A intensive mineralogical survey yields a map of copper deposits (essentially pointlike at this scale)

and geological faults (straight lines). The faults can easily be observed from satellites, but the

copper deposits are hard to find.

Main question: whether the faults are ‘predictive’ for copper deposits (e.g. copper less/more likely to

be found near faults).

Page 88: Adrian Baddeley / Ege Rubak - spatstat

Copper data

Spatial point patterns SSAI Course 2017 – 55

data(copper)

P <- copper$SouthPoints

Y <- copper$SouthLines

plot(P)

plot(Y, add=TRUE)

++

+++ +

++

+++

+ +

++

+ +

+

+ +++

+

++ +

+

+

+

+

+

++++ +

+

+ +

+

+

+ ++ +

+ +

++ +

+

+

++

+

++

Page 89: Adrian Baddeley / Ege Rubak - spatstat

Copper data

Spatial point patterns SSAI Course 2017 – 56

For analysis, we need a value Z(u) defined at each location u.

Page 90: Adrian Baddeley / Ege Rubak - spatstat

Copper data

Spatial point patterns SSAI Course 2017 – 56

For analysis, we need a value Z(u) defined at each location u.

Example: Z(u) = distance from u to nearest line.

Page 91: Adrian Baddeley / Ege Rubak - spatstat

Copper data

Spatial point patterns SSAI Course 2017 – 56

For analysis, we need a value Z(u) defined at each location u.

Example: Z(u) = distance from u to nearest line.

Z <- distmap(Y)

plot(Z)

Z

24

68

10

Page 92: Adrian Baddeley / Ege Rubak - spatstat

Lurking variable plot

Spatial point patterns SSAI Course 2017 – 57

We want to determine whether intensity depends on a spatial covariate Z.

Page 93: Adrian Baddeley / Ege Rubak - spatstat

Lurking variable plot

Spatial point patterns SSAI Course 2017 – 57

We want to determine whether intensity depends on a spatial covariate Z.

Plot C(z) against z, where C(z) = fraction of data points xi for which Z(xi) ≤ z.

Page 94: Adrian Baddeley / Ege Rubak - spatstat

Lurking variable plot

Spatial point patterns SSAI Course 2017 – 57

We want to determine whether intensity depends on a spatial covariate Z.

Plot C(z) against z, where C(z) = fraction of data points xi for which Z(xi) ≤ z.

Also plot C0(z) against z, where C0(z) = fraction of area of study region where Z(u) ≤ z.

Page 95: Adrian Baddeley / Ege Rubak - spatstat

Lurking variable plot

Spatial point patterns SSAI Course 2017 – 57

We want to determine whether intensity depends on a spatial covariate Z.

Plot C(z) against z, where C(z) = fraction of data points xi for which Z(xi) ≤ z.

Also plot C0(z) against z, where C0(z) = fraction of area of study region where Z(u) ≤ z.

lurking(ppm(P), Z)

Page 96: Adrian Baddeley / Ege Rubak - spatstat

Lurking variable plot

Spatial point patterns SSAI Course 2017 – 57

We want to determine whether intensity depends on a spatial covariate Z.

Plot C(z) against z, where C(z) = fraction of data points xi for which Z(xi) ≤ z.

Also plot C0(z) against z, where C0(z) = fraction of area of study region where Z(u) ≤ z.

lurking(ppm(P), Z)

0 2 4 6 8 10

01000

2000

3000

4000

5000

distance to nearest line

pro

babili

ty

Page 97: Adrian Baddeley / Ege Rubak - spatstat

Kolmogorov-Smirnov test

Spatial point patterns SSAI Course 2017 – 58

Formal test of agreement between C(z) and C0(z).

Page 98: Adrian Baddeley / Ege Rubak - spatstat

Kolmogorov-Smirnov test

Spatial point patterns SSAI Course 2017 – 58

Formal test of agreement between C(z) and C0(z).> kstest(P, Z)

Spatial Kolmogorov-Smirnov test of CSR

data: covariate ’Z’ evaluated at points of ’P’

and transformed to uniform distribution under CSR

D = 0.1163, p-value = 0.3939

alternative hypothesis: two-sided

Page 99: Adrian Baddeley / Ege Rubak - spatstat

Copper data

Spatial point patterns SSAI Course 2017 – 59

Z <- distmap(Y)

ppm(P ~ Z)

Fits the model

log λ(u) = β0 + β1Z(u)

where Z(u) is the distance from u to the nearest line segment.

Page 100: Adrian Baddeley / Ege Rubak - spatstat

Copper data

Spatial point patterns SSAI Course 2017 – 60

Z <- distmap(Y)

ppm(P ~ polynom(Z,5))fits a model in which log λ(u) is a 5th order polynomial function of Z(u).

Page 101: Adrian Baddeley / Ege Rubak - spatstat

Copper data

Spatial point patterns SSAI Course 2017 – 61

fit <- ppm(P ~polynom(Z,5))

plot(predict(fit))

00

.00

50

.01

0.0

15

Page 102: Adrian Baddeley / Ege Rubak - spatstat

Copper data

Spatial point patterns SSAI Course 2017 – 62

plot(effectfun(fit))plots fitted curve of λ against Z .

Page 103: Adrian Baddeley / Ege Rubak - spatstat

Copper data

Spatial point patterns SSAI Course 2017 – 63

0 2 4 6 8 10

0.0

00

0.0

05

0.0

10

0.0

15

effectfun(fit)

distance to nearest line

inte

nsity

Page 104: Adrian Baddeley / Ege Rubak - spatstat

Likelihood ratio test

Spatial point patterns SSAI Course 2017 – 64

fit0 <- ppm(P ~1)

fit1 <- ppm(P ~polynom(Z,5))

anova(fit0, fit1, test="Chi")

Page 105: Adrian Baddeley / Ege Rubak - spatstat

Likelihood ratio test

Spatial point patterns SSAI Course 2017 – 64

fit0 <- ppm(P ~1)

fit1 <- ppm(P ~polynom(Z,5))

anova(fit0, fit1, test="Chi")Analysis of Deviance Table

Model 1: ~1 Poisson

Model 2: ~Z + I(Z^2) + I(Z^3) + I(Z^4) + I(Z^5) Poisson

Npar Df Deviance Pr(>Chi)

1 1

2 6 5 3.6476 0.6012

Page 106: Adrian Baddeley / Ege Rubak - spatstat

Likelihood ratio test

Spatial point patterns SSAI Course 2017 – 64

fit0 <- ppm(P ~1)

fit1 <- ppm(P ~polynom(Z,5))

anova(fit0, fit1, test="Chi")Analysis of Deviance Table

Model 1: ~1 Poisson

Model 2: ~Z + I(Z^2) + I(Z^3) + I(Z^4) + I(Z^5) Poisson

Npar Df Deviance Pr(>Chi)

1 1

2 6 5 3.6476 0.6012

The p-value 0.81 exceeds 0.05 so the 5th order polynomial is not significant.

Page 107: Adrian Baddeley / Ege Rubak - spatstat

Interaction

Spatial point patterns SSAI Course 2017 – 65

‘Interpoint interaction’ is stochastic dependence between the points in a point pattern. Usually we

expect dependence to be strongest between points that are close to one another.

independent

regular

clustered

Page 108: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 66

Example: spacing between points in Swedish Pines data

swedishpines

Page 109: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 67

nearest neighbour distance = distance from a given point to the nearest other point

swedishpines

Page 110: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 68

Summary approach:

Page 111: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 68

Summary approach:

1. calculate average nearest-neighbour distance

Page 112: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 68

Summary approach:

1. calculate average nearest-neighbour distance

2. divide by the value expected for a completely random pattern.

Clark & Evans (1954)

Page 113: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 68

Summary approach:

1. calculate average nearest-neighbour distance

2. divide by the value expected for a completely random pattern.

Clark & Evans (1954)

> mean(nndist(swedishpines))

[1] 7.90754

> clarkevans(swedishpines)

naive Donnelly cdf

1.360082 1.291069 1.322862

Page 114: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 68

Summary approach:

1. calculate average nearest-neighbour distance

2. divide by the value expected for a completely random pattern.

Clark & Evans (1954)

> mean(nndist(swedishpines))

[1] 7.90754

> clarkevans(swedishpines)

naive Donnelly cdf

1.360082 1.291069 1.322862

Value greater than 1 suggests a regular pattern.

Page 115: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 69

Exploratory approach:

Page 116: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 69

Exploratory approach:

� plot NND for each point

P <- swedishpines

marks(P) <- nndist(P)

plot(P, markscale=0.5)

4

6

8

10

12

14

Page 117: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 70

Exploratory approach:

� plot NND for each point

Page 118: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 70

Exploratory approach:

� plot NND for each point

� look at empirical distribution of NND’s

plot(Gest(swedishpines))

0.0

0.2

0.4

0.6

0.8

Gest(swedishpines)

G^

km(r)G^

bord(r)G^

han(r)Gpois(r)

Page 119: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 71

Modelling approach:

Page 120: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 71

Modelling approach:

� Fit a stochastic model to the point pattern, with likelihood based on the NND’s.

Page 121: Adrian Baddeley / Ege Rubak - spatstat

Example

Spatial point patterns SSAI Course 2017 – 71

Modelling approach:

� Fit a stochastic model to the point pattern, with likelihood based on the NND’s.

> ppm(P ~1, Geyer(4,1))

Stationary Geyer saturation process

First order term:

beta

0.00971209

Fitted interaction parameter gamma: 0.6335

Page 122: Adrian Baddeley / Ege Rubak - spatstat

Example: Japanese pines

Spatial point patterns SSAI Course 2017 – 72

Locations of 65 saplings of Japanese pine in a 5.7× 5.7 metre square sampling region in a natural

stand.data(japanesepines)

J <- japanesepines

plot(J)

Japanese Pines

Page 123: Adrian Baddeley / Ege Rubak - spatstat

Japanese Pines

Spatial point patterns SSAI Course 2017 – 73

fit <- ppm(J ~polynom(x,y,3))

plot(predict(fit))

plot(J, add=TRUE)

predict(fit)

50

100

150

200

250

Page 124: Adrian Baddeley / Ege Rubak - spatstat

Adjusting for inhomogeneity

Spatial point patterns SSAI Course 2017 – 74

If the intensity function λ(u) is known, or estimated from data, thensome statistics can be adjusted by counting each data point xi with aweight wi = 1/λ(xi).

Page 125: Adrian Baddeley / Ege Rubak - spatstat

Inhomogeneous K-function

Spatial point patterns SSAI Course 2017 – 75

lam <- predict(fit)

plot(Kinhom(J, lam))

0.00 0.05 0.10 0.15 0.20 0.25

0.0

00

.05

0.1

00

.15

0.2

0

Kinhom(J, lam)

r (one unit = 5.7 metres)

Kin

ho

m(r

)K^

inhom

iso

(r)

K^

inhom

trans

(r)

K^

inhom

bord

(r)

K^

inhom

bordm

(r)K inhom

pois (r)

Page 126: Adrian Baddeley / Ege Rubak - spatstat

Conditional intensity

Spatial point patterns SSAI Course 2017 – 76

A point process model can also be defined through its conditional intensity λ(u | x).This is essentially the conditional probability of finding a point of the process at the location u, given

complete information about the rest of the process x.

u

Page 127: Adrian Baddeley / Ege Rubak - spatstat

Strauss process

Spatial point patterns SSAI Course 2017 – 77

Strauss(γ = 0.2) Strauss(γ = 0.7)

Page 128: Adrian Baddeley / Ege Rubak - spatstat

Fitting Gibbs models

Spatial point patterns SSAI Course 2017 – 78

The command ppm will also fit Gibbs models, using the technique of ‘maximum pseudolikelihood’.

Page 129: Adrian Baddeley / Ege Rubak - spatstat

Fitting Gibbs models

Spatial point patterns SSAI Course 2017 – 78

The command ppm will also fit Gibbs models, using the technique of ‘maximum pseudolikelihood’.

data(swedishpines)

ppm(swedishpines ~1, Strauss(r=7))

Page 130: Adrian Baddeley / Ege Rubak - spatstat

Fitting Gibbs models

Spatial point patterns SSAI Course 2017 – 78

The command ppm will also fit Gibbs models, using the technique of ‘maximum pseudolikelihood’.

data(swedishpines)

ppm(swedishpines ~1, Strauss(r=7))

Stationary Strauss process

First order term:

beta

0.02583902

Interaction: Strauss process

interaction distance: 7

Fitted interaction parameter gamma: 0.1841

Page 131: Adrian Baddeley / Ege Rubak - spatstat

Fitting Gibbs models

Spatial point patterns SSAI Course 2017 – 79

The model can include both spatial trend and interpoint interaction.

Page 132: Adrian Baddeley / Ege Rubak - spatstat

Fitting Gibbs models

Spatial point patterns SSAI Course 2017 – 79

The model can include both spatial trend and interpoint interaction.data(japanesepines)

ppm(japanesepines ~polynom(x,y,3), Strauss(r=0.07))

Page 133: Adrian Baddeley / Ege Rubak - spatstat

Fitting Gibbs models

Spatial point patterns SSAI Course 2017 – 79

The model can include both spatial trend and interpoint interaction.data(japanesepines)

ppm(japanesepines ~polynom(x,y,3), Strauss(r=0.07))Nonstationary Strauss process

Trend formula: ~polynom(x, y, 3)

Fitted coefficients for trend formula:

(Intercept) polynom(x, y, 3)[x] polynom(x, y, 3)[y]

0.4925368 22.0485400 -9.1889134

polynom(x, y, 3)[x^2] polynom(x, y, 3)[x.y] polynom(x, y, 3)[y^2]

-14.6524958 -41.0222232 50.2099917

polynom(x, y, 3)[x^3] polynom(x, y, 3)[x^2.y] polynom(x, y, 3)[x.y^2]

3.4935300 5.4524828 23.9209323

polynom(x, y, 3)[y^3]

-38.3946389

Interaction: Strauss process

interaction distance: 0.1

Fitted interaction parameter gamma: 0.5323

Page 134: Adrian Baddeley / Ege Rubak - spatstat

Plotting a fitted model

Spatial point patterns SSAI Course 2017 – 80

When we plot or predict a fitted Gibbs model, the first order trend β(u) and/or the conditional

intensity λ(u | x) are plotted.

fit <- ppm(japanesepines ~x, Strauss(r=0.1))

plot(predict(fit))

plot(predict(fit, type="cif")) predict(fit)

60

65

70

75

80

85

predict(fit, type = "cif")

20

30

40

50

60

70

80

Page 135: Adrian Baddeley / Ege Rubak - spatstat

Simulating the fitted model

Spatial point patterns SSAI Course 2017 – 81

A fitted Gibbs model can be simulated automatically using the Metropolis-Hastings algorithm (which

only requires the conditional intensity).

Page 136: Adrian Baddeley / Ege Rubak - spatstat

Simulating the fitted model

Spatial point patterns SSAI Course 2017 – 81

A fitted Gibbs model can be simulated automatically using the Metropolis-Hastings algorithm (which

only requires the conditional intensity).fit <- ppm(swedishpines ~1, Strauss(r=7))

Xsim <- simulate(fit)

plot(Xsim)

Page 137: Adrian Baddeley / Ege Rubak - spatstat

Simulating the fitted model

Spatial point patterns SSAI Course 2017 – 81

A fitted Gibbs model can be simulated automatically using the Metropolis-Hastings algorithm (which

only requires the conditional intensity).fit <- ppm(swedishpines ~1, Strauss(r=7))

Xsim <- simulate(fit)

plot(Xsim)

Xsim

Page 138: Adrian Baddeley / Ege Rubak - spatstat

Simulation-based tests

Spatial point patterns SSAI Course 2017 – 82

Tests of goodness-of-fit can be performed by simulating from the fitted model.

plot(envelope(fit, Gest, nsim=19))

0 2 4 6 8 10

0.0

0.2

0.4

0.6

0.8

1.0

envelope(fit, Gest, nsim = 39)

r (one unit = 0.1 metres)

G(r

)G^

obs(r)G(r)G^

hi(r)G^

lo(r)

Page 139: Adrian Baddeley / Ege Rubak - spatstat

Diagnostics

Spatial point patterns SSAI Course 2017 – 83

More powerful diagnostics are available.

diagnose.ppm(fit)

−0.004

−0.004

−0.004

−0.002

−0.002

−0.002

0

0

0

0.002

0.002

0.004

0.004

0.004

0.0

06

0 20 40 60 80 100

x coordinate

−8−6

−4−2

02

4

cum

ula

tive

sum

of ra

w r

esid

uals

020

40

60

80

100

y c

oord

inate

8 6 4 2 0 −2 −4 −6

cumulative sum of raw residuals

Page 140: Adrian Baddeley / Ege Rubak - spatstat

Spatial point patterns SSAI Course 2017 – 84

Marks

Page 141: Adrian Baddeley / Ege Rubak - spatstat

Marks

Spatial point patterns SSAI Course 2017 – 85

Each point in a spatial point pattern may carry additional information called a ‘mark’. It may be

a continuous variate: tree diameter, tree height

a categorical variate: label classifying the points into two or more different types (on/off,

case/control, species, colour)

20

40

60

on

off

In spatstat version 1, the mark attached to each point must be a single value.

Page 142: Adrian Baddeley / Ege Rubak - spatstat

Spatial point patterns SSAI Course 2017 – 86

Categorical marks

Page 143: Adrian Baddeley / Ege Rubak - spatstat

Categorical marks

Spatial point patterns SSAI Course 2017 – 87

A point pattern with categorical marks is usually called “multi-type”.> data(amacrine)

> amacrine

marked planar point pattern: 294 points

multitype, with levels = off on

window: rectangle = [0, 1.6012] x [0, 1] units (one unit = 662 microns)

> plot(amacrine) amacrine

on

off

Page 144: Adrian Baddeley / Ege Rubak - spatstat

Multitype point patterns

Spatial point patterns SSAI Course 2017 – 88

summary(amacrine)

Page 145: Adrian Baddeley / Ege Rubak - spatstat

Multitype point patterns

Spatial point patterns SSAI Course 2017 – 88

summary(amacrine)

Marked planar point pattern: 294 points

Average intensity 184 points per square unit (one unit = 662 microns)

Multitype:

frequency proportion intensity

off 142 0.483 88.7

on 152 0.517 94.9

Window: rectangle = [0, 1.6012] x [0, 1] units

Window area = 1.60121 square units

Unit of length: 662 microns

Page 146: Adrian Baddeley / Ege Rubak - spatstat

Intensity of multitype patterns

Spatial point patterns SSAI Course 2017 – 89

plot(split(amacrine))split(amacrine)

off

on

Page 147: Adrian Baddeley / Ege Rubak - spatstat

Intensity of multitype patterns

Spatial point patterns SSAI Course 2017 – 90

data(lansing)

summary(lansing)

plot(lansing) lansing

whiteoak

redoak

misc

maple

hickory

blackoak

Page 148: Adrian Baddeley / Ege Rubak - spatstat

Intensity of multitype patterns

Spatial point patterns SSAI Course 2017 – 91

“Segregation” occurs when the intensity depends on the mark (i.e. on the type of point).

plot(split(lansing))split(lansing)

blackoak

hickory

maple

misc

redoak

whiteoak

Page 149: Adrian Baddeley / Ege Rubak - spatstat

Intensity of multitype patterns

Spatial point patterns SSAI Course 2017 – 92

Let λ(u,m) be the intensity function for points of type m at location u. This can be estimated by

kernel smoothing the data points of type m.

plot(density(split(lansing)))

blackoak hickory maple

misc redoak whiteoak

Page 150: Adrian Baddeley / Ege Rubak - spatstat

Segregation

Spatial point patterns SSAI Course 2017 – 93

The probability that a point at location u has mark m is

p(m | u) =λ(u,m)

λ(u)

where λ(u) =∑

m λ(u,m) is the intensity function of points of all types.

Page 151: Adrian Baddeley / Ege Rubak - spatstat

Segregation

Spatial point patterns SSAI Course 2017 – 94

lansP <- relrisk(lansing)

plot(lansP)

blackoak

0.0

50

.15

0.2

5

hickory0

.10

.30

.50

.7 maple

0.1

0.3

0.5

0.7

misc

00

.05

0.1

5

redoak

0.1

0.2

0.3

whiteoak0

.10

.30

.5

Page 152: Adrian Baddeley / Ege Rubak - spatstat

Spatial point patterns SSAI Course 2017 – 95

Interaction between types

Page 153: Adrian Baddeley / Ege Rubak - spatstat

Interaction between types

Spatial point patterns SSAI Course 2017 – 96

In a multitype point pattern, there may be interaction between the points of different types, or

between points of the same type. amacrine

on

off

Page 154: Adrian Baddeley / Ege Rubak - spatstat

Bivariate G-function

Spatial point patterns SSAI Course 2017 – 97

Assume the points of type i have uniform intensity λi, for all i.

For two given types i and j, the bivariate G-function Gij is

Gij(r) = P (Rij ≤ r)

where Rij is the distance from a typical point of type i to the nearest point of type j.

Page 155: Adrian Baddeley / Ege Rubak - spatstat

Bivariate G-function

Spatial point patterns SSAI Course 2017 – 98

plot(Gcross(amacrine, "on", "off"))

0.00 0.01 0.02 0.03 0.04 0.05 0.06

0.0

0.2

0.4

0.6

0.8

Gcross(amacrine, "on", "off")

r (one unit = 662 microns)

Go

n, o

ff(r

)

G^

on, of f

km

(r)

G^

on, of f

bord

(r)

G^

on, of f

han

(r)

Gon, of f

pois (r)

Page 156: Adrian Baddeley / Ege Rubak - spatstat

Bivariate G-function

Spatial point patterns SSAI Course 2017 – 99

plot(alltypes(amacrine, Gcross))

0.00 0.02 0.04 0.06 0.08 0.10

0.0

0.2

0.4

0.6

0.8

r (one unit = 662 microns)

Goff

, off(r

)

0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07

0.0

0.2

0.4

0.6

0.8

r (one unit = 662 microns)

Goff

, on(r

)

0.00 0.01 0.02 0.03 0.04 0.05 0.06

0.0

0.2

0.4

0.6

0.8

r (one unit = 662 microns)

Gon

, off(r

)

0.00 0.02 0.04 0.06 0.08 0.10

0.0

0.2

0.4

0.6

0.8

r (one unit = 662 microns)

Gon

, on(r

)

off ono

ffo

n

array of Gcross functions for amacrine.

Page 157: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

Page 158: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1)

Page 159: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Page 160: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

Page 161: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks)

Page 162: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks) log λ(u,m) = βm

Page 163: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks) log λ(u,m) = βm

Different constant intensity for points of each type.

Page 164: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks) log λ(u,m) = βm

Different constant intensity for points of each type.

ppm(X ~marks + x)

Page 165: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks) log λ(u,m) = βm

Different constant intensity for points of each type.

ppm(X ~marks + x) log λ((x, y),m) = βm + αx

Page 166: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks) log λ(u,m) = βm

Different constant intensity for points of each type.

ppm(X ~marks + x) log λ((x, y),m) = βm + αx

Common spatial trend

Page 167: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks) log λ(u,m) = βm

Different constant intensity for points of each type.

ppm(X ~marks + x) log λ((x, y),m) = βm + αx

Common spatial trend

Different overall intensity for each type.

Page 168: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks) log λ(u,m) = βm

Different constant intensity for points of each type.

ppm(X ~marks + x) log λ((x, y),m) = βm + αx

Common spatial trend

Different overall intensity for each type.

ppm(X ~marks + x + marks:x)

Page 169: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks) log λ(u,m) = βm

Different constant intensity for points of each type.

ppm(X ~marks + x) log λ((x, y),m) = βm + αx

Common spatial trend

Different overall intensity for each type.

ppm(X ~marks + x + marks:x) equivalent to

ppm(X ~marks * x)

Page 170: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks) log λ(u,m) = βm

Different constant intensity for points of each type.

ppm(X ~marks + x) log λ((x, y),m) = βm + αx

Common spatial trend

Different overall intensity for each type.

ppm(X ~marks + x + marks:x) equivalent to

ppm(X ~marks * x) log λ((x, y),m) = βm + αmx

Page 171: Adrian Baddeley / Ege Rubak - spatstat

Fitting Poisson models

Spatial point patterns SSAI Course 2017 – 100

For a multitype point pattern:

COMMAND INTERPRETATION

ppm(X ~1) log λ(u,m) = β constant.

Equal intensity for points of each type.

ppm(X ~marks) log λ(u,m) = βm

Different constant intensity for points of each type.

ppm(X ~marks + x) log λ((x, y),m) = βm + αx

Common spatial trend

Different overall intensity for each type.

ppm(X ~marks + x + marks:x) equivalent to

ppm(X ~marks * x) log λ((x, y),m) = βm + αmx

Different spatial trends for each type

Page 172: Adrian Baddeley / Ege Rubak - spatstat

Segregation test

Spatial point patterns SSAI Course 2017 – 101

Likelihood ratio test of segregation in Lansing Woods data:

Page 173: Adrian Baddeley / Ege Rubak - spatstat

Segregation test

Spatial point patterns SSAI Course 2017 – 101

Likelihood ratio test of segregation in Lansing Woods data:

fit0 <- ppm(lansing ~marks + polynom(x,y,3))

fit1 <- ppm(lansing ~marks * polynom(x,y,3))

anova(fit0, fit1, test="Chi")

Page 174: Adrian Baddeley / Ege Rubak - spatstat

Segregation test

Spatial point patterns SSAI Course 2017 – 101

Likelihood ratio test of segregation in Lansing Woods data:

fit0 <- ppm(lansing ~marks + polynom(x,y,3))

fit1 <- ppm(lansing ~marks * polynom(x,y,3))

anova(fit0, fit1, test="Chi")

Analysis of Deviance Table

Model 1: ~marks + (x + y + I(x^2) + I(x * y) +

I(y^2) + I(x^3) + I(x^2 * y) + I(x * y^2) + I(y^3)) Poisson

Model 2: ~marks * (x + y + I(x^2) + I(x * y) +

I(y^2) + I(x^3) + I(x^2 * y) + I(x * y^2) + I(y^3)) Poisson

Npar Df Deviance Pr(>Chi)

1 15

2 60 45 612.57 < 2.2e-16 ***

Page 175: Adrian Baddeley / Ege Rubak - spatstat

Fitted intensity

Spatial point patterns SSAI Course 2017 – 102

fit1 <- ppm(lansing ~marks * polynom(x,y,3))

plot(predict(fit1))

predict(fit1)

blackoak hickory maple

misc redoak whiteoak

Page 176: Adrian Baddeley / Ege Rubak - spatstat

Inhomogeneous multitype K function

Spatial point patterns SSAI Course 2017 – 103

Inhomogeneous K function can be generalised to inhomogeneous multitype K function.fit1 <- ppm(lansing ~marks * polynom(x,y,3))

lamb <- predict(fit1)

plot(Kcross.inhom(lansing, "maple","hickory",

lamb$markmaple, lamb$markhickory))

0.00 0.05 0.10 0.15 0.20 0.25

0.0

00.0

50.1

00.1

50.2

0

r (one unit = 924 feet)

Kin

ho

m, m

ap

le, h

icko

ry(r

)

K^

inhom, maple, hickory

iso

(r)

K^

inhom, maple, hickory

trans

(r)

K^

inhom, maple, hickory

bord

(r)

K inhom, maple, hickory

pois (r)

Page 177: Adrian Baddeley / Ege Rubak - spatstat

Spatial point patterns SSAI Course 2017 – 104

Multitype Gibbs models

Page 178: Adrian Baddeley / Ege Rubak - spatstat

Conditional intensity

Spatial point patterns SSAI Course 2017 – 105

The conditional intensity λ(u,m | x) is essentially the conditional probability of finding a point of

type m at location u, given complete information about the rest of the process x.

u

Page 179: Adrian Baddeley / Ege Rubak - spatstat

Multitype Strauss process

Spatial point patterns SSAI Course 2017 – 106

> ppm(amacrine ~marks, Strauss(r=0.04))

Stationary Strauss process

First order terms:

beta_off beta_on

156.0724 162.1160

Interaction: Strauss process

interaction distance: 0.04

Fitted interaction parameter gamma: 0.4464

Page 180: Adrian Baddeley / Ege Rubak - spatstat

Multitype Strauss process

Spatial point patterns SSAI Course 2017 – 107

> rad <- matrix(c(0.03, 0.04, 0.04, 0.02), 2, 2)

> ppm(amacrine ~ marks,

MultiStrauss(radii=rad,types=c("off", "on")))

Stationary Multitype Strauss process

First order terms:

beta_off beta_on

120.2312 108.8413

Interaction radii:

off on

off 0.03 0.04

on 0.04 0.02

Fitted interaction parameters gamma_ij:

off on

off 0.0619 0.8786

on 0.8786 0.0000

Page 181: Adrian Baddeley / Ege Rubak - spatstat

Website

Spatial point patterns SSAI Course 2017 – 108

www.spatstat.org