funs.seg.coeff | R Documentation |
Two functions: Pseg.coeff
and seg.coeff
.
Each function computes segregation coefficients based on NNCTs.
The function Pseg.coeff
computes Pielou's segregation coefficient (\insertCitepielou:1961;textualnnspat)
for the two-class case (i.e., based on 2 \times 2
NNCTs)
and seg.coeff
is the extension of Pseg.coeff
to the multi-class case (i.e., for k \times k
NNCTs with k \ge 2
)
and provides a k \times k
matrix of segregation coefficients
(\insertCiteceyhan:SiM-seg-ind2014;textualnnspat).
Both functions use the same argument, ct
, for NNCT.
Pielou's segregation coefficient (for two classes) is S_P = 1-(N_{12} + N_{21})/(E[N_{12}] + E[N_{21}])
and the extended segregation coefficents (for k \ge 2
classes) are
S_c = 1 -(N_{ii})/(E[N_{ii}])
for the diagonal cells in the NNCT
and
S_c = 1 -(N_{ij} + N_{ji})/(E[N_{ij}] + E[N_{ji}])
for the off-diagonal cells in the NNCT.
Pseg.coeff(ct)
seg.coeff(ct)
ct |
A nearest neighbor contingency table, used in both functions |
Pseg.coeff
returns Pielou's segregation coefficient for 2 \times 2
NNCT
seg.coeff
returns a k \times k
matrix of segregation coefficients (which are extended versions
of Pielou's segregation coefficient)
Elvan Ceyhan
seg.ind
, Zseg.coeff.ct
and Zseg.coeff
#Examples for Pseg.coeff
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
Pseg.coeff(ct)
#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
ct<-nnct(ipd,fcls)
Pseg.coeff(ct)
#############
ct<-matrix(sample(1:25,9),ncol=3)
#Pseg.coeff(ct)
#Examples for seg.coeff
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
seg.coeff(ct)
#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
ct<-nnct(ipd,fcls)
seg.coeff(ct)
#############
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)
seg.coeff(ct)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.