# alltypes

##### Calculate Summary Statistic for All Types in a Multitype Point Pattern

Given a marked point pattern, this computes the estimates of a selected summary function (\(F\),\(G\), \(J\), \(K\) etc) of the pattern, for all possible combinations of marks, and returns these functions in an array.

- Keywords
- spatial, nonparametric

##### Usage

```
alltypes(X, fun="K", …,
dataname=NULL,verb=FALSE,envelope=FALSE,reuse=TRUE)
```

##### Arguments

- X
The observed point pattern, for which summary function estimates are required. An object of class

`"ppp"`

or`"lpp"`

.- fun
The summary function. Either an R function, or a character string indicating the summary function required. Options for strings are

`"F"`

,`"G"`

,`"J"`

,`"K"`

,`"L"`

,`"pcf"`

,`"Gcross"`

,`"Jcross"`

,`"Kcross"`

,`"Lcross"`

,`"Gdot"`

,`"Jdot"`

,`"Kdot"`

,`"Ldot"`

.- …
Arguments passed to the summary function (and to the function

`envelope`

if appropriate)- dataname
Character string giving an optional (alternative) name to the point pattern, different from what is given in the call. This name, if supplied, may be used by

`plot.fasp()`

in forming the title of the plot. If not supplied it defaults to the parsing of the argument supplied as`X`

in the call.- verb
Logical value. If

`verb`

is true then terse ``progress reports'' (just the values of the mark indices) are printed out when the calculations for that combination of marks are completed.- envelope
Logical value. If

`envelope`

is true, then simulation envelopes of the summary function will also be computed. See Details.- reuse
Logical value indicating whether the envelopes in each panel should be based on the same set of simulated patterns (

`reuse=TRUE`

) or on different, independent sets of simulated patterns (`reuse=FALSE`

).

##### Details

This routine is a convenient way to analyse the dependence between
types in a multitype point pattern.
It computes the estimates of a selected summary function of the
pattern, for all possible combinations of marks.
It returns these functions in an array
(an object of class `"fasp"`

) amenable to plotting
by `plot.fasp()`

.

The argument `fun`

specifies the summary function that will
be evaluated for each type of point, or for each pair of types.
It may be either an R function or a character string.

Suppose that the points have possible types \(1,2,\ldots,m\) and let \(X_i\) denote the pattern of points of type \(i\) only.

If `fun="F"`

then this routine
calculates, for each possible type \(i\),
an estimate of the Empty Space Function \(F_i(r)\) of
\(X_i\). See `Fest`

for explanation of the empty space function.
The estimate is computed by applying `Fest`

to \(X_i\) with the optional arguments `…`

.

If `fun`

is
`"Gcross"`

, `"Jcross"`

, `"Kcross"`

or `"Lcross"`

,
the routine calculates, for each pair of types \((i,j)\),
an estimate of the ```i`

-to`j`

'' cross-type function
\(G_{ij}(r)\),
\(J_{ij}(r)\),
\(K_{ij}(r)\) or
\(L_{ij}(r)\) respectively describing the
dependence between
\(X_i\) and \(X_j\).
See `Gcross`

, `Jcross`

, `Kcross`

or `Lcross`

respectively for explanation of these
functions.
The estimate is computed by applying the relevant function
(`Gcross`

etc)
to `X`

using each possible value of the arguments `i,j`

,
together with the optional arguments `…`

.

If `fun`

is `"pcf"`

the routine calculates
the cross-type pair correlation function `pcfcross`

between each pair of types.

If `fun`

is
`"Gdot"`

, `"Jdot"`

, `"Kdot"`

or `"Ldot"`

,
the routine calculates, for each type \(i\),
an estimate of the ```i`

-to-any'' dot-type function
\(G_{i\bullet}(r)\),
\(J_{i\bullet}(r)\) or
\(K_{i\bullet}(r)\) or
\(L_{i\bullet}(r)\) respectively describing the
dependence between \(X_i\) and \(X\).
See `Gdot`

, `Jdot`

, `Kdot`

or `Ldot`

respectively for explanation of these functions.
The estimate is computed by applying the relevant function
(`Gdot`

etc)
to `X`

using each possible value of the argument `i`

,
together with the optional arguments `…`

.

The letters `"G"`

, `"J"`

, `"K"`

and `"L"`

are interpreted as abbreviations for `Gcross`

,
`Jcross`

, `Kcross`

and `Lcross`

respectively, assuming the point pattern is
marked. If the point pattern is unmarked, the appropriate
function `Fest`

