spatial statistics - msijohnm/courses/r/asc2008/pdf/spatial-ohp.pdf · types of spatial data...

222
Spatial Statistics ASC Workshop 2008 – 1 Spatial Statistics Adrian Baddeley www.maths.uwa.edu.au/˜adrian CSIRO and University of Western Australia ASC Workshop Computing with R 2008

Upload: trankhue

Post on 19-Mar-2018

253 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 1

Spatial Statistics

Adrian Baddeleywww.maths.uwa.edu.au/˜adrian

CSIRO and University of Western Australia

ASC WorkshopComputing with R

2008

Page 2: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 2

Types of spatial data

Page 3: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Types of spatial data

Spatial Statistics ASC Workshop 2008 – 3

Three basic types of spatial data:

Page 4: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Types of spatial data

Spatial Statistics ASC Workshop 2008 – 3

Three basic types of spatial data:

� geostatistical

Page 5: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Types of spatial data

Spatial Statistics ASC Workshop 2008 – 3

Three basic types of spatial data:

� geostatistical

� regional

Page 6: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Types of spatial data

Spatial Statistics ASC Workshop 2008 – 3

Three basic types of spatial data:

� geostatistical

� regional

� point pattern

Page 7: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Geostatistical data

Spatial Statistics ASC Workshop 2008 – 4

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

Page 8: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Geostatistical data

Spatial Statistics ASC Workshop 2008 – 5

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

Page 9: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Regional data

Spatial Statistics ASC Workshop 2008 – 6

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

Page 10: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Point pattern data

Spatial Statistics ASC Workshop 2008 – 7

POINT PATTERN DATA:The main interest is in the locations of all occurrences of some event (e.g. tree deaths, meteoriteimpacts, robberies). Exact locations are recorded.

Page 11: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Points with marks

Spatial Statistics ASC Workshop 2008 – 8

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

Page 12: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Point pattern or geostatistical data?

Spatial Statistics ASC Workshop 2008 – 9

POINT PATTERN OR GEOSTATISTICAL DATA?

Page 13: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Explanatory vs. response variables

Spatial Statistics ASC Workshop 2008 – 10

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 14: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Point pattern or geostatistical data?

Spatial Statistics ASC Workshop 2008 – 11

Geostatistics treats the spatial locations as explanatory variables and the valuesattached to them as response variables.Spatial point pattern statistics treats the spatial locations, and the valuesattached to them, as the response.

Page 15: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Point pattern or geostatistical data?

Spatial Statistics ASC Workshop 2008 – 12

“Temperature is increasing as we move from South to North” — geostatistics“Trees become less abundant as we move from South to North” — point patternstatistics

Page 16: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 13

Software Overview

Page 17: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Software overview

Spatial Statistics ASC Workshop 2008 – 14

For information on spatial statistics software:

Page 18: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Software overview

Spatial Statistics ASC Workshop 2008 – 14

For information on spatial statistics software:

� go to cran.r-project.org

Page 19: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Software overview

Spatial Statistics ASC Workshop 2008 – 14

For information on spatial statistics software:

� go to cran.r-project.org

� find Task Views

Page 20: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Software overview

Spatial Statistics ASC Workshop 2008 – 14

For information on spatial statistics software:

� go to cran.r-project.org

� find Task Views --- Spatial

Page 21: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GIS software

Spatial Statistics ASC Workshop 2008 – 15

GIS = Geographical Information System

Page 22: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GIS software

Spatial Statistics ASC Workshop 2008 – 15

GIS = Geographical Information System

ArcInfo

Page 23: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GIS software

Spatial Statistics ASC Workshop 2008 – 15

GIS = Geographical Information System

ArcInfo proprietary esri.com

Page 24: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GIS software

Spatial Statistics ASC Workshop 2008 – 15

GIS = Geographical Information System

ArcInfo proprietary esri.com

GRASS open source grass.osgeo.org

Page 25: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS

Spatial Statistics ASC Workshop 2008 – 16

Page 26: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: Image data

Spatial Statistics ASC Workshop 2008 – 17

Page 27: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: Vector data

Spatial Statistics ASC Workshop 2008 – 18

Page 28: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: Regional data

Spatial Statistics ASC Workshop 2008 – 19

Page 29: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: Multiple data layers

Spatial Statistics ASC Workshop 2008 – 20

Page 30: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: Multiple data layers

Spatial Statistics ASC Workshop 2008 – 21

Page 31: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: Mixed layers

Spatial Statistics ASC Workshop 2008 – 22

Page 32: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: visualisation

Spatial Statistics ASC Workshop 2008 – 23

Page 33: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: Data integration

Spatial Statistics ASC Workshop 2008 – 24

Page 34: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: I mean really integrated

Spatial Statistics ASC Workshop 2008 – 25

Page 35: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: did I mention data integration

Spatial Statistics ASC Workshop 2008 – 26

Page 36: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: unbelievably well integrated

Spatial Statistics ASC Workshop 2008 – 27

Page 37: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS

Spatial Statistics ASC Workshop 2008 – 28

Page 38: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GRASS: runs on anything

Spatial Statistics ASC Workshop 2008 – 29

Page 39: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Recommendations

