funsVarTrun: Variance of Cuzick and Edwards T_{run} Test statistic

funsVarTrunR Documentation

Variance of Cuzick and Edwards T_{run} Test statistic

Description

Two functions: varTrun and varTrun.sim.

The function varTrun computes the (finite sample) variance of 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. And the function varTrun.sim estimates this variance based on simulations under the RL hypothesis.

The only common argument for both functions is dat, the data set used in the functions.

n_1 is an argument for varTrun and is the number of cases (denoted as n1 as an argument). The number of cases are denoted as n_1 and number of controls as n_0 in this function to match the case-control class labeling, which is just the reverse of the labeling in \insertCitecuzick:1990;textualnnspat.

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 argument Nsim represents the number of resamplings (without replacement) in the RL scheme, with default being 1000. cc.lab, case.lab and Nsim are arguments for varTrun.sim only.

The function varTrun might take a very long time when data size is large (even larger than 50), hence the need for the varTrun.sim function.

See (\insertCitecuzick:1990;textualnnspat).

Usage

varTrun(dat, n1, ...)

varTrun.sim(dat, cc.lab, Nsim = 1000, case.lab = NULL)

Arguments

dat

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

n1

Number of cases, used in varTrun only.

...

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

cc.lab

Case-control labels, 1 for case, 0 for control, used in varTrun.sim only.

Nsim

The number of simulations, i.e., the number of resamplings under the RL scheme to estimate the variance of T_{run}, used in varTrun.sim only.

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, used in varTrun.sim only.

Value

The function varTrun returns the variance of Cuzick and Edwards T_{run} test statistic under RL or CSR independence. And the function varTrun.sim estimates the same variance based on simulations under the RL hypothesis.

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

ceTrun and EV.Trun

Examples

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)
n1<-sum(cls==1)
n0<-sum(cls==0)
c(n1,n0)

varTrun(Y,n1)
varTrun(Y,n1,method="max")

n<-15  #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)
n1<-sum(cls==1)
varTrun(Y,n1) #the actual value (might take a long time if n is large)

Nmc<-1000
varTrun.sim(Y,cls,Nsim=Nmc)

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


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