, `Jest`

,
`Kest`

or `Lest`

is invoked instead.

If `envelope=TRUE`

, then as well as computing the value of the
summary function for each combination of types, the algorithm also
computes simulation envelopes of the summary function for each
combination of types. The arguments `…`

are passed to the function
`envelope`

to control the number of
simulations, the random process generating the simulations,
the construction of envelopes, and so on.

When `envelope=TRUE`

it is possible that errors could occur
because the simulated point patterns do not satisfy the requirements
of the summary function (for example, because the simulated pattern
is empty and `fun`

requires at least one point). If the number
of such errors exceeds the maximum permitted number `maxnerr`

,
then the envelope algorithm will give up, and will return
the empirical summary function for the data point pattern,
`fun(X)`

, in place of the envelope.

##### Value

A function array (an object of class `"fasp"`

,
see `fasp.object`

). This can be plotted
using `plot.fasp`

.

If the pattern is not marked, the resulting ``array'' has dimensions \(1 \times 1\). Otherwise the following is true:

If `fun="F"`

,
the function array has dimensions \(m \times 1\)
where \(m\) is the number of different marks in the point pattern.
The entry at position `[i,1]`

in this array
is the result of applying `Fest`

to the
points of type `i`

only.

If `fun`

is `"Gdot"`

, `"Jdot"`

, `"Kdot"`

or `"Ldot"`

, the function array
again has dimensions \(m \times 1\).
The entry at position `[i,1]`

in this array
is the result of `Gdot(X, i)`

, `Jdot(X, i)`

`Kdot(X, i)`

or `Ldot(X, i)`

respectively.

If `fun`

is `"Gcross"`

, `"Jcross"`

, `"Kcross"`

or `"Lcross"`

(or their abbreviations `"G"`

, `"J"`

, `"K"`

or `"L"`

),
the function array has dimensions \(m \times m\).
The `[i,j]`

entry of the function array
(for \(i \neq j\)) is the
result of applying the function `Gcross`

,
`Jcross`

, `Kcross`

or`Lcross`

to
the pair of types `(i,j)`

. The diagonal
`[i,i]`

entry of the function array is the result of
applying the univariate function `Gest`

,
`Jest`

, `Kest`

or `Lest`

to the
points of type `i`

only.

If `envelope=FALSE`

, then
each function entry `fns[[i]]`

retains the format
of the output of the relevant estimating routine
`Fest`

, `Gest`

, `Jest`

,
`Kest`

, `Lest`

, `Gcross`

,
`Jcross`

,`Kcross`

, `Lcross`

,
`Gdot`

, `Jdot`

, `Kdot`

or
`Ldot`

The default formulae for plotting these functions are
`cbind(km,theo) ~ r`

for F, G, and J functions, and
`cbind(trans,theo) ~ r`

for K and L functions.

If `envelope=TRUE`

, then each function entry `fns[[i]]`

has the same format as the output of the `envelope`

command.

##### Note

Sizeable amounts of memory may be needed during the calculation.

##### See Also

`plot.fasp`

,
`fasp.object`

,
`Fest`

,
`Gest`

,
`Jest`

,
`Kest`

,
`Lest`

,
`Gcross`

,
`Jcross`

,
`Kcross`

,
`Lcross`

,
`Gdot`

,
`Jdot`

,
`Kdot`

,
`envelope`

.

##### Examples

```
# NOT RUN {
# bramblecanes (3 marks).
bram <- bramblecanes
# }
# NOT RUN {
bF <- alltypes(bram,"F",verb=TRUE)
plot(bF)
if(interactive()) {
plot(alltypes(bram,"G"))
plot(alltypes(bram,"Gdot"))
}
# Swedishpines (unmarked).
swed <- swedishpines
# }
# NOT RUN {
plot(alltypes(swed,"K"))
plot(alltypes(amacrine, "pcf"), ylim=c(0,1.3))
# A setting where you might REALLY want to use dataname:
# }
# NOT RUN {
xxx <- alltypes(ppp(Melvin$x,Melvin$y,
window=as.owin(c(5,20,15,50)),marks=clyde),
fun="F",verb=TRUE,dataname="Melvin")
# }
# NOT RUN {
# envelopes
bKE <- alltypes(bram,"K",envelope=TRUE,nsim=19)
# }
# NOT RUN {
bFE <- alltypes(bram,"F",envelope=TRUE,nsim=19,global=TRUE)
# }
# NOT RUN {
# extract one entry
as.fv(bKE[1,1])
# }
```

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