This session covers modelling of marked point patterns using marked point processes.

The lecturer’s R script is available here (right click and save).

The dataset `spruces`

contains the Norwegian Spruces dataset giving the locations of trees and their diameters at breast height.

Read the help file for the data;

access the dataset and plot it;

re-plot the data so that the tree diameters are displayed at a physical scale that is 10 times the physical scale of the location coordinates.

use

`Smooth`

(notice the upper case S) to compute and plot a pixel image of the local average tree diameter;trees are normally classified as ‘adult’ when their diameter exceeds 30 centimetres. Use the

`cut`

command to classify each tree as adult or juvenile, and produce a multitype point pattern in which the trees are marked as adult or juvenile. Plot this pattern, and plot the adults and juveniles separately.

The file `anthills.txt`

is available in the Data directory on github and downloadable by this direct link (right click and save).

It records the locations of anthills recorded in a 1200x1500 metre study region in northern Australia. Coordinates are given in metres, along with a letter code recording the ecological ‘status’ of each anthill.

read the data into

`R`

as a data frame, using the`R`

function`read.table`

. (Since the input file has a header line, you will need to use the argument`header=TRUE`

when you call`read.table`

.)check the data for any peculiarities.

create a point pattern

`hills`

containing these data. Ensure that the marks are a factor, and that the unit of length is given its correct name.plot the data.

The dataset `hamster`

is a multitype pattern representing the locations of cells of two types, *dividing* and *pyknotic*.

plot the data;

plot the patterns of pyknotic and dividing cells separately;

plot kernel estimates of the intensity functions of pyknotic and dividing cells separately;

use

`relrisk`

to perform cross-validated bandwidth selection and computation of the relative intensity of pyknotic cells.

The command `rmpoispp`

generates simulated realisations of a *multitype* Poisson process. The first argument `lambda`

specifies the intensity function \(\lambda(x,y,m)\) which gives the intensity of points at location (x,y). It may be given in several forms.

If

`lambda`

is a single number, it specifies the intensity of points*of each type*. Try computing, inspecting and plotting the result of`rmpoispp(21, win=square(1), types=c("yes", "no"))`

What is the expected total number of points generated by this command?

If

`lambda`

is a vector of numbers, the vector entries specify the intensities for each type of point. Try`rmpoispp(c(20,40,20), types=letters[1:3])`

What is the expected total number of points generated by this command?

If

`lambda`

is a function with arguments`x,y,m`

then this is interpreted as the intensity function \(\lambda(x,y,m)\). Try`fun <- function(x,y,m) { 40 * (x+y) } X <- rmpoispp(fun, types=letters[24:26]) fun2 <- function(x,y,m) { ifelse(m == "yes", 100 * x, 50 * (1-x)) } X2 <- rmpoispp(fun2, types=c("yes", "no"))`

What is the expected total number of points in

`X`

?

Take the Harkness-Isham ants’ nests data `ants`

use

`summary`

to estimate the average intensities of the points of each type.Generate and plot a realisation of a marked Poisson process in the same window as the data, with the same possible types of points, with uniform intensities for each type, given by the intensities estimated from the data.

Repeat the simulation several times. Do the simulations look like the data?

Here we will fit multitype Poisson point process models to the Harkness-Isham ants’ nests data `ants`

.

Fit the model

`ppm(ants ~ marks)`

and interpret the result. Compare the result with`summary(ants)`

and explain the similarities.Fit the model

`ppm(ants ~ marks + x)`

and write down an expression for the fitted intensity function.Fit the model

`ppm(ants ~ marks * x)`

and write down an expression for the fitted intensity function.Compute the fitted intensities of the three models fitted above using

`predict`

and plot the results.Explain the difference between the models fitted by

`ppm(ants ~ marks + x)`

and`ppm(ants ~ marks * x)`

.

The study region for the ants’ nests data `ants`

is divided into areas of ‘scrub’ and ‘field’. We want to fit a Poisson model with different intensities in the field and scrub areas.

The coordinates of two points on the boundary line between field and scrub are given in `ants.extra$fieldscrub`

. First construct a function that determines which side of the line we are on:

```
fs <- function(x,y) {
ends <- ants.extra$fieldscrub
angle <- atan(diff(ends$y)/diff(ends$x))
normal <- angle + pi/2
project <- (x - ends$x[1]) * cos(normal) + (y - ends$y[1]) * sin(normal)
factor(ifelse(project > 0, "scrub", "field"))
}
```

Now fit the models:

```
ppm(ants ~ marks + side, covariates=list(side=fs))
ppm(ants ~ marks * side, covariates=list(side=fs))
```

and interpret the results.