Spatial Statistics ASC Workshop 2008 – 30

Recommendations:

Page 40: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Recommendations

Spatial Statistics ASC Workshop 2008 – 30

Recommendations:

For visualisation of spatial data, especially for presentation

graphics, use a GIS.

Page 41: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Recommendations

Spatial Statistics ASC Workshop 2008 – 30

Recommendations:

For visualisation of spatial data, especially for presentation

graphics, use a GIS.

For statistical analysis of spatial data, use R.

Page 42: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Recommendations

Spatial Statistics ASC Workshop 2008 – 30

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 43: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Putting the pieces together

Spatial Statistics ASC Workshop 2008 – 31

RGIS

Page 44: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Putting the pieces together

Spatial Statistics ASC Workshop 2008 – 32

RGIS

Inte

rfac

e

Interface between R and GIS (online or offline)

Page 45: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Interfaces

Spatial Statistics ASC Workshop 2008 – 33

Direct interfaces between R and GIS:spgrass6 interface to GRASS 6

RArcInfo interface to ArcInfo

Page 46: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Interfaces

Spatial Statistics ASC Workshop 2008 – 33

Direct interfaces between R and GIS:spgrass6 interface to GRASS 6

RArcInfo interface to ArcInfo

Start R and GRASS independently; then start library(spgrass6) to establishcommunication

Page 47: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GIS data files

Spatial Statistics ASC Workshop 2008 – 34

Dominant formats for data files:ESRI “shapefiles” ArcInfo software esri.com

NetCDF Unidata GIS standard unidata.ucar.edu

Page 48: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GIS data files

Spatial Statistics ASC Workshop 2008 – 34

Dominant formats for data files:ESRI “shapefiles” ArcInfo software esri.com

NetCDF Unidata GIS standard unidata.ucar.edu

Libraries for reading/writing formats, etc:

GDAL geospatial data gdal.org

PROJ.4 map projections remotesensing.org

Page 49: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

GIS data files

Spatial Statistics ASC Workshop 2008 – 34

Dominant formats for data files:ESRI “shapefiles” ArcInfo software esri.com

NetCDF Unidata GIS standard unidata.ucar.edu

Libraries for reading/writing formats, etc:

GDAL geospatial data gdal.org

PROJ.4 map projections remotesensing.org

R packages handling GIS data files:

rgdal shapefiles, GDAL, PROJ.4

maps + mapproj map databases

Page 50: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Putting the pieces together

Spatial Statistics ASC Workshop 2008 – 35

RGIS

spatial

data

supportInte

rfac

e

Support for spatial data: data structures, classes, methods

Page 51: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

R packages supporting spatial data

Spatial Statistics ASC Workshop 2008 – 36

R packages supporting spatial data classes:

sp genericmaps polygon mapsspatstat point patterns

Page 52: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Putting the pieces together

Spatial Statistics ASC Workshop 2008 – 37

RGIS

analysis

spatial

data

supportInte

rfac

e

Capabilities for statistical analysis

Page 53: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Putting the pieces together

Spatial Statistics ASC Workshop 2008 – 38

RGIS

analysis

spatial

data

support

analysis

analysis

Inte

rfac

e

Multiple packages for different analyses

Page 54: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Statistical functionality

Spatial Statistics ASC Workshop 2008 – 39

R packages for geostatistical data

gstat classical geostatisticsgeoR model-based geostatisticsRandomFields stochastic processesakima interpolation

Page 55: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Statistical functionality

Spatial Statistics ASC Workshop 2008 – 39

R packages for geostatistical data

gstat classical geostatisticsgeoR model-based geostatisticsRandomFields stochastic processesakima interpolation

R packages for regional data

spdep spatial dependencespgwr geographically weighted regression

Page 56: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Statistical functionality

Spatial Statistics ASC Workshop 2008 – 39

R packages for geostatistical data

gstat classical geostatisticsgeoR model-based geostatisticsRandomFields stochastic processesakima interpolation

R packages for regional data

spdep spatial dependencespgwr geographically weighted regression

R packages for point patterns

spatstat parametric modelling, diagnosticssplancs nonparametric, space-time

Page 57: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 40

Geostatistical data

Page 58: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Software

Spatial Statistics ASC Workshop 2008 – 41

The R package gstat does classical geostatistics: kriging,variograms etc.

Page 59: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Maas River data

Spatial Statistics ASC Workshop 2008 – 42

> library(gstat)

Loading required package: sp

> data(meuse)

> class(meuse)

[1] "data.frame"

> names(meuse)

[1] "x" "y" "cadmium" "copper" "lead" "zinc" "elev"

[8] "dist" "om" "ffreq" "soil" "lime" "landuse" "dist.m"

Page 60: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Convert raw data to spatial class

Spatial Statistics ASC Workshop 2008 – 43

> coordinates(meuse) = ~x+y

> class(meuse)

[1] "SpatialPointsDataFrame"

attr(,"package")

[1] "sp"

Page 61: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Bubble plot

Spatial Statistics ASC Workshop 2008 – 44

> bubble(meuse, "zinc",

main="Zinc concentration (ppm)")

Zinc concentration

113198326674.51839

Page 62: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Pixel image

