# cov.nnct: Covariance Matrix of the Cell Counts in an NNCT In nnspat: Nearest Neighbor Methods for Spatial Patterns

## Description

Returns the covariance matrix of cell counts N_{ij} for i,j=1,…,k in the NNCT, ct. The covariance matrix is of dimension k^2 \times k^2 and its entries are cov(N_{ij},N_{kl}) when N_{ij} values are by default corresponding to the row-wise vectorization of ct. If byrow=FALSE, the column-wise vectorization of ct is used. These covariances are valid under RL or conditional on Q and R under CSR.

## Usage

 1 cov.nnct(ct, varN, Q, R, byrow = TRUE) 

## Arguments

 ct A nearest neighbor contingency table varN The k \times k variance matrix of cell counts of NNCT, ct. Q The number of shared NNs R The number of reflexive NNs (i.e., twice the number of reflexive NN pairs) byrow A logical argument (default=TRUE). If TRUE, rows of ct are appended to obtain the vector and if FALSE columns of ct are appended to obtain the vector.

## Value

The k^2 \times k^2 covariance matrix of cell counts N_{ij} for i,j=1,…,k in the NNCT, ct

Elvan Ceyhan

## References

\insertAllCited

covNrow2col, cov.tct and cov.nnsym
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 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) W<-Wmat(ipd) Qv<-Qvec(W)$q Rv<-Rval(W) varN<-var.nnct(ct,Qv,Rv) cov.nnct(ct,varN,Qv,Rv) cov.nnct(ct,varN,Qv,Rv,byrow=FALSE) ############# 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) varN<-var.nnct(ct,Qv,Rv) cov.nnct(ct,varN,Qv,Rv) cov.nnct(ct,varN,Qv,Rv,byrow=FALSE) #1D data points n<-20 #or try sample(1:20,1) X<-as.matrix(runif(n))# need to be entered as a matrix with one column #(i.e., a column vector), hence X<-runif(n) would not work ipd<-ipd.mat(X) cls<-sample(1:2,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) varN<-var.nnct(ct,Qv,Rv) Qv<-Qvec(W)$q Rv<-Rval(W) varN<-var.nnct(ct,Qv,Rv) cov.nnct(ct,varN,Qv,Rv)