Interpolation

HES 505 Fall 2024: Session 18

Carolyn Koehn

Assignment Revision 2…

  • Chance to revise assignments 6-7 - please note why you made changes/what the new code does

  • Switching projects in RStudio

Objectives

By the end of today you should be able to:

  • Distinguish deterministic and stochastic processes

  • Define autocorrelation and describe its estimation

  • Articulate the benefits and drawbacks of autocorrelation

  • Leverage point patterns and autocorrelation to interpolate missing data

But first…

Patterns as realizations of spatial processes

  • A spatial process is a description of how a spatial pattern might be generated

  • Generative models

  • An observed pattern as a possible realization of an hypothesized process

Deterministic vs. stochastic processes

  • Deterministic processes: always produce the same outcome

\[ z = 2x + 3y \]

  • Results in a spatially continuous field

Deterministic vs. stochastic processes

x <- rast(nrows = 10, ncols=10, xmin = 0, xmax=10, ymin = 0, ymax=10)
values(x) <- 1
z <- x
values(z) <- 2 * crds(x)[,1] + 3*crds(x)[,2]

Deterministic vs. stochastic processes

  • Stochastic processes: variation makes each realization difficult to predict

\[ z = 2x + 3y + d \]

  • The process is random, not the result (!!)
  • Measurement error makes deterministic processes appear stochastic
x <- rast(nrows = 10, ncols=10, xmin = 0, xmax=10, ymin = 0, ymax=10)
values(x) <- 1
fun <- function(z){
a <- z
d <- runif(ncell(z), -50,50)
values(a) <- 2 * crds(x)[,1] + 3*crds(x)[,2] + d
return(a)
}

b <- replicate(n=6, fun(z=x), simplify=FALSE)
d <- do.call(c, b)

Deterministic vs. stochastic processes

Expected values and hypothesis testing

  • Considering each outcome as the realization of a process allows us to generate expected values

  • The simplest spatial process is Completely Spatial Random (CSR) process

  • First Order effects: any event has an equal probability of occurring in a location

  • Second Order effects: the location of one event is independent of the other events

From Manuel Gimond

Generating expactations for CSR

  • We can use quadrat counts to estimate the expected number of events in a given area

  • The probability of each possible count is given by:

\[ P(n,k) = {n \choose x}p^k(1-p)^{n-k} \]

  • Given total coverage of quadrats, then \(p=\frac{\frac{a}{x}}{a}\) and

\[ \begin{equation} P(k,n,x) = {n \choose k}\bigg(\frac{1}{x}\bigg)^k\bigg(\frac{x-1}{x}\bigg)^{n-k} \end{equation} \]

Revisiting Ripley’s \(K\)

  • Probability is tied to quadrat size – we can improve estimates with a moving window

  • If points have independent, fixed marginal densities, then they exhibit complete, spatial randomness (CSR)

  • The K function is an alternative, based on a series of circles with increasing radius

\[ \begin{equation} K(d) = \lambda^{-1}E(N_d) \end{equation} \]

  • We can test for clustering by comparing to the expectation:

\[ \begin{equation} K_{CSR}(d) = \pi d^2 \end{equation} \]

  • if \(k(d) > K_{CSR}(d)\) then there is clustering at the scale defined by \(d\)

Ripley’s \(K\) Function

  • When working with a sample the distribution of \(K\) is unknown

  • Estimate with

\[ \begin{equation} \hat{K}(d) = \hat{\lambda}^{-1}\sum_{i=1}^n\sum_{j=1}^n\frac{I(d_{ij} <d)}{n(n-1)} \end{equation} \]

where:

\[ \begin{equation} \hat{\lambda} = \frac{n}{|A|} \end{equation} \]

Ripley’s \(K\) Function

Using the spatstat package

Ripley’s \(K\) Function

kf <- Kest(bramblecanes, correction-"border")
plot(kf)

Ripley’s \(K\) Function

  • accounting for variation in \(d\)
kf.env <- envelope(bramblecanes, correction="border", envelope = FALSE, verbose = FALSE)
plot(kf.env)

Other functions

  • \(L\) function: square root transformation of \(K\)

  • \(G\) function: the cumulative frequency distribution of the nearest neighbor distances

  • \(F\) function: similar to \(G\) but based on randomly located points

Tobler’s Law

‘everything is usually related to all else but those which are near to each other are more related when compared to those that are further away’.
Waldo Tobler

Spatial autocorrelation