Spatial Statistics ASC Workshop 2008 – 45

> data(meuse.grid)

> coordinates(meuse.grid) = ~x+y

> gridded(meuse.grid) = TRUE

> class(meuse.grid)

[1] "SpatialPixelsDataFrame"

attr(,"package")

[1] "sp"

Page 63: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Pixel image

Spatial Statistics ASC Workshop 2008 – 46

> image(meuse.grid["dist"])

> title("distance to river")

distance to river

Page 64: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Naive Interpolation

Spatial Statistics ASC Workshop 2008 – 47

> zinc.idw = krige(zinc~1, meuse, meuse.grid)

[inverse distance weighted interpolation]

> class(zinc.idw)

[1] "SpatialPixelsDataFrame"

attr(,"package")

[1] "sp"

> spplot(zinc.idw["var1.pred"],

main = "Inverse distance weighted interpolations")

zinc inverse distance weighted interpolations

600

800

1000

1200

1400

1600

1800

Page 65: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 48

> plot(zinc ~ dist, meuse)

0.0 0.2 0.4 0.6 0.8

500

1000

1500

dist

zinc

Page 66: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Transformation

Spatial Statistics ASC Workshop 2008 – 49

> plot(log(zinc) ~ sqrt(dist), meuse)

> abline(lm(log(zinc) ~ sqrt(dist), meuse))

0.0 0.2 0.4 0.6 0.8

5.0

6.0

7.0

sqrt(dist)

log(

zinc

)

Page 67: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Variograms

Spatial Statistics ASC Workshop 2008 – 50

Variogram assuming constant mean:> lzn.vgm = variogram(log(zinc)~1, meuse)

> head(lzn.vgm)

np dist gamma dir.hor dir.ver id

1 57 79.29244 0.1234479 0 0 var1

2 299 163.97367 0.2162185 0 0 var1

3 419 267.36483 0.3027859 0 0 var1

> lzn.fit = fit.variogram(lzn.vgm, model = vgm(1, "Sph", 900, 1))

> lzn.fit

model psill range

1 Nug 0.05066243 0.0000

2 Sph 0.59060780 897.0209

> plot(lzn.vgm, lzn.fit)

sem

ivar

ianc

e

0.2

0.4

0.6

Page 68: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 51

distance

sem

ivar

ianc

e

0.2

0.4

0.6

500 1000 1500

Page 69: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Variograms

Spatial Statistics ASC Workshop 2008 – 52

Variogram of residuals from a fitted spatial trend:> lznr.vgm = variogram(log(zinc)~sqrt(dist), meuse)

> lznr.fit = fit.variogram(lznr.vgm, model = vgm(1, "Exp", 300, 1))

> lznr.fit

model psill range

1 Nug 0.05712231 0.0000

2 Exp 0.17641559 340.3201

> plot(lznr.vgm, lznr.fit)

distance

sem

ivar

ianc

e

0.05

0.10

0.15

0.20

0.25

500 1000 1500

Page 70: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 53

distance

sem

ivar

ianc

e

0.05

0.10

0.15

0.20

0.25

500 1000 1500

Page 71: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Kriging

Spatial Statistics ASC Workshop 2008 – 54

lzn.kriged = krige(log(zinc)~1, meuse, meuse.grid, model = lzn.fit)

spplot(lzn.kriged["var1.pred"])

5.0

5.5

6.0

6.5

7.0

7.5

Page 72: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Conditional simulation

Spatial Statistics ASC Workshop 2008 – 55

lzn.condsim = krige(log(zinc)~1, meuse, meuse.grid, model = lzn.fit,

nmax = 30, nsim = 4)

spplot(lzn.condsim, main = "four conditional simulations")

four conditional simulations

sim1 sim2

sim3 sim4

3

4

5

6

7

8

Page 73: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 56

Regional data

Page 74: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Software

Spatial Statistics ASC Workshop 2008 – 57

The R package spdep analyses regional data using neighbourhooddependence statistics.

Page 75: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Software

Spatial Statistics ASC Workshop 2008 – 58

> library(spdep)

Loading required package: sp

Loading required package: tripack

Loading required package: maptools

Loading required package: foreign

Loading required package: SparseM

Loading required package: boot

Page 76: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

North Carolina SIDS data

Spatial Statistics ASC Workshop 2008 – 59

> data(nc.sids)

> plot(sidspolys, forcefill=FALSE)

3234

3638

40

Page 77: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

p-value for each region

Spatial Statistics ASC Workshop 2008 – 60

pmap <- probmap(nc.sids$SID74, nc.sids$BIR74)

brks <- c(0,0.001,0.01,0.025,0.05,0.95,0.975,0.99,0.999,1)

cols <- rainbow(length(brks))

plot(sidspolys, col=cols[findInterval(pmap$pmap, brks)], forcefill=FALSE)

3234

3638

40

under 0.0010.001 − 0.010.01 − 0.0250.025 − 0.050.05 − 0.95

0.95 − 0.9750.975 − 0.990.99 − 0.999over 0.999

Page 78: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Neighbours

Spatial Statistics ASC Workshop 2008 – 61

Define which regions are immediate neighbours according to some criterion.coords <- nc.sids[, c("east", "north")]

