funsZnnself: Self-Reflexivity Tests with Normal Approximation

funsZnnselfR Documentation

Self-Reflexivity Tests with Normal Approximation

Description

Two functions: Znnself.ct and Znnself.

Both functions are objects of class "cellhtest" but with different arguments (see the parameter list below). Each one performs hypothesis tests of equality of the expected values 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 NN self reflexivity for each class test which is appropriate (i.e., have the appropriate asymptotic sampling distribution) for completely mapped data. NN self reflexivity is for each class can be viewed as a decomposition of species correspondence for each class. (See \insertCiteceyhan:NNCorrespond2018;textualnnspat for more detail).

Each test is based on the normal approximation of the self entries (i.e., 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 a vector of length k of the test statistics, p-values for the corresponding alternative, null values (i.e., expected values), sample estimates (i.e., observed values) of self entries in the SCCT or diagonal entries in the NNCT, a k \times 2 matrix of confidence intervals (where each row is the confidence interval for self entry S_i in the SCCT or diagonal entry N_{ii} in the NNCT) and also names of the test statistics, estimates, null values, the description of the test, and the data set used.

The null hypothesis is that all E[S_i] = E[N_{ii}] = n_i(n_i - 1)/(n - 1) where n_i is the size of class i and n is the data size.

The Znnself functions (i.e., Znnself.ct and Znnself) are different from the Znnref functions (i.e., Znnref.ct and Znnref) and from Zself.ref functions (i.e., Zself.ref.ct and Zself.ref) and also from Znnself.sum functions (i.e., Znnself.sum.ct and Znnself.sum). Znnself functions are testing the self reflexivity at a class-specific level (i.e., for each class) using the first column in the SCCT, while Zself.ref functions are for testing the self reflexivity for the entire data set using entry (1,1) in RCT, and Znnref functions are for testing the self reflexivity and mixed non-reflexivity using the diagonal entries in the RCT, and Znnself.sum functions are testing the cumulative species correspondence using the sum of the self column (i.e., the first column) in the SCCT.

Usage

Znnself.ct(
  ct,
  VarNii,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95
)

Znnself(
  dat,
  lab,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95,
  ...
)

Arguments

ct

The NNCT or SCCT, used in Znnself.ct only

VarNii

The variance vector of differences of self entries in the SCCT or diagonal entries in the NNCT, used in Znnself.ct only

alternative

Type of the alternative hypothesis in the test, one of "two.sided", "less" or "greater".

conf.level

Level of the upper and lower confidence limits, default is 0.95, for the self entries in the SCCT or diagonal entries in the NNCT

dat

The data set in one or higher dimensions, each row corresponds to a data point, used in Znnself only

lab

The vector of class labels (numerical or categorical), used in Znnself only

...

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

Value

A list with the elements

statistic

The vector (of length k) of Z test statistics for NN self reflexivity test

stat.names

Name of the test statistics

p.value

The vector of p-values for the hypothesis test for the corresponding alternative

LCL, UCL

Lower and Upper Confidence Levels, it is NULL here since we provide confidence intervals as a k \times 2 matrix.

conf.int

The k \times 2 matrix of confidence intervals for the estimates, (where each row is the confidence interval for self entry S_i in the SCCT or diagonal entry N_{ii} in the NNCT).

cnf.lvl

Level of the confidence intervals (i.e., conf.level) for the self entries in the SCCT or diagonal entries in the NNCT.

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, both are same in 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.

null.name

Name of the null values

alternative

Type of the alternative hypothesis in the test, one of "two.sided", "less", "greater"

method

Description of the hypothesis test

ct.name

Name of the contingency table, ct, returned by Znnself.ct only

data.name

Name of the data set, dat, returned by Znnself only

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

Zself.ref.ct, Zself.ref, Znnref.ct, Znnref, Xsq.spec.cor and Xsq.spec.cor.ct

Examples

n<-20
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.diag<-varNii.ct(ct,Qv,Rv)

Znnself(Y,cls)
Znnself(Y,cls,alt="g")

Znnself.ct(ct,VarN.diag)
Znnself.ct(ct,VarN.diag,alt="g")

Znnself(Y,cls,method="max")

ct<-scct(ipd,cls)
Znnself.ct(ct,VarN.diag)

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

Znnself(Y,fcls)
Znnself.ct(ct,VarN.diag)

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

W<-Wmat(ipd)
Qv<-Qvec(W)$q
Rv<-Rval(W)
VarN.diag<-varNii.ct(ct,Qv,Rv)

Znnself(Y,cls,alt="l")
Znnself.ct(ct,VarN.diag)
Znnself.ct(ct,VarN.diag,alt="l")


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