funs.class.spec: Class-specific Chi-square Tests based on NNCTs

funs.class.specR Documentation

Class-specific Chi-square Tests based on NNCTs

Description

Two functions: class.spec.ct and class.spec.

Both functions are objects of class "classhtest" but with different arguments (see the parameter list below). Each one performs class specific segregation tests for the rows if type="base" and columns if type="NN" for k \ge 2 classes. That is, each one performs hypothesis tests of deviations of entries in each row (column) of NNCT from the expected values under RL or CSR for each row (column) if type="base" ("NN"). Recall that row labels of the NNCT are base class labels and column labels in the NNCT are NN class labels. The test for each row (column) i is based on the chi-squared approximation of the corresponding quadratic form and are due to \insertCitedixon:NNCTEco2002;textualnnspat (\insertCiteceyhan:stat-neer-class2009;textualnnspat).

The argument covN must be covariance of row-wise (column-wise) vectorization of NNCT if type="base" (type="NN").

Each function yields the test statistic, p-value and df for each base class i, description of the alternative with the corresponding null values (i.e., expected values) for the row (column) i, estimates for the entries in row (column) i for i=1,\ldots,k if type="base" (type="NN"). The functions also provide names of the test statistics, the description of the test and the data set used.

The null hypothesis for each row (column) is that the corresponding N_{ij} entries in row (column) i are equal to their expected values under RL or CSR.

See also (\insertCitedixon:NNCTEco2002,ceyhan:stat-neer-class2009;textualnnspat) and the references therein.

Usage

class.spec.ct(ct, covN, type = "base")

class.spec(dat, lab, type = "base", ...)

Arguments

ct

A nearest neighbor contingency table, used in class.spec.ct only

covN

The k^2 \times k^2 covariance matrix of row-wise vectorized entries of NNCT, ct; used in class.spec.ct only.

type

The type of the class-specific tests with default="base". Takes on values"base" for (Dixon's) base class-specific test and"NN" for NN class-specific test.

dat

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

lab

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

...

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

Value

A list with the elements

type

Type of the class-specific test, which is "base" or "NN" for this function

statistic

The vector of class-specific test statistics

stat.names

Name of the test statistics

p.value

The vector of p-values for the hypothesis test

df

Degrees of freedom for the chi-squared test, which is k-1 for base class-specific test and k for NN class-specific test.

estimate

Estimates of the parameters, NNCT, i.e., the matrix of the observed N_{ij} values for base class-specific test and transpose of the NNCT for the NN class-specific test.

null.value

The matrix of hypothesized null values for the parameters which are expected values of the N_{ij} values for the base class-specific test and transpose of this matrix for the NN-class specific test.

null.name

Name of the null values

method

Description of the hypothesis test

ct.name

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

data.name

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

References

\insertAllCited

See Also

base.class.spec.ct, base.class.spec, NN.class.spec.ct and NN.class.spec

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<-var.nnct(ct,Qv,Rv)
covN<-cov.nnct(ct,varN,Qv,Rv) #default is byrow

class.spec(Y,cls)
class.spec(Y,cls,type="NN")

class.spec.ct(ct,covN)
class.spec.ct(ct,covN,type="NN")

class.spec(Y,cls,method="max")

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

class.spec(Y,fcls)
class.spec(Y,fcls,type="NN")

class.spec.ct(ct,covN)
class.spec.ct(ct,covN,type="NN")

#############
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<-var.nnct(ct,Qv,Rv)
covN<-cov.nnct(ct,varN,Qv,Rv)

class.spec(Y,cls)
class.spec(Y,cls,type="NN")

class.spec.ct(ct,covN)
class.spec.ct(ct,covN,type="NN")


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