gg <- gabrielneigh(coords)

nb <- graph2nb(gg)

3234

3638

40

Page 79: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Moran’s I

Spatial Statistics ASC Workshop 2008 – 62

An index of spatial autocorrelation:

I =n

∑i

∑j wij(yi − y)(yj − y)

(∑

i

∑j wij)(

∑i(yi − y)2)

where wij = 1 if sites i and j are neighbours, and 0 otherwise.

Page 80: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Weights

Spatial Statistics ASC Workshop 2008 – 63

Convert neighbourhood relations to weights wij between each pair of regions i, j.lw <- nb2listw(nb)

(Non-binary weights are possible too.)

Page 81: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Moran’s I

Spatial Statistics ASC Workshop 2008 – 64

> rates <- with(nc.sids, SID74/BIR74)

> moran.test(rates, listw=lw)

Moran’s I test under randomisation

data: rates

weights: lw

Moran I statistic standard deviate = 4.1051, p-value = 2.021e-05

alternative hypothesis: greater

sample estimates:

Moran I statistic Expectation Variance

0.222612195 -0.010101010 0.003213686

Page 82: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial correlogram

Spatial Statistics ASC Workshop 2008 – 65

> lmr <- lm(rates ~ 1, data=nc.sids, weights=BIR74)

> res <- sp.correlogram(nb, residuals(lmr), order=5, method="I")

> plot(res)

−0.

10.

00.

10.

20.

3

residuals(lmr)

lags

Mor

an’s

I

1 2 3 4 5

Page 83: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 66

Spatial point patterns

Page 84: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Software

Spatial Statistics ASC Workshop 2008 – 67

The R package spatstat supports statistical analysis for spatialpoint patterns.

Page 85: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Point patterns

Spatial Statistics ASC Workshop 2008 – 68

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 ofnew cases of influenza, galaxies, etc.

Page 86: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Marks

Spatial Statistics ASC Workshop 2008 – 69

The points may have extra information called marks attached to them. The mark represents an“attribute” of the point.

Page 87: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Marks

Spatial Statistics ASC Workshop 2008 – 69

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:

offon

Page 88: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Continuous marks

Spatial Statistics ASC Workshop 2008 – 70

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

Page 89: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Covariates

Spatial Statistics ASC Workshop 2008 – 71

Our dataset may also include covariates — any data that we treat as explanatory, rather than aspart of the ‘response’.Covariate data may be a spatial function Z(u) defined at all spatial locations u, e.g. altitude, soilpH, displayed as a pixel image or a contour plot:

120

130

140

150

160

125 125 130

130

130

130

135

135

135

140

140

140

145

145 150

150

155

Page 90: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Covariates

Spatial Statistics ASC Workshop 2008 – 72

Covariate data may be another spatial pattern such as another point pattern, or a line segmentpattern, e.g. a map of geological faults:

Page 91: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 73

Intensity

Page 92: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Intensity

Spatial Statistics ASC Workshop 2008 – 74

‘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 93: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Swedish Pines data

Spatial Statistics ASC Workshop 2008 – 75

> data(swedishpines)

> P <- swedishpines

> plot(P)

Page 94: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Quadrat counts

Spatial Statistics ASC Workshop 2008 – 76

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+

++

+

+

++

+

+

+

+

+

+

++

+

++++

+

+++

+

+

+

+

++

++

+

+

+

+

+

+

+++++

+

++

++

++

++

+

+

+

+

+

+

+

+++

+

+

+

++

++

+

+

5 6 11

8 11 9

8 6 7

Page 95: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

χ2 test of uniformity

Spatial Statistics ASC Workshop 2008 – 77

If the points have uniform intensity, and are completely random, then the quadrat counts should bePoisson random numbers with constant mean.

Page 96: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

χ2 test of uniformity

Spatial Statistics ASC Workshop 2008 – 77

If the points have uniform intensity, and are completely random, then the quadrat counts should bePoisson random numbers with constant mean.Use the χ2 goodness-of-fit test statistic

X2 =∑ (observed − expected)2

expected

Page 97: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

χ2 test of uniformity

Spatial Statistics ASC Workshop 2008 – 77

If the points have uniform intensity, and are completely random, then the quadrat counts should bePoisson 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 98: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

χ2 test of uniformity

Spatial Statistics ASC Workshop 2008 – 78

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

> plot(P)

> plot(QT, add=TRUE)

+

++

+

+

++

+

+

+

+

+

+

++

+

+

+++

+

+++

+

+

+

+

++

++

+

+

+

+

+

+

+

++++

+

++

++

++

++

+

+

+

+

+

+

+

+++

+

+

+

++

++

+

+

5 6 11

8 11 9

8 6 7

7.9 7.9 7.9

7.9 7.9 7.9

7.9 7.9 7.9

−1 −0.67 1.1

0.04 1.1 0.4

0.04 −0.67 −0.32

Page 99: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Kernel smoothing

Spatial Statistics ASC Workshop 2008 – 79

Kernel smoothed intensity

λ(u) =

n∑

i=1

κ(u − xi)

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

Page 100: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Kernel smoothing

Spatial Statistics ASC Workshop 2008 – 79

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 101: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Kernel smoothing

Spatial Statistics ASC Workshop 2008 – 79

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 chocolate2. melt chocolate with hair dryer

Page 102: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Kernel smoothing

Spatial Statistics ASC Workshop 2008 – 79

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 chocolate2. melt chocolate with hair dryer3. resulting landscape is a kernel smoothed estimate of intensity function

Page 103: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Kernel smoothing

Spatial Statistics ASC Workshop 2008 – 80

den <- density(P, sigma=15)

plot(den)

plot(P, add=TRUE)

0 20 40 60 80 100

020

4060

8010

0

0.00

40.

006

0.00

80.

010.

012+

+

+

+

+

+

+

+

+

+

+

+

+

++

+

+

++

+

+

+

++

+

+

+

+

++

+

+

+

+

+

+

+

+

+

+

+

++

+

++

+

+

++

++

+

+

+

+

+

+

+

+

+

+

+

+

+

++

++

+

+

Page 104: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Modelling intensity

Spatial Statistics ASC Workshop 2008 – 81

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 105: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Modelling intensity

Spatial Statistics ASC Workshop 2008 – 81

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 106: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Modelling intensity

Spatial Statistics ASC Workshop 2008 – 82

COMMAND INTENSITY

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

Page 107: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Modelling intensity

Spatial Statistics ASC Workshop 2008 – 82

COMMAND INTENSITY

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

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

Page 108: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Modelling intensity

Spatial Statistics ASC Workshop 2008 – 82

COMMAND INTENSITY

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

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

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

Page 109: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Modelling intensity

Spatial Statistics ASC Workshop 2008 – 82

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 110: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Swedish Pines data

Spatial Statistics ASC Workshop 2008 – 83

> ppm(P, ~1)

Stationary Poisson process

Uniform intensity: 0.007

Page 111: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Swedish Pines data

Spatial Statistics ASC Workshop 2008 – 84

> 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 112: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Modelling intensity

Spatial Statistics ASC Workshop 2008 – 85

COMMAND INTENSITY

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

Page 113: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Modelling intensity

Spatial Statistics ASC Workshop 2008 – 85

COMMAND INTENSITY

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

ppm(P, ~I(y > 18)) different constants above and belowthe line y = 18

Page 114: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitted intensity

Spatial Statistics ASC Workshop 2008 – 86

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 20 40 60 80 100

020

4060

8010

0

0.00

60.

007

0.00

80.

009

Page 115: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Likelihood ratio test

Spatial Statistics ASC Workshop 2008 – 87

fit0 <- ppm(P, ~1)

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

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

Page 116: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Likelihood ratio test

Spatial Statistics ASC Workshop 2008 – 87

fit0 <- ppm(P, ~1)

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

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

Model 1: .mpl.Y ~ 1

Model 2: .mpl.Y ~ polynom(x, y, 5)

Resid. Df Resid. Dev Df Deviance P(>|Chi|)

1 699 408.10

2 694 400.62 5 7.48 0.19

Page 117: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Likelihood ratio test

Spatial Statistics ASC Workshop 2008 – 87

fit0 <- ppm(P, ~1)

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

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

Model 1: .mpl.Y ~ 1

Model 2: .mpl.Y ~ polynom(x, y, 5)

Resid. Df Resid. Dev Df Deviance P(>|Chi|)

1 699 408.10

2 694 400.62 5 7.48 0.19

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

Page 118: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Residuals

Spatial Statistics ASC Workshop 2008 – 88

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

Smoothed raw residuals

−0.003

−0.002

−0.002

−0.001

−0.001

0

0

0.001 0.001

0.002

0.002

0.003

0.0

04

0.0

05

Page 119: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 89

Spatial covariates

Page 120: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial covariates

Spatial Statistics ASC Workshop 2008 – 90

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

Page 121: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial covariates

Spatial Statistics ASC Workshop 2008 – 90

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

� geographical coordinates

Page 122: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial covariates

Spatial Statistics ASC Workshop 2008 – 90

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

� geographical coordinates� terrain altitude

Page 123: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial covariates

Spatial Statistics ASC Workshop 2008 – 90

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

� geographical coordinates� terrain altitude� soil pH

Page 124: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial covariates

Spatial Statistics ASC Workshop 2008 – 90

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 125: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial covariates

Spatial Statistics ASC Workshop 2008 – 90

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

� geographical coordinates� terrain altitude� soil pH� distance from location u to another feature

120

130

140

150

160

125 125 130

130

130

130

135

135

135

140

140

140

145

145 150

150

155

Page 126: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Covariates

Spatial Statistics ASC Workshop 2008 – 91

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

Page 127: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Covariate effects

Spatial Statistics ASC Workshop 2008 – 92

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 128: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example: Queensland copper data

Spatial Statistics ASC Workshop 2008 – 93

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 thecopper deposits are hard to find.

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

Page 129: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Copper data

Spatial Statistics ASC Workshop 2008 – 94

data(copper)

P <- copper$SouthPoints

Y <- copper$SouthLines

plot(P)

plot(Y, add=TRUE)

++

+++ +

++

++ +

+ +

+ +

+ +

+

+ +++

+++ ++

