funs.auxcovtct {nnspat}R Documentation

Auxiliary Functions for Computing Covariances Between Cell Counts in the TCT

Description

Five functions: cov.2cells, cov.cell.col, covNijCk, cov2cols and covCiCj

These are auxiliary functions for computing covariances between entries in the TCT for the types I-IV cell-specific tests. The covariances between T_{ij} values for i,j=1,\ldots,k in the TCT require covariances between two cells in the NNCT, between a cell and column sum, and between two column sums in the NNCT. cov.2cells computes the covariance between two cell counts N_{ij} and N_{kl} in an NNCT, cov.cell.col and covNijCk are equivalent and they compute the covariance between cell count N_{ij} and sum of column k, C_k, cov2cols and covCiCj are equivalent and they compute the covariance between sums of two columns, C_i and C_j. The index arguments refer to which entry or column sum is intended in the NNCT. The argument covN must be the covariance between N_{ij} values which are obtained from NNCT by row-wise vectorization. These covariances are valid under RL or conditional on Q and R under CSR.

Usage

cov.2cells(i, j, k, l, ct, covN)

cov.cell.col(i, j, k, ct, covN)

covNijCk(i, j, k, ct, covN)

cov.2cols(i, j, ct, covN)

covCiCj(i, j, ct, covN)

Arguments

i, j, k, l

Indices of the cell counts or column sums whose covariance is to be computed. All four are needed for cov.2cells referring to cells (i,j) and (k,l); only three indices i,j,k are needed for cov.cell.col and covNijCk referring to cell (i,j) and column k; only two indices i,j are needed for cov2cols and covCiCj referring to columns i and j.

ct

A nearest neighbor contingency table

covN

The k^2 \times k^2 covariance matrix of row-wise vectorized cell counts of NNCT, ct.

Value

cov.2cells returns the covariance between two cell counts N_{ij} and N_{kl} in an NNCT, cov.cell.col and covNijCk return the covariance between cell count N_{ij} and sum of column k, C_k, cov2cols and covCiCj return the covariance between sums of two columns, C_i and C_j.

Author(s)

Elvan Ceyhan

See Also

cov.tct 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)

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

cov.2cells(1,1,1,2,ct,covN)

cov.cell.col(2,2,1,ct,covN)
covNijCk(2,2,1,ct,covN)

cov.2cols(2,1,ct,covN)
covCiCj(2,1,ct,covN)

#############
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)
covN<-cov.nnct(ct,varN,Qv,Rv)

cov.2cells(2,3,1,2,ct,covN)

cov.cell.col(1,1,2,ct,covN)
covNijCk(1,1,2,ct,covN)

cov.2cols(3,4,ct,covN)
covCiCj(3,4,ct,covN)


[Package nnspat version 0.1.2 Index]