funsZdir.nnct.ss {nnspat} | R 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)\sqrt{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 Ceyhan (2010)).
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 Ceyhan (2010) 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 (Bickel and Doksum 1977).
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 |
alternative |
Type of the alternative hypothesis in the test, one of |
conf.level |
Level of the 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 the NNCT
at the given confidence level |
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 |
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
Bickel PJ, Doksum AK (1977).
Mathematical Statistics, Basic Ideas and Selected Topics.
Prentice Hall, Englewood Cliffs, NJ.
Ceyhan E (2010).
“Directional clustering tests based on nearest neighbour contingency tables.”
Journal of Nonparametric Statistics, 22(5), 599-616.
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)