+

+

+

++

++++

+

++

+

+

+ ++ ++ +

++ +

+

+

++

+

++

Page 130: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Copper data

Spatial Statistics ASC Workshop 2008 – 95

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

Page 131: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Copper data

Spatial Statistics ASC Workshop 2008 – 95

For analysis, we need a value Z(u) defined at each location u.Example: Z(u) = distance from u to nearest line.

Page 132: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Copper data

Spatial Statistics ASC Workshop 2008 – 95

For analysis, we need a value Z(u) defined at each location u.Example: Z(u) = distance from u to nearest line.D <- distmap(Y)

plot(D)

Z

−150 −100 −50 0

010

2030

02

46

810

Page 133: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Lurking variable plot

Spatial Statistics ASC Workshop 2008 – 96

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

Page 134: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Lurking variable plot

Spatial Statistics ASC Workshop 2008 – 96

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 135: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Lurking variable plot

Spatial Statistics ASC Workshop 2008 – 96

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 136: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Lurking variable plot

Spatial Statistics ASC Workshop 2008 – 96

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 137: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Lurking variable plot

Spatial Statistics ASC Workshop 2008 – 96

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

010

0020

0030

0040

0050

00

distance to nearest line

prob

abili

ty

Page 138: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Kolmogorov-Smirnov test

Spatial Statistics ASC Workshop 2008 – 97

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

Page 139: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Kolmogorov-Smirnov test

Spatial Statistics ASC Workshop 2008 – 97

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 140: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Copper data

Spatial Statistics ASC Workshop 2008 – 98

D <- distmap(Y)

ppm(P, ~Z, covariates=list(Z=D))

Fits the modellog λ(u) = β0 + β1Z(u)

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

Page 141: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Copper data

Spatial Statistics ASC Workshop 2008 – 99

D <- distmap(Y)

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

Page 142: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Copper data

Spatial Statistics ASC Workshop 2008 – 100

fit <- ppm(P, ~polynom(Z,5), covariates=list(Z=D))

plot(predict(fit))

−150 −100 −50 0

010

2030

40

00.

005

0.01

0.01

5

Page 143: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Copper data

Spatial Statistics ASC Workshop 2008 – 101

Dr <- summary(D)$range

Dvalues <- seq(Dr[1], Dr[2], length=100)

fakeZ <- data.frame(Z=Dvalues)

fakexy <- data.frame(x=rep(0,100), y=rep(0,100))

lambda <- predict(fit, locations=fakexy, covariates=fakeZ)

plot(Dvalues, lambda, type="l")plots fitted curve of λ against Z .

Page 144: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Copper data

Spatial Statistics ASC Workshop 2008 – 102

0 2 4 6 8 10

0.00

00.

005

0.01

00.

015

distance to nearest line

inte

nsity

Page 145: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Likelihood ratio test

Spatial Statistics ASC Workshop 2008 – 103

fit0 <- ppm(P, ~1)

fit1 <- ppm(P, ~polynom(Z,5), covariates=list(Z=D))

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

Page 146: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Likelihood ratio test

Spatial Statistics ASC Workshop 2008 – 103

fit0 <- ppm(P, ~1)

fit1 <- ppm(P, ~polynom(Z,5), covariates=list(Z=D))

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

Model 1: .mpl.Y ~ 1

Model 2: .mpl.Y ~ polynom(Z, 5)

Resid. Df Resid. Dev Df Deviance P(>|Chi|)

1 682 372.32

2 677 370.04 5 2.28 0.81

Page 147: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Likelihood ratio test

Spatial Statistics ASC Workshop 2008 – 103

fit0 <- ppm(P, ~1)

fit1 <- ppm(P, ~polynom(Z,5), covariates=list(Z=D))

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

Model 1: .mpl.Y ~ 1

Model 2: .mpl.Y ~ polynom(Z, 5)

Resid. Df Resid. Dev Df Deviance P(>|Chi|)

1 682 372.32

2 677 370.04 5 2.28 0.81

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

Page 148: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Interaction

Spatial Statistics ASC Workshop 2008 – 104

‘Interpoint interaction’ is stochastic dependence between the points in a point pattern. Usually weexpect dependence to be strongest between points that are close to one another.

independent regular clustered

Page 149: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 105

Example: spacing between points in Swedish Pines data

swedishpines

Page 150: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 106

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

swedishpines

Page 151: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 107

Summary approach:

Page 152: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 107

Summary approach:

1. calculate average nearest-neighbour distance

Page 153: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 107

Summary approach:

1. calculate average nearest-neighbour distance2. divide by the value expected for a completely random pattern.

Clark & Evans (1954)

Page 154: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 107

Summary approach:

1. calculate average nearest-neighbour distance2. 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 155: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 107

Summary approach:

1. calculate average nearest-neighbour distance2. 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 156: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 108

Exploratory approach:

Page 157: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 108

Exploratory approach:

� plot NND for each point

P <- swedishpines

marks(P) <- nndist(P)

plot(P, markscale=0.5)

Page 158: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 109

Exploratory approach:

� plot NND for each point

Page 159: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 109

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)

Page 160: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 110

Modelling approach:

Page 161: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 110

Modelling approach:

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

