Learn R Programming

nnspat (version 0.1.2)

ZTrun: \(Z\)-test for Cuzick and Edwards \(T_{run}\) statistic

Description

An object of class "htest" performing a \(z\)-test for Cuzick and Edwards \(T_{run}\) test statistic which is based on the number of consecutive cases from the cases in the data under RL or CSR independence.

Under RL of \(n_1\) cases and \(n_0\) controls to the given locations in the study region, \(T_{run}\) approximately has \(N(E[T_{run}],Var[T_{run}])\) distribution for large \(n\).

The argument cc.lab is case-control label, 1 for case, 0 for control, if the argument case.lab is NULL, then cc.lab should be provided in this fashion, if case.lab is provided, the labels are converted to 0's and 1's accordingly.

The logical argument var.sim (default=FALSE) is for using the simulation estimated variance or the exact variance for the variance of \(T_{run}\) in its standardization. If var.sim=TRUE, the simulation estimated variance is used for \(Var[T_{run}]\) (see varTrun.sim), otherwise the exact variance (see varTrun) is used. Moreover, when var.sim=TRUE, the argument Nvar.sim represents the number of resamplings (without replacement) in the RL scheme, with default being 1000.

The function varTrun might take a very long time when data size is large (even larger than 50); in this case, it is recommended to use var.sim=TRUE in this function.

See also (cuzick:1990;textualnnspat) and the references therein.

Usage

ZTrun(
  dat,
  cc.lab,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95,
  case.lab = NULL,
  var.sim = FALSE,
  Nvar.sim = 1000,
  ...
)

Value

A list with the elements

statistic

The \(Z\) test statistic for the Cuzick and Edwards \(T_{run}\) test

p.value

The \(p\)-value for the hypothesis test for the corresponding alternative

conf.int

Confidence interval for the Cuzick and Edwards \(T_{run}\) value at the given confidence level conf.level and depends on the type of alternative.

estimate

Estimate of the parameter, i.e., the Cuzick and Edwards \(T_{run}\) value.

null.value

Hypothesized null value for the Cuzick and Edwards \(T_{run}\) value which is \(n_1 (n_1-1)/(n_0+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

data.name

Name of the data set, dat

Arguments

dat

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

cc.lab

Case-control labels, 1 for case, 0 for control

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 Cuzick and Edwards \(T_{run}\) statistic

case.lab

The label used for cases in the cc.lab (if cc.lab is not provided then the labels are converted such that cases are 1 and controls are 0), default is NULL.

var.sim

A logical argument (default is FALSE) to determine whether the simulation estimated variance or the exact variance be used for the variance of \(T_{run}\) in its standardization. If var.sim=TRUE, the simulation estimated variance is used for \(Var[T_{run}]\) (see varTrun.sim), otherwise the exact variance (see varTrun) is used.

Nvar.sim

The number of simulations, i.e., the number of resamplings under the RL scheme to estimate the variance of \(T_{run}\), used only when var.sim=TRUE.

...

are for further arguments, such as method and p, passed to the dist function.

Author

Elvan Ceyhan

References

See Also

ceTrun, ZceTk, and ZTcomb

Examples

Run this code
n<-20  #or try sample(1:20,1) #try also 40, 50, 60
set.seed(123)
Y<-matrix(runif(3*n),ncol=3)
cls<-sample(0:1,n,replace = TRUE)  #or try cls<-rep(0:1,c(10,10))

ZTrun(Y,cls)
ZTrun(Y,cls,method="max")
ZTrun(Y,cls,var.sim=TRUE)
ZTrun(Y,cls+1,case.lab = 2,alt="l") #try also ZTrun(Y,cls,conf=.9,alt="g")

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

Run the code above in your browser using DataLab