funsXsq.spec.cor: Overall Species Correspondence Test with Chi-square...

funsXsq.spec.corR Documentation

Overall Species Correspondence Test with Chi-square Approximation

Description

Two functions: Xsq.spec.cor.ct and Xsq.spec.cor.

Each one performs hypothesis tests of (simultaneous) equality of the self entries (i.e., first column) in a species correspondence contingency table (SCCT) or the expected values of the diagonal entries N_{ii} in an NNCT to the ones under RL or CSR. That is, each performs the overall species correspondence test which is appropriate (i.e., have the appropriate asymptotic sampling distribution) for completely mapped data. (See \insertCiteceyhan:NNCorrespond2018;textualnnspat for more detail).

Each test is based on the Chi-square approximation of the corresponding quadratic form for the first column in a species correspondence contingency table (SCCT) or the diagonal entries N_{ii} in an NNCT and are due to \insertCiteceyhan:NNCorrespond2018nnspat.

Each function yields the test statistic, p-value and df which is k, description of the alternative with the corresponding null values (i.e., expected values) of the self entries (i.e., first column) in the SCCT or the diagonal entries in the NNCT and also the sample estimates (i.e., observed values) of these entries. The functions also provide names of the test statistics, the description of the test and the data set used.

The null hypothesis is that all E[S_1,S_2,\ldots,S_k] = E[N_{11},N_{22},\ldots,N_{kk}] = ((n_1(n_1 - 1)/(n - 1),(n_2(n_2 - 1)/(n - 1),\ldots,(n_k(n_k - 1)/(n - 1) ) where n_i is the size of class i and n is the data size.

Usage

Xsq.spec.cor.ct(ct, covSC, nnct = FALSE)

Xsq.spec.cor(dat, lab, ...)

Arguments

ct

The NNCT or SCCT, used in Xsq.spec.cor.ct only

covSC

The covariance matrix for the self entries (i.e., first column) in the SCCT or the diagonal entries in the NNCT, used in Xsq.spec.cor.ct only. Usually output of the functions covNii.ct or covNii.

nnct

A logical parameter (default=FALSE). If TRUE, x is taken to be the k \times k NNCT, and if FALSE, x is taken to be the IPD matrix, used in Xsq.spec.cor.ct only

dat

The data set in one or higher dimensions, each row corresponds to a data point, used in Xsq.spec.cor only

lab

The vector of class labels (numerical or categorical), used in Xsq.spec.cor only

...

are for further arguments, such as method and p, passed to the dist function. used in Xsq.spec.cor only

Value

A list with the elements

statistic

The chi-squared test statistic for overall species correspondence test

p.value

The p-value for the hypothesis test

df

Degrees of freedom for the chi-squared test, which is k for this function.

estimate

The vector of estimates of the parameters, i.e., observed values of self entries in the SCCT or diagonal entries in the NNCT.

est.name, est.name2

Names of the estimates, they are identical for this function.

null.value

The vector of null values of the parameters, i.e., expected values of self entries in the SCCT or diagonal entries in the NNCT under RL or CSR.

method

Description of the hypothesis test

ct.name

Name of the contingency table, ct, returned by Xsq.spec.cor.ct only

data.name

Name of the data set, dat, returned by Xsq.spec.cor only

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

Zself.ref.ct, Zself.ref, Xsq.nnref.ct and Xsq.nnref

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<-scct(ipd,cls)
ct

W<-Wmat(ipd)
Qv<-Qvec(W)$q
Rv<-Rval(W)

vsq<-varNii.ct(ct,Qv,Rv)
cv<-covNii.ct(ct,vsq,Qv,Rv)
Xsq.spec.cor.ct(ct,cv)
Xsq.spec.cor(Y,cls)
Xsq.spec.cor(Y,cls,method="max")

ct<-nnct(ipd,cls)
Xsq.spec.cor.ct(ct,cv,nnct = TRUE)

#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
ct<-scct(ipd,fcls)
Xsq.spec.cor.ct(ct,cv)
Xsq.spec.cor(Y,fcls)

ct<-nnct(ipd,fcls)
Xsq.spec.cor.ct(ct,cv,nnct=TRUE)

#############
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<-scct(ipd,cls)

W<-Wmat(ipd)
Qv<-Qvec(W)$q
Rv<-Rval(W)

vsq<-varNii.ct(ct,Qv,Rv)
cv<-covNii.ct(ct,vsq,Qv,Rv)
Xsq.spec.cor.ct(ct,cv)

ct<-nnct(ipd,cls)
Xsq.spec.cor.ct(ct,cv,nnct = TRUE)
Xsq.spec.cor(Y,cls)


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