Page 162: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example

Spatial Statistics ASC Workshop 2008 – 110

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 163: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Example: Japanese pines

Spatial Statistics ASC Workshop 2008 – 111

Locations of 65 saplings of Japanese pine in a 5.7 × 5.7 metre square sampling region in a naturalstand.data(japanesepines)

J <- japanesepines

plot(J)

Japanese Pines

Page 164: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Japanese Pines

Spatial Statistics ASC Workshop 2008 – 112

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

plot(predict(fit))

plot(J, add=TRUE)

predict(fit)

0.0 0.2 0.4 0.6 0.8 1.0

0.0

0.2

0.4

0.6

0.8

1.0

5010

015

020

0

Page 165: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Adjusting for inhomogeneity

Spatial Statistics ASC Workshop 2008 – 113

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 166: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Inhomogeneous K-function

Spatial Statistics ASC Workshop 2008 – 114

lam <- predict(fit)

plot(Kinhom(J, lam))

0.00 0.05 0.10 0.15 0.20 0.25

0.00

0.05

0.10

0.15

0.20

Kinhom(J, lam)

r (one unit = 5.7 metres)

Kin

hom

(r)

Page 167: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Conditional intensity

Spatial Statistics ASC Workshop 2008 – 115

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, givencomplete information about the rest of the process x.

u

Page 168: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Strauss process

Spatial Statistics ASC Workshop 2008 – 116

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

Page 169: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Gibbs models

Spatial Statistics ASC Workshop 2008 – 117

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

Page 170: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Gibbs models

Spatial Statistics ASC Workshop 2008 – 117

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

data(swedishpines)

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

Page 171: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Gibbs models

Spatial Statistics ASC Workshop 2008 – 117

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 172: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Gibbs models

Spatial Statistics ASC Workshop 2008 – 118

The model can include both spatial trend and interpoint interaction.

Page 173: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Gibbs models

Spatial Statistics ASC Workshop 2008 – 118

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

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

Page 174: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Gibbs models

Spatial Statistics ASC Workshop 2008 – 118

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 175: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Plotting a fitted model

Spatial Statistics ASC Workshop 2008 – 119

When we plot or predict a fitted Gibbs model, the first order trend β(u) and/or the conditionalintensity λ(u | x) are plotted.fit <- ppm(japanesepines, ~x, Strauss(r=0.1))

plot(predict(fit))

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

0.0 0.2 0.4 0.6 0.8 1.0

0.0

0.2

0.4

0.6

0.8

1.0

6869

7071

7273

predict(fit, type = "cif")

0.0 0.2 0.4 0.6 0.8 1.0

0.0

0.2

0.4

0.6

0.8

1.0

3040

5060

70

Page 176: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Simulating the fitted model

Spatial Statistics ASC Workshop 2008 – 120

A fitted Gibbs model can be simulated automatically using the Metropolis-Hastings algorithm (whichonly requires the conditional intensity).

Page 177: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Simulating the fitted model

Spatial Statistics ASC Workshop 2008 – 120

A fitted Gibbs model can be simulated automatically using the Metropolis-Hastings algorithm (whichonly requires the conditional intensity).fit <- ppm(swedishpines, ~1, Strauss(r=7))

Xsim <- rmh(fit)

plot(Xsim)

Page 178: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Simulating the fitted model

Spatial Statistics ASC Workshop 2008 – 120

A fitted Gibbs model can be simulated automatically using the Metropolis-Hastings algorithm (whichonly requires the conditional intensity).fit <- ppm(swedishpines, ~1, Strauss(r=7))

Xsim <- rmh(fit)

plot(Xsim)

Xsim

Page 179: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Simulation-based tests

Spatial Statistics ASC Workshop 2008 – 121

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

)

Page 180: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Diagnostics

Spatial Statistics ASC Workshop 2008 – 122

More powerful diagnostics are available.diagnose.ppm(fit)

−0.004

−0.004

−0.004 −0.004

−0.002

−0.002

−0.002

0

0

0

0.002

0.002

0.0

02

0.004

0.004

0.0

06

0 20 40 60 80 100

−8

−6

−4

−2

02

4

cum

ulat

ive

sum

of r

aw r

esid

uals

020

4060

8010

0

y co

ordi

nate

8 6 4 2 0 −2 −4 −6

cumulative sum of raw residuals

Page 181: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 123

Marks

Page 182: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Marks

Spatial Statistics ASC Workshop 2008 – 124

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

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

case/control, species, colour)

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

Page 183: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 125

Categorical marks

Page 184: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Categorical marks

Spatial Statistics ASC Workshop 2008 – 126

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

Page 185: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Multitype point patterns

Spatial Statistics ASC Workshop 2008 – 127

summary(amacrine)

Page 186: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Multitype point patterns

Spatial Statistics ASC Workshop 2008 – 127

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 187: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Intensity of multitype patterns

Spatial Statistics ASC Workshop 2008 – 128

plot(split(amacrine))

split(amacrine)

off on

Page 188: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Intensity of multitype patterns

Spatial Statistics ASC Workshop 2008 – 129

data(lansing)

summary(lansing)

plot(lansing)

lansing

Page 189: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Intensity of multitype patterns

