This function computes the \(A=a_{ij}(\theta)\) matrix useful in calculations for Tango's test \(T(\theta)\)
for spatial (disease) clustering (see Eqn (2) of tango:2007;textualnnspat.
Here, \(A=a_{ij}(\theta)\) is any matrix of a measure of the closeness between two points \(i\) and \(j\) with \(aii = 0\) for all
\(i = 1, \ldots,n\), and \(\theta = (\theta_1,\ldots,\theta_p)^t\) denotes the unknown parameter vector related
to cluster size and \(\delta = (\delta_1,\ldots,\delta_n)^t\), where \(\delta_i=1\) if \(z_i\) is a case and 0
otherwise.
The test is then
$$T(\theta)=\sum_{i=1}^n\sum_{j=1}^n\delta_i \delta_j a_{ij}(\theta)=\delta^t A(\theta) \delta$$
where \(A=a_{ij}(\theta)\).
\(T(\theta)\) becomes Cuzick and Edwards \(T_k\) tests statistic (cuzick:1990;textualnnspat),
if \(a_{ij}=1\) if \(z_j\) is among the kNNs of \(z_i\) and 0 otherwise.
In this case \(\theta=k\) and aij.theta becomes aij.mat (more specifically,
aij.mat(dat,k) and aij.theta(dat,k,model="NN").
In Tango's exponential clinal model (tango:2000;textualnnspat),
\(a_{ij}=\exp\left(-4 \left(\frac{d_{ij}}{\theta}\right)^2\right)\) if \(i \ne j\) and 0 otherwise,
where \(\theta\) is a predetermined scale of cluster such that any pair of cases far apart beyond the distance
\(\theta\) cannot be considered as a cluster and \(d_{ij}\) denote the Euclidean distance between
two points \(i\) and \(j\).
In the exponential model (tango:2007;textualnnspat),
\(a_{ij}=\exp\left(-\frac{d_{ij}}{\theta}\right)\) if \(i \ne j\) and 0 otherwise,
where \(\theta\) and \(d_{ij}\) are as above.
In the hot-spot model (tango:2007;textualnnspat),
\(a_{ij}=1\) if \(d_{ij} \le \theta\) and \(i \ne j\) and 0 otherwise,
where \(\theta\) and \(d_{ij}\) are as above.
The argument model has four options, NN, exp.clinal, exponential, and
hot.spot, with exp.clinal being the default.
And the theta argument specifies the scale of clustering or the clustering parameter in the particular
spatial disease clustering model.
See also (tango:2007;textualnnspat) and the references therein.