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

funsZdir.nnctR Documentation

Directional Segregation Test for Two Classes with Normal Approximation

Description

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

Both functions are objects of class "htest" but with different arguments (see the parameter list below). Each one performs hypothesis tests of equality of the expected value of the the difference between the phat estimates in a 2 \times 2 NNCT to the one under RL or CSR (which is -1/(n-1)) where phat estimates are N_{11}/n_1 and N_{21}/n_2. That is, each performs directional (i.e., one-sided) tests based on the 2 \times 2 NNCT (i.e., have the appropriate asymptotic sampling distribution) for completely mapped data. (See \insertCiteceyhan:jnps-NNCT-2010;textualnnspat for more detail).

The one-sided (or directional) test has two types, specified with the type argument, with default type="II". The second type is Z_{II}=(T_n-E T_n)/\sqrt{Var(T_n)} where T_n=N_{11}/n_1 - N_{21}/n_2 (which is the difference between phat values) and the first type is Z_I=U_n T_n where U_n=\sqrt{n_1 n_2/(C_1 C_2)}. Each test is based on the normal approximation of the Z_I and Z_{II} based on the 2 \times 2 NNCT and are due to \insertCiteceyhan:jnps-NNCT-2010nnspat.

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 phat values which is -1/(n-1) for this function and method and name of the data set used.

The null hypothesis is that all E[Z_{II}] = 0 and E[Z_I] converges to 0 as class sizes go to infinity (or T_n has mean equal to -1/(n-1) where n is the data size.

Usage

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

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

Arguments

ct

The NNCT, used in Zdir.nnct.ct only

covN

The k^2 \times k^2 covariance matrix of row-wise vectorized entries of NNCT

type

The type of the directional (i.e., one-sided) test with default="II". Takes on values "I" and "II" for types I and II directional tests (see the description above).

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 in phat estimates in the NNCT

dat

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

lab

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

...

are for further arguments, such as method and p, passed to the dist function. used in Zdir.nnct 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 an 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 an NNCT.

null.value

Hypothesized null value for the difference in phat values in an NNCT which is -1/(n-1) 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.ct only

data.name

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

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

Zdir.nnct.ss.ct, Zdir.nnct.ss, overall.nnct.ct and overall.nnct

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)

Zdir.nnct(Y,cls)
Zdir.nnct.ct(ct,covN)

Zdir.nnct(Y,cls,alt="g")
Zdir.nnct.ct(ct,covN,type="I",alt="l")

Zdir.nnct(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(Y,fcls)
Zdir.nnct.ct(ct,covN)

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


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