This function selects an appropriate bandwidth `sigma`

for the kernel estimator of point process intensity
computed by `density.ppp`

.

The bandwidth \(\sigma\) is chosen to
maximise the point process likelihood cross-validation criterion
$$
\mbox{LCV}(\sigma) =
\sum_i \log\hat\lambda_{-i}(x_i) - \int_W \hat\lambda(u) \, {\rm d}u
$$
where the sum is taken over all the data points \(x_i\),
where \(\hat\lambda_{-i}(x_i)\) is the
leave-one-out kernel-smoothing estimate of the intensity at
\(x_i\) with smoothing bandwidth \(\sigma\),
and \(\hat\lambda(u)\) is the kernel-smoothing estimate
of the intensity at a spatial location \(u\) with smoothing
bandwidth \(\sigma\).
See Loader(1999, Section 5.3).

The value of \(\mbox{LCV}(\sigma)\) is computed
directly, using `density.ppp`

,
for `ns`

different values of \(\sigma\)
between `srange[1]`

and `srange[2]`

.

The result is a numerical value giving the selected bandwidth.
The result also belongs to the class `"bw.optim"`

which can be plotted to show the (rescaled) mean-square error
as a function of `sigma`

.

If `shortcut=TRUE`

, the computation is accelerated by
omitting the integral term in the equation above. This is valid
because the integral is approximately constant.