funsXsq.nnref: Reflexivity Test with Chi-square Approximation

funsXsq.nnrefR Documentation

Reflexivity Test with Chi-square Approximation

Description

Two functions: Xsq.nnref.ct and Xsq.nnref.

Both functions are objects of class "Chisqtest" but with different arguments (see the parameter list below). Each one performs hypothesis tests of equality of the expected values of the diagonal cell counts (i.e., entries) under RL or CSR in the RCT for k \ge 2 classes. That is, each test performs an overall NN reflexivity test (for the vector of entries (1,1) and (2,2), respectively, in the RCT) which is appropriate (i.e., have the appropriate asymptotic sampling distribution) for completely mapped data. (See \insertCiteceyhan:NNreflexivity2017;textualnnspat for more detail).

Each reflexivity test is based on the chi-squared approximation of the corresponding quadratic form for the vector of diagonal entries in the RCT and are due to \insertCiteceyhan:NNreflexivity2017;textualnnspat.

Each function yields the test statistic, p-value and df which is 2, description of the alternative with the corresponding null values (i.e., expected values) of the diagonal entries and also the sample estimates (i.e., observed values) of the diagonal entries of RCT (as a vector). The functions also provide names of the test statistics, the description of the test and the data set used.

The null hypothesis is that E(N_{11},N_{22})=(R P_{aa},R P_{ab}) in the RCT, where R is the number of reflexive NNs and P_{aa} is the probability of any two points selected are being from the same class and P_{ab} is the probability of any two points selected are being from two different classes.

Usage

Xsq.nnref.ct(rfct, nvec, Qv, Tv)

Xsq.nnref(dat, lab, ...)

Arguments

rfct

An RCT, used in Xsq.nnref.ct only

nvec

The vector of class sizes, used in Xsq.nnref.ct only

Qv

The number of shared NNs, used in Xsq.nnref.ct only

Tv

T value, which is the number of triplets (z_i, z_j, z_k) with NN(z_i) = NN(z_j) = z_k and NN(z_k) = z_j where NN(\cdot) is the nearest neighbor function, used in Xsq.nnref.ct only.

dat

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

lab

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

...

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

Value

A list with the elements

statistic

The chi-squared test statistic for overall NN reflexivity test

p.value

The p-value for the hypothesis test

df

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

estimate

Estimates of the parameters, i.e., the observed diagonal entries (1,1) and (2,2) in the RCT, rfct.

est.name, est.name2

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

null.value

Hypothesized null values for the diagonal entries (1,1) and (2,2) in the RCT, which are E(N_{11})=R P_{aa} and E(N_{22})=R P_{ab}, respectively).

method

Description of the hypothesis test

ct.name

Name of the contingency table, rfct, returned by Xsq.nnref.ct only

data.name

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

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

Znnref.ct, Znnref, Zself.ref.ct, Zself.ref, Zmixed.nonref.ct and Zmixed.nonref

Examples

n<-20  #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
cls<-sample(1:2,n,replace = TRUE)  #or try cls<-rep(1:2,c(10,10))

ipd<-ipd.mat(Y)
W<-Wmat(ipd)
Qv<-Qvec(W)$q
R<-Rval(W)
Tv<-Tval(W,R)

nvec<-as.numeric(table(cls))
rfct<-rct(ipd,cls)

Xsq.nnref(Y,cls)
Xsq.nnref.ct(rfct,nvec,Qv,Tv)

Xsq.nnref(Y,cls,method="max")

#############
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)
W<-Wmat(ipd)
Qv<-Qvec(W)$q
R<-Rval(W)
Tv<-Tval(W,R)

nvec<-as.numeric(table(cls))
rfct<-rct(ipd,cls)

Xsq.nnref(Y,cls)
Xsq.nnref.ct(rfct,nvec,Qv,Tv)


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