funsZsegind: Z Tests for Segregation Indices

funsZsegindR Documentation

Z Tests for Segregation Indices

Description

Two functions: Zseg.ind.ct and Zseg.ind.

Both functions are objects of class "cellhtest" but with different arguments (see the parameter list below). Each one performs hypothesis tests of deviations of segregation indices from their expected values under RL or CSR for each segregation index in the NNCT. The test for each cell i,j is based on the normal approximation of the corresponding segregation index.

Each function yields a contingency table of the test statistics, p-values for the corresponding alternative, lower and upper confidence levels, sample estimates (i.e., observed values) and null value(s) (i.e., expected values) for the segregation indices and also names of the test statistics, estimates, null value, the description of the test, and the data set used.

The null hypothesis for each cell i,j is that the corresponding segregation index equal to the expected value (which is 0) under RL or CSR.

See also (\insertCiteceyhan:SiM-seg-ind2014;textualnnspat).

Usage

Zseg.ind.ct(
  ct,
  varN,
  inf.corr = FALSE,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95
)

Zseg.ind(
  dat,
  lab,
  inf.corr = FALSE,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95,
  ...
)

Arguments

ct

A nearest neighbor contingency table, used in Zseg.ind.ct only

varN

The variance matrix for cell counts in the NNCT, ct; used in Zseg.ind.ct only

inf.corr

A logical argument (default=FALSE). If TRUE, indices are modified so that they are finite and if FALSE the above definition in the description is used.

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 segregation indices

dat

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

lab

The vector of class labels (numerical or categorical), used in Zseg.ind only

...

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

Value

A list with the elements

statistic

The matrix of test statistics for the segregation indices

stat.names

Name of the test statistics

p.value

The matrix of p-values for the hypothesis test for the corresponding alternative

LCL, UCL

Matrix of lower and upper confidence levels for the segregation indices at the given confidence level conf.level and depends on the type of alternative.

cnf.lvl

Level of the upper and lower confidence limits of the segregation indices, provided in conf.level.

estimate

Estimate of the parameter, i.e., matrix of the observed segregation indices

est.name, est.name2

Names of the estimates, both are same in this function

null.value

Hypothesized values for the parameters, i.e., the null values of the segregation indices, which are all 0 under RL or CSR.

null.name

Name of the null value

alternative

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

method

Description of the hypothesis test

ct.name

Name of the contingency table, ct, returned by Zseg.ind.ct only

data.name

Name of the data set, dat, returned by Zseg.ind only

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

seg.ind and Zseg.coeff

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

seg.ind(ct)
seg.ind(ct,inf.corr=TRUE)
W<-Wmat(ipd)
Qv<-Qvec(W)$q
Rv<-Rval(W)
varN<-var.nnct(ct,Qv,Rv)
varN

Zseg.ind(Y,cls)
Zseg.ind(Y,cls,inf.corr=TRUE)
Zseg.ind.ct(ct,varN)

Zseg.ind(Y,cls,alt="g")
Zseg.ind.ct(ct,varN,alt="g")

Zseg.ind(Y,cls,method="max")

#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
Zseg.ind(Y,cls)

#############
n<-40
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
cls<-sample(1:4,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)
varN

Zseg.ind(Y,cls)
Zseg.ind(Y,cls,inf.corr = TRUE)

Zseg.ind.ct(ct,varN)
Zseg.ind.ct(ct,varN,inf.corr = TRUE)

#1D data points
n<-20  #or try sample(1:20,1)
X<-as.matrix(runif(n))# need to be entered as a matrix with one column
#(i.e., a column vector), hence X<-runif(n) would not work
ipd<-ipd.mat(X)
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)

Zseg.ind(X,cls)
Zseg.ind.ct(ct,varN)
Zseg.ind.ct(ct,varN,inf.corr=TRUE)


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