Computes spatially-weighted versions of the the local \(K\)-function or \(L\)-function.

```
localKinhom(X, lambda, ..., rmax = NULL,
correction = "Ripley", verbose = TRUE, rvalue=NULL,
sigma = NULL, varcov = NULL, update=TRUE, leaveoneout=TRUE)
localLinhom(X, lambda, ..., rmax = NULL,
correction = "Ripley", verbose = TRUE, rvalue=NULL,
sigma = NULL, varcov = NULL, update=TRUE, leaveoneout=TRUE)
```

X

A point pattern (object of class `"ppp"`

).

lambda

Optional.
Values of the estimated intensity function.
Either a vector giving the intensity values
at the points of the pattern `X`

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

) giving the
intensity values at all locations, a fitted point process model
(object of class `"ppm"`

or `"kppm"`

or `"dppm"`

)
or a `function(x,y)`

which
can be evaluated to give the intensity value at any location.

…

Extra arguments. Ignored if `lambda`

is present.
Passed to `density.ppp`

if `lambda`

is omitted.

rmax

Optional. Maximum desired value of the argument \(r\).

correction

String specifying the edge correction to be applied.
Options are `"none"`

, `"translate"`

, `"Ripley"`

,
`"translation"`

, `"isotropic"`

or `"best"`

.
Only one correction may be specified.

verbose

Logical flag indicating whether to print progress reports during the calculation.

rvalue

Optional. A *single* value of the distance argument
\(r\) at which the function L or K should be computed.

sigma, varcov

Optional arguments passed to `density.ppp`

to control
the kernel smoothing procedure for estimating `lambda`

,
if `lambda`

is missing.

leaveoneout

Logical value (passed to `density.ppp`

or
`fitted.ppm`

) specifying whether to use a
leave-one-out rule when calculating the intensity.

update

Logical value indicating what to do when `lambda`

is a fitted model
(class `"ppm"`

, `"kppm"`

or `"dppm"`

).
If `update=TRUE`

(the default),
the model will first be refitted to the data `X`

(using `update.ppm`

or `update.kppm`

)
before the fitted intensity is computed.
If `update=FALSE`

, the fitted intensity of the
model will be computed without re-fitting it to `X`

.

If `rvalue`

is given, the result is a numeric vector
of length equal to the number of points in the point pattern.

If `rvalue`

is absent, the result is
an object of class `"fv"`

, see `fv.object`

,
which can be plotted directly using `plot.fv`

.
Essentially a data frame containing columns

the vector of values of the argument \(r\) at which the function \(K\) has been estimated

the theoretical value \(K(r) = \pi r^2\) or \(L(r)=r\) for a stationary Poisson process

The functions `localKinhom`

and `localLinhom`

are inhomogeneous or weighted versions of the
neighbourhood density function implemented in
`localK`

and `localL`

.

Given a spatial point pattern `X`

, the
inhomogeneous neighbourhood density function
\(L_i(r)\) associated with the \(i\)th point
in `X`

is computed by
$$
L_i(r) = \sqrt{\frac 1 \pi \sum_j \frac{e_{ij}}{\lambda_j}}
$$
where the sum is over all points \(j \neq i\) that lie
within a distance \(r\) of the \(i\)th point,
\(\lambda_j\) is the estimated intensity of the
point pattern at the point \(j\),
and \(e_{ij}\) is an edge correction
term (as described in `Kest`

).
The value of \(L_i(r)\) can also be interpreted as one
of the summands that contributes to the global estimate of the
inhomogeneous L function (see `Linhom`

).

By default, the function \(L_i(r)\) or
\(K_i(r)\) is computed for a range of \(r\) values
for each point \(i\). The results are stored as a function value
table (object of class `"fv"`

) with a column of the table
containing the function estimates for each point of the pattern
`X`

.

Alternatively, if the argument `rvalue`

is given, and it is a
single number, then the function will only be computed for this value
of \(r\), and the results will be returned as a numeric vector,
with one entry of the vector for each point of the pattern `X`

.

```
# NOT RUN {
data(ponderosa)
X <- ponderosa
# compute all the local L functions
L <- localLinhom(X)
# plot all the local L functions against r
plot(L, main="local L functions for ponderosa", legend=FALSE)
# plot only the local L function for point number 7
plot(L, iso007 ~ r)
# compute the values of L(r) for r = 12 metres
L12 <- localL(X, rvalue=12)
# }
```

Run the code above in your browser using DataLab