cov.seg.coeff: Covariance Matrix of Segregation Coefficients in a...

View source: R/NNCTFunctions.R

cov.seg.coeffR Documentation

Covariance Matrix of Segregation Coefficients in a Multi-class Case

Description

Returns the covariance matrix of the segregation coefficients in a multi-class case based on the NNCT, ct. The covariance matrix is of dimension k(k+1)/2 \times k(k+1)/2 and its entry i,j correspond to the entries in the rows i and j of the output of ind.seg.coeff(k). The segregation coefficients in the multi-class case are the extension of Pielou's segregation coefficient for the two-class case. These covariances are valid under RL or conditional on Q and R under CSR.

The argument covN is the covariance matrix of N_{ij} (concatenated rowwise).

See also (\insertCiteceyhan:SiM-seg-ind2014;textualnnspat).

Usage

cov.seg.coeff(ct, covN)

Arguments

ct

A nearest neighbor contingency table

covN

The k^2 \times k^2 covariance matrix of row-wise vectorized entries of NNCT

Value

The k(k+1)/2 x k(k+1)/2 covariance matrix of the segregation coefficients for the multi-class case based on the NNCT, ct

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

seg.coeff, var.seg.coeff, cov.nnct and cov.nnsym

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.seg.coeff(ct,covN)

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

cov.seg.coeff(ct,covN)

#############
n<-40
Y<-matrix(runif(3*n),ncol=3)
cls<-sample(1:4,n,replace = TRUE)  #or try cls<-rep(1:2,c(10,10))
ipd<-ipd.mat(Y)
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.seg.coeff(ct,covN)


nnspat documentation built on May 29, 2024, 10:03 a.m.