# var.nnct: Variances of Cell Counts in an NNCT In nnspat: Nearest Neighbor Methods for Spatial Patterns

 var.nnct R Documentation

## Variances of Cell Counts in an NNCT

### Description

Returns the variances of cell counts N_{ij} for i,j=1,…,k in the NNCT, `ct` in matrix form which is of the same dimension as `ct`. These variances are valid under RL or conditional on Q and R under CSR.

### Usage

```var.nnct(ct, Q, R)
```

### Arguments

 `ct` A nearest neighbor contingency table `Q` The number of shared NNs `R` The number of reflexive NNs (i.e., twice the number of reflexive NN pairs)

### Value

A `matrix` of same dimension as, `ct`, whose entries are the variances of the cell counts in the NNCT with class sizes given as the row sums of `ct`. The row and column names are inherited from `ct`.

Elvan Ceyhan

### References

\insertAllCited

`var.tct`, `var.nnsym` and `cov.nnct`

### Examples

```n<-20  #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
cls<-sample(1:2,n,replace = TRUE)  #or try cls<-rep(1:2,c(10,10))
ct<-nnct(ipd,cls)
ct

W<-Wmat(ipd)
Qv<-Qvec(W)\$q
Rv<-Rval(W)
var.nnct(ct,Qv,Rv)

#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
ct<-nnct(ipd,fcls)
var.nnct(ct,Qv,Rv)

#############
n<-40
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
cls<-sample(1:4,n,replace = TRUE)  #or try cls<-rep(1:2,c(10,10))
ct<-nnct(ipd,cls)

W<-Wmat(ipd)
Qv<-Qvec(W)\$q
Rv<-Rval(W)
var.nnct(ct,Qv,Rv)

```

nnspat documentation built on Aug. 30, 2022, 9:06 a.m.