funsZdir.nnct {nnspat} | R 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 Ceyhan (2010) 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 (Ceyhan 2010).
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 |
covN |
The |
type |
The type of the directional (i.e., one-sided) test with default= |
alternative |
Type of the alternative hypothesis in the test, one of |
conf.level |
Level of the upper and lower confidence limits, default is |
dat |
The data set in one or higher dimensions, each row corresponds to a data point,
used in |
lab |
The |
... |
are for further arguments, such as |
Value
A list
with the elements
statistic |
The |
p.value |
The |
conf.int |
Confidence interval for the difference in phat values in an NNCT
at the given confidence level |
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 |
alternative |
Type of the alternative hypothesis in the test, one of |
method |
Description of the hypothesis test |
ct.name |
Name of the contingency table, |
data.name |
Name of the data set, |
Author(s)
Elvan Ceyhan
References
Ceyhan E (2010). “Directional clustering tests based on nearest neighbour contingency tables.” Journal of Nonparametric Statistics, 22(5), 599-616.
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)