funsZnnref {nnspat}R Documentation

Z Tests for NN Reflexivity

Description

Two functions: Znnref.ct and Znnref.

Both functions are objects of class "refhtest" 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 NN reflexivity test (i.e., a test of self reflexivity and a test of mixed non-reflexivity, corresponding to 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 Ceyhan and Bahadir (2017) for more detail).

The reflexivity test is based on the normal approximation of the diagonal entries in the RCT and are due to Ceyhan and Bahadir (2017).

Each function yields the test statistics, p-values for the corresponding alternative, expected values (i.e., null value(s)), confidence intervals and sample estimates (i.e., observed values)for the self reflexivity and mixed non-reflexivity values (i.e., entries (1,1) and (2,2) values, respectively) in the RCT. Each function also gives names of the test statistics, null values, the description of the test, and the data set used.

The null hypothesis is that E(N_{11})=R P_{aa} and E(N_{22})=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.

The Znnref functions (i.e., Znnref.ct and Znnref) are different from the Znnself functions (i.e., Znnself.ct and Znnself) 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). Znnref functions are for testing the self reflexivity and mixed non-reflexivity using the diagonal entries in the RCT while Znnself functions are testing the self reflexivity at a class-specific level (i.e., for each class) using the first column in the SCCT, and Zself.ref functions are for testing the self reflexivity for the entire data set using entry (1,1) in 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

Znnref.ct(
  rfct,
  nvec,
  Qv,
  Tv,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95
)

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

Arguments

rfct

An RCT, used in Znnref.ct only

nvec

The vector of class sizes, used in Znnref.ct only

Qv

The number of shared NNs, used in Znnref.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 Znnref.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 difference of the off-diagonal entries, N_{12}-N_{21}

dat

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

lab

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

...

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

Value

A list with the elements

statistic

The Z test statistics for self reflexivity and mixed non-reflexivity, corresponding to entries (1,1) and (2,2) in the RCT

stat.names

Name of the test statistics

p.value

The p-values for self reflexivity and mixed non-reflexivity tests

conf.int

Confidence intervals for the self reflexivity and mixed non-reflexivity values (i.e., diagonal entries (1,1) and (2,2) values, respectively) in the RCT at the given confidence level conf.level and depends on the type of alternative.

cnf.lvl

Level of the onfidence intervals of the diagonal entries, provided in conf.level.

estimate

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

null.value

Hypothesized null values for the self reflexivity and mixed non-reflexivity values (i.e., expected values of the diagonal entries (1,1) and (2,2) values, which are E(N_{11})=R P_{aa} and E(N_{22})=R P_{ab}, respectively) in the RCT.

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, rfct, returned by Znnref.ct only

data.name

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

Author(s)

Elvan Ceyhan

References

Ceyhan E, Bahadir S (2017). “Nearest Neighbor Methods for Testing Reflexivity.” Environmental and Ecological Statistics, 24(1), 69-108.

See Also

Znnself.ct, Znnself, Zmixed.nonref.ct, Zmixed.nonref, Xsq.nnref.ct and Xsq.nnref

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
Rv<-Rval(W)
Tv<-Tval(W,Rv)

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

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

Znnref.ct(rfct,nvec,Qv,Tv)
Znnref.ct(rfct,nvec,Qv,Tv,alt="g")

#############
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)

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

Znnref.ct(rfct,nvec,Qv,Tv)
Znnref.ct(rfct,nvec,Qv,Tv,alt="l")


[Package nnspat version 0.1.2 Index]