rsppmix: Generate a point pattern from a Poisson process

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/rsppmix.R

Description

This function generates a point pattern from a Poisson point process with intensity surface modeled by a mixture of normal components.

For examples see

http://faculty.missouri.edu/~micheasa/sppmix/sppmix_all_examples.html#rsppmix

Usage

1
2
3
4
rsppmix(intsurf, truncate = TRUE, marks = NULL, ...)

## S3 method for class 'sppmix'
summary(object, ...)

Arguments

intsurf

Object of class intensity_surface or normmix.

truncate

Logical variable indicating that the points should be within the window of observation. Default is TRUE.

marks

An optional vector defining the mark space. A mark value is randomly selected and attached to the generated locations. Default is NULL, so that we create an unmarked point pattern.

...

Further parameters passed to to_int_surf().

object

A point pattern object of class sppmix.

Details

If an intensity surface is passed to intsurf, the function generates a pattern from the Poisson directly. We can also pass a normal mixture of class normmix and specify the observation window win and the parameter lambda, which is interpreted as the average number of points over the window, as additional parameters.

Even if we pass an intensity surface to rsppmix(), we can still overwrite the lambda and win by passing them as additional parameters. See the examples for specific calls to the function.

For a given window W, the number of points N(W) in W follows a Poisson distribution, with intensity measure Lambda(W). The intensity surface of the Poisson process is the Radon-Nikodym derivative of the measure Lambda with respect to the Lebesgue measure.

The intensity surface is modeled using a multiple of a mixture of normal distributions, i.e., the intensity is given by

f(x|lambda,thetas)=lambda * sum(p_i*f_i(x|mu_i,sigma_i)),

where the parameters thetas consist of the mixture probabilities ps, normal component means mus, and covariances sigmas, with sum(p_i)=1.

When the masses of all the components f_i are within the window, then the mixture sum(p_i*f_i(x|mu_i,sigma_i)) integrates to 1 over W, so that the average number of points is given by E(N(W))=lambda.

If truncate = TRUE, we generate points from the unbounded Poisson with the given mixture intensity function until there are exactly n points in the window (rejection method). If truncate = FALSE, the function will not check if the points are inside the window.

Value

A point pattern of class c("sppmix", "ppp"). The object has all the traits of the ppp object and in addition, a comp member indicating from which mixture component the event comes from. The object members include:

x : a vector of x coordinates of the events,

y : a vector of y coordinates of the events,

n : the number of events,

window : the window of observation (an object of class owin),

marks : optional vector of marks,

comp : vector of true allocation variables.

Author(s)

Jiaxun Chen, Sakis Micheas, Yuchen Wang

See Also

normmix, rmixsurf, square, rsppmix, plot.sppmix, plotmix_2d, plot2dPP, plot.normmix, rnormmix, plotmix_3d

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# create the true mixture
truemix_surf <- normmix(ps=c(.2, .6,.2), mus=list(c(0.3, 0.3), c(0.7, 0.7), c(0.5, 0.5)),
 sigmas = list(.01*diag(2), .03*diag(2), .02*diag(2)), lambda=100, win=spatstat::square(1))
plot(truemix_surf)
# generate the point pattern
genPPP1=rsppmix(truemix_surf)
summary(genPPP1)
plot2dPP(genPPP1)
plot2dPP(genPPP1,truemix_surf$mus)
plotmix_2d(truemix_surf,genPPP1)
# overwrite lambda or win
genPPP2=rsppmix(truemix_surf, lambda = 200)
plotmix_2d(truemix_surf,genPPP2)
genPPP3=rsppmix(truemix_surf, win = spatstat::square(2))
truemix_surf$window
plotmix_2d(truemix_surf,genPPP3)#will not see the points outside the surface window
plotmix_2d(truemix_surf,genPPP3, win = spatstat::square(2)) #have to pass the new window
#to see the points
#use normmix with additional parameters
truemix<- rnormmix(m = 3, sig0 = .1, df = 5, xlim= c(0, 3), ylim = c(0, 3))
plot(truemix)
normdens=dnormmix(truemix, xlim= c(0, 3), ylim = c(0, 3))
plotmix_3d(normdens)
genPPP4=rsppmix(truemix, lambda = 100, win = spatstat::square(3))
# turn off truncation
genPPP5=rsppmix(intsurf = truemix_surf, truncate = FALSE)
plotmix_2d(truemix_surf,genPPP5)
plotmix_2d(truemix_surf,genPPP5, win = spatstat::square(2))
plotmix_2d(truemix_surf,genPPP5,contour=TRUE)
intsurf6=rmixsurf(m=5,lambda=rgamma(1,shape=10,scale=5),
 df=5,sig0=1,rand_m=TRUE,mu0 = c(.5,.5),Sigma0 = 0.001*diag(2))
genPPP6=rsppmix(intsurf6,marks=1:3,truncate = FALSE)
plotmix_2d(intsurf6,genPPP6)
plot(genPPP6,showmarks=TRUE)

sppmix documentation built on Jan. 13, 2021, 10:04 p.m.