advanced r course on spatial point patterns
play

Advanced R course on spatial point patterns Adrian Baddeley / Ege - PowerPoint PPT Presentation

Advanced R course on spatial point patterns Adrian Baddeley / Ege Rubak Curtin University / Aalborg University SSAI 2017 Spatial point patterns SSAI Course 2017 1 Plan of Workshop 1. Introduction 2. Inhomogeneous Intensity 3.


  1. Intensity ‘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’). inhomogeneous uniform Spatial point patterns SSAI Course 2017 – 35

  2. Swedish Pines data > data(swedishpines) > P <- swedishpines > plot(P) Spatial point patterns SSAI Course 2017 – 36

  3. Quadrat counts Divide study region into rectangles (‘quadrats’) of equal size, and count points in each rectangle. Q <- quadratcount(P, nx=3, ny=3) Q plot(Q, add=TRUE) P + + + + + + + 8 6 7 + + + + + + + + + + + + + + + ++ + + + + + + + + + + + 8 11 9 + + + + + + + + + + + + + + + + + + + + + + + + 5 6 11 + + + + + + + + + + + + Spatial point patterns SSAI Course 2017 – 37

  4. χ 2 test of uniformity If the points have uniform intensity, and are completely random, then the quadrat counts should be Poisson random numbers with constant mean. Spatial point patterns SSAI Course 2017 – 38

  5. χ 2 test of uniformity If the points have uniform intensity, and are completely random, then the quadrat counts should be Poisson random numbers with constant mean. Use the χ 2 goodness-of-fit test statistic � ( observed − expected ) 2 X 2 = expected Spatial point patterns SSAI Course 2017 – 38

  6. χ 2 test of uniformity If the points have uniform intensity, and are completely random, then the quadrat counts should be Poisson random numbers with constant mean. Use the χ 2 goodness-of-fit test statistic � ( observed − expected ) 2 X 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 Spatial point patterns SSAI Course 2017 – 38

  7. χ 2 test of uniformity > QT <- quadrat.test(P, nx=3, ny=3) > plot(P) > plot(QT, add=TRUE) 8 7.9 6 7.9 7 7.9 0.04 −0.67 −0.32 8 7.9 11 7.9 9 7.9 0.04 1.1 0.4 5 7.9 6 7.9 11 7.9 −0.67 −1 1.1 Spatial point patterns SSAI Course 2017 – 39

  8. Kernel smoothing Kernel smoothed intensity n � � λ ( u ) = κ ( u − x i ) i =1 where κ ( u ) is the kernel function and x 1 , . . . , x n are the data points. Spatial point patterns SSAI Course 2017 – 40

  9. Kernel smoothing Kernel smoothed intensity n � � λ ( u ) = κ ( u − x i ) i =1 where κ ( u ) is the kernel function and x 1 , . . . , x n are the data points. 1. replace each data point by a square of chocolate Spatial point patterns SSAI Course 2017 – 40

  10. Kernel smoothing Kernel smoothed intensity n � � λ ( u ) = κ ( u − x i ) i =1 where κ ( u ) is the kernel function and x 1 , . . . , x n are the data points. 1. replace each data point by a square of chocolate 2. melt chocolate with hair dryer Spatial point patterns SSAI Course 2017 – 40

  11. Kernel smoothing Kernel smoothed intensity n � � λ ( u ) = κ ( u − x i ) i =1 where κ ( u ) is the kernel function and x 1 , . . . , x n are the data points. 1. replace each data point by a square of chocolate 2. melt chocolate with hair dryer 3. resulting landscape is a kernel smoothed estimate of intensity function Spatial point patterns SSAI Course 2017 – 40

  12. Kernel smoothing den <- density(P, sigma=15) plot(den) plot(P, add=TRUE) + + 0.012 + + + + + + + + + + + + + + + 0.01 + + + + + + + + + + + + ++ + + + + 0.008 + + + + + + + + + + + + + + + + 0.006 + + ++ + + + + + + + + + + + ++ + 0.004 + + Spatial point patterns SSAI Course 2017 – 41

  13. Modelling intensity 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 ) . Spatial point patterns SSAI Course 2017 – 42

  14. Modelling intensity 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”. Spatial point patterns SSAI Course 2017 – 42

  15. Modelling intensity C OMMAND I NTENSITY log λ ( u ) = β 0 ppm(P ~1) Spatial point patterns SSAI Course 2017 – 43

  16. Modelling intensity C OMMAND I NTENSITY log λ ( u ) = β 0 ppm(P ~1) β 0 , β 1 , . . . denote parameters to be estimated. Spatial point patterns SSAI Course 2017 – 43

  17. Modelling intensity C OMMAND I NTENSITY log λ ( u ) = β 0 ppm(P ~1) log λ (( x, y )) = β 0 + β 1 x ppm(P ~x) β 0 , β 1 , . . . denote parameters to be estimated. Spatial point patterns SSAI Course 2017 – 43

  18. Modelling intensity C OMMAND I NTENSITY log λ ( u ) = β 0 ppm(P ~1) log λ (( x, y )) = β 0 + β 1 x ppm(P ~x) log λ (( x, y )) = β 0 + β 1 x + β 2 y ppm(P ~x + y) β 0 , β 1 , . . . denote parameters to be estimated. Spatial point patterns SSAI Course 2017 – 43

  19. Swedish Pines data > ppm(P ~1) Stationary Poisson process Uniform intensity: 0.007 Spatial point patterns SSAI Course 2017 – 44

  20. Swedish Pines data > 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 Spatial point patterns SSAI Course 2017 – 45

  21. Modelling intensity C OMMAND I NTENSITY exp (3rd order polynomial in x and y ) ppm(P ~polynom(x,y,3)) Spatial point patterns SSAI Course 2017 – 46

  22. Modelling intensity C OMMAND I NTENSITY exp (3rd order polynomial in x and y ) ppm(P ~polynom(x,y,3)) ppm(P ~I(y > 18)) different constants above and below the line y = 18 Spatial point patterns SSAI Course 2017 – 46

  23. Fitted intensity 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.009 0.008 0.007 0.006 Spatial point patterns SSAI Course 2017 – 47

  24. Likelihood ratio test fit0 <- ppm(P ~1) fit1 <- ppm(P ~polynom(x,y,2)) anova(fit0, fit1, test="Chi") Spatial point patterns SSAI Course 2017 – 48

  25. Likelihood ratio test fit0 <- ppm(P ~1) fit1 <- ppm(P ~polynom(x,y,2)) anova(fit0, fit1, test="Chi") Analysis of Deviance Table Model 1: ~1 Poisson Model 2: ~x + y + I(x^2) + I(x * y) + I(y^2) Poisson Npar Df Deviance Pr(>Chi) 1 1 2 6 5 7.4821 0.1872 Spatial point patterns SSAI Course 2017 – 48

  26. Likelihood ratio test fit0 <- ppm(P ~1) fit1 <- ppm(P ~polynom(x,y,2)) anova(fit0, fit1, test="Chi") Analysis of Deviance Table Model 1: ~1 Poisson Model 2: ~x + y + I(x^2) + I(x * y) + I(y^2) Poisson Npar Df Deviance Pr(>Chi) 1 1 2 6 5 7.4821 0.1872 The p -value 0 . 19 exceeds 0 . 05 so the log-quadratic spatial trend is not significant . Spatial point patterns SSAI Course 2017 – 48

  27. Residuals diagnose.ppm(fit0, which="smooth") Smoothed raw residuals −0.002 0.002 −0.001 0 0.001 0.001 0 −0.001 0.002 − 0 . 0 0.003 0 3 4 0 0 . 0 5 −0.002 0 0 . 0 Spatial point patterns SSAI Course 2017 – 49

  28. Spatial covariates Spatial point patterns SSAI Course 2017 – 50

  29. Spatial covariates A spatial covariate is a function Z ( u ) of spatial location. Spatial point patterns SSAI Course 2017 – 51

  30. Spatial covariates A spatial covariate is a function Z ( u ) of spatial location. geographical coordinates � Spatial point patterns SSAI Course 2017 – 51

  31. Spatial covariates A spatial covariate is a function Z ( u ) of spatial location. geographical coordinates � terrain altitude � Spatial point patterns SSAI Course 2017 – 51

  32. Spatial covariates A spatial covariate is a function Z ( u ) of spatial location. geographical coordinates � terrain altitude � soil pH � Spatial point patterns SSAI Course 2017 – 51

  33. Spatial covariates A spatial covariate is a function Z ( u ) of spatial location. geographical coordinates � terrain altitude � soil pH � distance from location u to another feature � Spatial point patterns SSAI Course 2017 – 51

  34. Spatial covariates A spatial covariate is a function Z ( u ) of spatial location. geographical coordinates � terrain altitude � soil pH � distance from location u to another feature � 140 130 145 150 145 140 1 5 5 150 135 130 3 0 125 1 1 3 5 125 140 130 5 3 1 Spatial point patterns SSAI Course 2017 – 51

  35. Covariates Covariate data may be another spatial pattern such as another point pattern, or a line segment pattern: Spatial point patterns SSAI Course 2017 – 52

  36. Covariate effects 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 Spatial point patterns SSAI Course 2017 – 53

  37. Example: Queensland copper data A intensive mineralogical survey yields a map of copper deposits (essentially pointlike at this scale) and geological faults (straight lines). The faults can easily be observed from satellites, but the copper deposits are hard to find. Main question: whether the faults are ‘predictive’ for copper deposits (e.g. copper less/more likely to be found near faults). Spatial point patterns SSAI Course 2017 – 54

  38. Copper data data(copper) P <- copper$SouthPoints Y <- copper$SouthLines plot(P) plot(Y, add=TRUE) + + ++ + + + +++ + + ++ + + + + + + + + ++ + + + ++ + + ++ + + + + + + + + + + + + + + + + ++ + + + + + + Spatial point patterns SSAI Course 2017 – 55

  39. Copper data For analysis, we need a value Z ( u ) defined at each location u . Spatial point patterns SSAI Course 2017 – 56

  40. Copper data For analysis, we need a value Z ( u ) defined at each location u . Example: Z ( u ) = distance from u to nearest line. Spatial point patterns SSAI Course 2017 – 56

  41. Copper data For analysis, we need a value Z ( u ) defined at each location u . Example: Z ( u ) = distance from u to nearest line. Z <- distmap(Y) plot(Z) Z 10 8 6 4 2 Spatial point patterns SSAI Course 2017 – 56

  42. Lurking variable plot We want to determine whether intensity depends on a spatial covariate Z . Spatial point patterns SSAI Course 2017 – 57

  43. Lurking variable plot We want to determine whether intensity depends on a spatial covariate Z . Plot C ( z ) against z , where C ( z ) = fraction of data points x i for which Z ( x i ) ≤ z . Spatial point patterns SSAI Course 2017 – 57

  44. Lurking variable plot We want to determine whether intensity depends on a spatial covariate Z . Plot C ( z ) against z , where C ( z ) = fraction of data points x i for which Z ( x i ) ≤ z . Also plot C 0 ( z ) against z , where C 0 ( z ) = fraction of area of study region where Z ( u ) ≤ z . Spatial point patterns SSAI Course 2017 – 57

  45. Lurking variable plot We want to determine whether intensity depends on a spatial covariate Z . Plot C ( z ) against z , where C ( z ) = fraction of data points x i for which Z ( x i ) ≤ z . Also plot C 0 ( z ) against z , where C 0 ( z ) = fraction of area of study region where Z ( u ) ≤ z . lurking(ppm(P), Z) Spatial point patterns SSAI Course 2017 – 57

  46. Lurking variable plot We want to determine whether intensity depends on a spatial covariate Z . Plot C ( z ) against z , where C ( z ) = fraction of data points x i for which Z ( x i ) ≤ z . Also plot C 0 ( z ) against z , where C 0 ( z ) = fraction of area of study region where Z ( u ) ≤ z . lurking(ppm(P), Z) 5000 4000 probability 3000 2000 1000 0 0 2 4 6 8 10 distance to nearest line Spatial point patterns SSAI Course 2017 – 57

  47. Kolmogorov-Smirnov test Formal test of agreement between C ( z ) and C 0 ( z ) . Spatial point patterns SSAI Course 2017 – 58

  48. Kolmogorov-Smirnov test Formal test of agreement between C ( z ) and C 0 ( 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 Spatial point patterns SSAI Course 2017 – 58

  49. Copper data Z <- distmap(Y) ppm(P ~ Z) Fits the model log λ ( u ) = β 0 + β 1 Z ( u ) where Z ( u ) is the distance from u to the nearest line segment. Spatial point patterns SSAI Course 2017 – 59

  50. Copper data Z <- distmap(Y) ppm(P ~ polynom(Z,5)) fits a model in which log λ ( u ) is a 5th order polynomial function of Z ( u ) . Spatial point patterns SSAI Course 2017 – 60

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend