# rLGCP

##### Simulate Log-Gaussian Cox Process

Generate a random point pattern, a realisation of the log-Gaussian Cox process.

##### Usage

`rLGCP(model="exponential", mu = 0, param = NULL, ..., win)`

##### Arguments

- model
- character string: the name of a covariance model for
the Gaussian random field, as recognised by the function
`GaussRF`

in theRandomFields package. - mu
- mean function of the Gaussian random field. Either a
single number, a
`function(x,y, ...)`

or a pixel image (object of class`"im"`

). - param
- Numeric vector of parameters for the covariance,
as understood by the function
`GaussRF`

in theRandomFields package. - ...
- Further arguments passed to the function
`GaussRF`

in theRandomFields package. - win
- Window in which to simulate the pattern.
An object of class
`"owin"`

.

##### Details

This function generates a realisation of a log-Gaussian Cox process (LGCP). This is a Cox point process in which the logarithm of the random intensity is a Gaussian random field with mean function $\mu$ and covariance function $c(r)$. Conditional on the random intensity, the point process is a Poisson process with this intensity.

The arguments `model`

and `param`

specify the covariance
function of the Gaussian random field, in the format expected by the
`GaussRF`

or
`Covariance`

for information about this format. A list of all implemented
models is available by typing `PrintModelList()`

.
This algorithm uses the function `GaussRF`

in the
`mu`

and the covariance specified by the arguments `model`

and
`param`

, on the points of a regular grid. The exponential
of this random field is taken as the intensity of a Poisson point
process, and a realisation of the Poisson process is then generated by the
function `rpoispp`

in the `win`

is missing, then it defaults to
`as.owin(mu)`

if `mu`

is a pixel image,
and it defaults to the unit square otherwise.
The LGCP model can be fitted to data using `kppm`

.

##### Value

- The simulated point pattern (an object of class
`"ppp"`

).Additionally, the simulated intensity function is returned as an attribute

`"Lambda"`

.

##### References

Moller, J., Syversveen, A. and Waagepetersen, R. (1998)
Log Gaussian Cox Processes.
*Scandinavian Journal of Statistics* **25**, 451--482.

##### See Also

`rpoispp`

,
`rMatClust`

,
`rGaussPoisson`

,
`rNeymanScott`

,
`lgcp.estK`

,
`kppm`

##### Examples

```
if(require(RandomFields)) {
# homogeneous LGCP with exponential covariance function
X <- rLGCP("exp", 3, c(0, variance=0.2, nugget=0, scale=.1 ))
# inhomogeneous LGCP with Gaussian covariance function
m <- as.im(function(x, y){5 - 1.5 * (x - 0.5)^2 + 2 * (y - 0.5)^2}, W=owin())
X <- rLGCP("gauss", m, c(0, variance=0.15, nugget = 0, scale =0.5))
plot(attr(X, "Lambda"))
points(X)
# inhomogeneous LGCP with Matern covariance function
X <- rLGCP("matern", function(x, y){ 1 - 0.4 * x},
c(0, variance=2, nugget=0, scale=0.7, a = 0.5),
win = owin(c(0, 10), c(0, 10)))
plot(X)
} else message("Simulation requires the RandomFields package")
```

*Documentation reproduced from package spatstat, version 1.23-3, License: GPL (>= 2)*