funsZdir.nnct.ss: Directional Segregation Test for Two Classes with Normal...

funsZdir.nnct.ssR Documentation

Directional Segregation Test for Two Classes with Normal Approximation (for Sparse Sampling)

Description

Two functions: Zdir.nnct.ss.ct and Zdir.nnct.ss.

Both functions are objects of class "htest" but with different arguments (see the parameter list below). Each one performs hypothesis tests of independence in the 2 \times 2 NNCT which implies Z_P=0 or equivalently N_{11}/n_1=N_{21}/n_2. Z_P=(N_{11}/n_1-N_{21}/n_2)√{n_1 n_2 n/(C_1 C_2)} where N_{ij} is the cell count in entry i,j, n_i is the sum of row i (i.e. size of class i), c_j is the sum of column j in the 2 \times 2 NNCT; N_{11}/n_1 and N_{21}/n_2 are also referred to as the phat estimates in row-wise binomial framework for 2 \times 2 NNCT (see \insertCiteceyhan:jnps-NNCT-2010;textualnnspat).

That is, each performs directional (i.e. one-sided) tests based on the 2 \times 2 NNCT and is appropriate (i.e. have the appropriate asymptotic sampling distribution) when that data is obtained by sparse sampling. (See \insertCiteceyhan:jnps-NNCT-2010;textualnnspat for more detail).

Each test is based on the normal approximation of Z_P which is the directional Z-tests for the chi-squared tests of independence for the contingency tables \insertCitebickel:1977nnspat.

Each function yields the test statistic, p-value for the corresponding alternative, the confidence interval, sample estimate (i.e. observed value) and null (i.e., expected) value for the difference in the phat values (which is 0 for this test) in an NNCT, and method and name of the data set used.

The null hypothesis is that E[Z_P] = 0 or equivalently N_{11}/n_1 = N_{21}/n_2.

Usage

Zdir.nnct.ss.ct(
  ct,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95
)

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

Arguments

ct

The NNCT, used in Zdir.nnct.ss.ct only

alternative

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

conf.level

Level of the confidence limits, default is 0.95, for the difference in phat values in the NNCT

dat

The data set in one or higher dimensions, each row corresponds to a data point, used in Zdir.nnct.ss only

lab

The vector of class labels (numerical or categorical), used in Zdir.nnct.ss only

...

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

Value

A list with the elements

statistic

The Z test statistic for the directional (i.e. one-sided) test of segregation based on the NNCT

p.value

The p-value for the hypothesis test for the corresponding alternative

conf.int

Confidence interval for the difference in phat values in the NNCT at the given confidence level conf.level and depends on the type of alternative.

estimate

Estimate of the parameter, i.e., the observed difference in phat values in the NNCT.

null.value

Hypothesized null value for the difference in phat values in the NNCT which is 0 for this function.

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 Zdir.nnct.ss.ct only

data.name

Name of the data set, dat, returned by Zdir.nnct.ss only

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

Zdir.nnct.ct, Zdir.nnct, Pseg.ss.ct and Pseg.ss

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

Zdir.nnct.ss(Y,cls)
Zdir.nnct.ss.ct(ct)
Zdir.nnct.ss(Y,cls,alt="g")

Zdir.nnct.ss(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)

Zdir.nnct.ss(Y,fcls)
Zdir.nnct.ss.ct(ct)

#############
ct<-matrix(1:4,ncol=2)
Zdir.nnct.ss.ct(ct) #gives an error message if ct<-matrix(1:9,ncol=3)


nnspat documentation built on Aug. 30, 2022, 9:06 a.m.