Spatial Statistics ASC Workshop 2008 – 130

“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 190: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Intensity of multitype patterns

Spatial Statistics ASC Workshop 2008 – 131

Let λ(u, m) be the intensity function for points of type m at location u. This can be estimated bykernel smoothing the data points of type m.plot(density(split(lansing)))

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2

blackoak

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2

hickory

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2

maple

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2

misc

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2

redoak

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2

whiteoak

Page 191: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Segregation

Spatial Statistics ASC Workshop 2008 – 132

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 192: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Segregation

Spatial Statistics ASC Workshop 2008 – 133

D <- density(lansing)

Y <- density(split(lansing))

Dblackoak <- Y$blackoak

pBlackoak <- eval.im(Dblackoak/D)

plot(pBlackoak)pBlackoak

0.0 0.2 0.4 0.6 0.8 1.0

0.0

0.2

0.4

0.6

0.8

1.0

0.05

0.1

0.15

Page 193: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 134

Interaction between types

Page 194: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Interaction between types

Spatial Statistics ASC Workshop 2008 – 135

In a multitype point pattern, there may be interaction between the points of different types, orbetween points of the same type.

amacrine

Page 195: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Bivariate G-function

Spatial Statistics ASC Workshop 2008 – 136

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 196: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Bivariate G-function

Spatial Statistics ASC Workshop 2008 – 137

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)

Gcr

oss[

"on"

, "of

f"](

r)

Page 197: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Bivariate G-function

Spatial Statistics ASC Workshop 2008 – 138

plot(alltypes(amacrine, Gcross))

0.00 0.01 0.02 0.03 0.04 0.05 0.06

0.0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

r (one unit = 662 microns)

km ,

rs ,

theo

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)

km ,

rs ,

theo

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)

km ,

rs ,

theo

0.00 0.01 0.02 0.03 0.04 0.05 0.06

0.0

0.2

0.4

0.6

r (one unit = 662 microns)

km ,

rs ,

theo

off onof

fon

array of Gcross function for amacrine.

Page 198: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

For a multitype point pattern:COMMAND INTERPRETATION

Page 199: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

For a multitype point pattern:COMMAND INTERPRETATION

ppm(X, ~1)

Page 200: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

For a multitype point pattern:COMMAND INTERPRETATION

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

Page 201: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

For a multitype point pattern:COMMAND INTERPRETATION

ppm(X, ~1) log λ(u, m) = β constant.Equal intensity for points of each type.

Page 202: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 203: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 204: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 205: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 206: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 207: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 208: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 trendDifferent overall intensity for each type.

Page 209: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 trendDifferent overall intensity for each type.

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

Page 210: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 trendDifferent overall intensity for each type.

ppm(X, ~marks + x + marks:x) equivalent toppm(X, ~marks * x)

Page 211: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 trendDifferent overall intensity for each type.

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

Page 212: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitting Poisson models

Spatial Statistics ASC Workshop 2008 – 139

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 trendDifferent overall intensity for each type.

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

Different spatial trends for each type

Page 213: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Segregation test

Spatial Statistics ASC Workshop 2008 – 140

Likelihood ratio test of segregation in Lansing Woods data:

Page 214: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Segregation test

Spatial Statistics ASC Workshop 2008 – 140

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 215: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Segregation test

Spatial Statistics ASC Workshop 2008 – 140

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: .mpl.Y ~ marks + polynom(x, y, 3)

Model 2: .mpl.Y ~ marks * polynom(x, y, 3)

Resid. Df Resid. Dev Df Deviance P(>|Chi|)

1 73515 17485.0

2 73470 16872.4 45 612.6 1.226e-100

Page 216: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Fitted intensity

Spatial Statistics ASC Workshop 2008 – 141

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

plot(predict(fit1))

predict(fit1)

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2 markblackoak

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2 markhickory

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2 markmaple

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2 markmisc

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2 markredoak

0.0 0.2 0.4 0.6 0.8 1.0

−0.

20.

00.

20.

40.

60.

81.

01.

2 markwhiteoak

Page 217: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Inhomogeneous multitype K function

Spatial Statistics ASC Workshop 2008 – 142

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.00

0.05

0.10

0.15

0.20

r (one unit = 924 feet)

Kcr

oss.

inho

m["

map

le",

"hi

ckor

y"](

r)

Page 218: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Spatial Statistics ASC Workshop 2008 – 143

Multitype Gibbs models

Page 219: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Conditional intensity

Spatial Statistics ASC Workshop 2008 – 144

The conditional intensity λ(u, m | x) is essentially the conditional probability of finding a point oftype m at location u, given complete information about the rest of the process x.

u

Page 220: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Multitype Strauss process

Spatial Statistics ASC Workshop 2008 – 145

> 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 221: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Multitype Strauss process

Spatial Statistics ASC Workshop 2008 – 146

> 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 222: Spatial Statistics - MSIjohnm/courses/r/ASC2008/pdf/spatial-ohp.pdf · Types of spatial data Spatial Statistics ASC Workshop 2008 – 3 Three basic types of spatial data: geostatistical

Website

Spatial Statistics ASC Workshop 2008 – 147

www.spatstat.org