# varblock

##### Estimate Variance of Summary Statistic by Subdivision

This command estimates the variance of any summary statistic (such as the $K$-function) by spatial subdivision of a single point pattern dataset.

- Keywords
- spatial, nonparametric

##### Usage

```
varblock(X, fun = Kest, blocks = quadrats(X, nx = nx, ny = ny), ...,
nx = 3, ny = nx)
```

##### Arguments

- X
- Point pattern dataset (object of class
`"ppp"`

). - fun
- Function that computes the summary statistic.
- blocks
- Optional. A tessellation that specifies the division of the space into blocks.
- ...
- Arguments passed to
`fun`

. - nx,ny
- Optional. Number of rectangular blocks
in the $x$ and $y$ directions.
Incompatible with
`blocks`

.

##### Details

This command computes an estimate of the variance of
the summary statistic `fun(X)`

from a single point pattern
dataset `X`

using a subdivision method.
It can be used to plot **confidence intervals**
for the true value of a summary function such as the $K$-function.
The window containing `X`

is divided into pieces by
an `nx * ny`

array of rectangles
(or is divided into pieces of more general shape,
according to the argument `blocks`

if it is present).
The summary statistic `fun`

is applied to each of the
corresponding sub-patterns of `X`

as described below.
Then the pointwise
sample mean, sample variance and sample standard deviation
of these summary statistics are computed. The two-standard-deviation
confidence intervals are computed.

The variance is estimated by equation (4.21) of Diggle (2003, page 52).
This assumes that the point pattern `X`

is stationary.
For further details see Diggle (2003, pp 52--53).
The estimate of the summary statistic
from each block is computed as follows.
For most functions `fun`

,
the estimate from block `B`

is computed by finding the subset of `X`

consisting of
points that fall inside `B`

,
and applying `fun`

to these points, by calling `fun(X[B])`

.

However if `fun`

is the $K$-function `Kest`

,
or any function which has an argument called `domain`

,
the estimate for each block `B`

is computed
by calling `fun(X, domain=B)`

. In the case of the
$K$-function this means that the estimate from block `B`

is computed by counting pairs of
points in which the *first* point lies in `B`

,
while the second point may lie anywhere.

##### Value

- A function value table (object of class
`"fv"`

) that contains the result of`fun(X)`

as well as the sample mean, sample variance and sample standard deviation of the block estimates, together with the upper and lower two-standard-deviation confidence limits.

##### Errors

If the blocks are too small, there may be insufficient data
in some blocks, and the function `fun`

may report an error.
If this happens, you need to take larger blocks.
An error message about incompatibility may occur.
The different function estimates may be incompatible in some cases,
for example, because they use different default edge corrections
(typically because the tiles of the tessellation are not the same kind
of geometric object as the window of `X`

, or because the default
edge correction depends on the number of points). To prevent
this, specify the choice of edge correction,
in the `correction`

argument to `fun`

, if it has one.
Some edge corrections are only available if you have set
`spatstat.options(gpclib=TRUE)`

.

An alternative to `varblock`

is Loh's mark bootstrap
`lohboot`

.

##### References

Diggle, P.J. (2003)
*Statistical analysis of spatial point patterns*,
Second edition. Arnold.

##### See Also

`tess`

,
`quadrats`

for basic manipulation.
`lohboot`

for an alternative bootstrap technique.

##### Examples

```
v <- varblock(amacrine, Kest, nx=4, ny=2)
v <- varblock(amacrine, Kcross, nx=4, ny=2)
if(interactive()) plot(v, iso ~ r, shade=c("hiiso", "loiso"))
```

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