Learn R Programming

nnspat (version 0.1.2)

var.seg.coeff: Variances of Segregation Coefficients in a Multi-class Case

Description

Returns the variances of segregation coefficients in a multi-class case based on the NNCT, ct in a vector of length \(k(k+1)/2\), the order of the variances are as in the order of rows output of ind.seg.coeff(k). These variances are valid under RL or conditional on \(Q\) and \(R\) under CSR.

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

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

Usage

var.seg.coeff(ct, covN)

Value

A vector of length \(k(k+1)/2\), whose entries are the variances of segregation coefficients for the entry \(i,j\) in the NNCT, where the order of the variances are as in the order of rows output of ind.seg.coeff(k).

Arguments

ct

A nearest neighbor contingency table

covN

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

Author

Elvan Ceyhan

References

See Also

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

Examples

Run this code
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)

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

var.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)

var.seg.coeff(ct,covN)

Run the code above in your browser using DataLab