1 Lab Session 2

Simulate Data

We begin by simulating data for this workshop. As you covered this yesterday, just copy and past these commands into your R script for this workshop so you can access each object by typing its name at the console.

library(spatstat)

win1 <- owin()  # rectangular [0,1]x[0,1] window
lambda1 <- 100
patt1 <- rpoispp(lambda = lambda1, win = win1)
patt1
Planar point pattern: 96 points
window: rectangle = [0, 1] x [0, 1] units
win2 <- owin(poly = list(x = c(-1, 3, 2), y = c(-1,
    1, 2)))  # triangular window
lambda2 <- 50
patt2 <- rpoispp(lambda = lambda2, win = win2)
patt2
Planar point pattern: 165 points
window: polygonal boundary
enclosing rectangle: [-1, 3] x [-1, 2] units
win3 <- owin(xrange = c(0, 1), yrange = c(0, 2))  # rectangular window
lambda3 <- function(x, y) {
    return(10 + 100 * x + 200 * y)
}
patt3 <- rpoispp(lambda = lambda3, lmax = 510, win = win3)
patt3
Planar point pattern: 542 points
window: rectangle = [0, 1] x [0, 2] units
win4 <- owin(poly = list(x = c(0, 10, 10), y = c(0,
    0, 3)))  # triangular window
lambda4 <- function(x, y) {
    return(5 * x + 10 * y)
}
patt4 <- rpoispp(lambda = lambda4, lmax = 80, win = win4)
patt4
Planar point pattern: 648 points
window: polygonal boundary
enclosing rectangle: [0, 10] x [0, 3] units
plot(patt1, pch = "+")
plot(patt2, pch = "+")
plot(patt3, pch = "+")
plot(patt4, pch = "+")