funsXsq.spec.cor {nnspat} | R 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 Ceyhan (2018) 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 (Ceyhan 2018).
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 |
covSC |
The covariance matrix for the self entries (i.e., first column) in the SCCT
or the diagonal entries in the NNCT, used in |
nnct |
A logical parameter (default= |
dat |
The data set in one or higher dimensions, each row corresponds to a data point,
used in |
lab |
The |
... |
are for further arguments, such as |
Value
A list
with the elements
statistic |
The chi-squared test statistic for overall species correspondence test |
p.value |
The |
df |
Degrees of freedom for the chi-squared test, which is |
estimate |
The |
est.name , est.name2 |
Names of the estimates, they are identical for this function. |
null.value |
The |
method |
Description of the hypothesis test |
ct.name |
Name of the contingency table, |
data.name |
Name of the data set, |
Author(s)
Elvan Ceyhan
References
Ceyhan E (2018). “A contingency table approach based on nearest neighbor relations for testing self and mixed correspondence.” SORT-Statistics and Operations Research Transactions, 42(2), 125-158.
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)