rnonRLI: Type I Non-Random Labeling of a Given Set of Points

View source: R/NNCTFunctions.R

rnonRLIR Documentation

Type I Non-Random Labeling of a Given Set of Points

Description

An object of class "SpatPatterns".

Given the set of n points, dat, in a region, this function assigns n_1=round(n*prop,0) of them as cases, and the rest as controls with first selecting a point, Z_i, as a case and assigning the label case to the remaining points with infection probabilities prob=c(prop+((1-prop)*rho)/(1:k)) where rho is a parameter adjusting the NN dependence of infection probabilities. The number of cases will be n_1 on the average if the argument poisson=TRUE (i.e., n_1=rpois(1,round(n*prop,0))), otherwise n_1=round(n*prop,0). We stop when we first exceed n_1 cases. rho must be between -prop/(1-prop) and 1 for the infection probabilities to be valid. The init.from.cases is a logical argument (with default=TRUE) to determine the initial cases are from the cases or controls (the first initial case is always from controls), so, if TRUE, initial cases (other than the first initial case) are selected randomly among the cases (as if they are contagious), otherwise, they are selected from controls as new cases infecting their kNNs. otherwise first entry is chosen as the case (or case is recorded as the first entry) in the data set, dat.

Algorithmically, first all dat points are treated as non-cases (i.e., controls or healthy subjects). Then the function follows the following steps for labeling of the points:

step 0: n_1 is generated randomly from a Poisson distribution with mean = n*prop, so that the average number of cases is n*prop.

step 0: n_1 is generated randomly from a Poisson distribution with mean = round(n*prop,0), so that the average number of cases will be round(n*prop,0) if the argument poisson=TRUE, else n_1=round(n*prop,0).

step 1: Initially, one point from dat is selected randomly as a case. In the first round this point is selected from the controls, and the subsequent rounds, it is selected from cases if the argument init.from.cases=TRUE, and from controls otherwise. Then it assigns the label case to the kNNs among controls of the initial case selected in step 1 with infection probabilities prob=c(prop+((1-prop)*rho)/(1:k)), see the description for the details of the parameters in the prob.

step 2: Then this initial case and cases among its kNNs (possibly all k+1 points) in step 2 are removed from the data, and for the remaining control points step 1 is applied where initial point is from cases or control based on the argument init.from.cases.

step 3: The procedure ends when number of cases n_c exceeds n_1, and n_c-n_1 of the cases (other than the initial cases) are randomly selected and relabeled as controls, i.e., 0s, so that the number of cases is exactly n_1.

In the output cases are labeled as 1 and controls as 0. Note that the infection probabilities of the kNNs of each initial case increase with increasing rho, and infection probability decreases for increasing k in the kNNs.

See \insertCiteceyhan:SiM-seg-ind2014;textualnnspat for more detail where type I non-RL pattern is the case 1 of non-RL pattern considered in Section 6 with n_1 is fixed as a parameter rather than being generated from a Poisson distribution and init=FALSE.

Although the non-RL pattern is described for the case-control setting, it can be adapted for any two-class setting when it is appropriate to treat one of the classes as cases or one of the classes behave like cases and other class as controls.

Usage

rnonRLI(dat, prop = 0.5, k, rho, poisson = FALSE, init.from.cases = TRUE)

Arguments

dat

A set of points the non-RL procedure is applied to obtain cases and controls randomly in the type I fashion (see the description).

prop

A real number between 0 and 1 (inclusive) representing the proportion of new cases (on the average) infected by the initial cases, i.e., number of newly infected cases (in addition to the initial cases) is Poisson with mean=round(n*prop) where n is the number of points in dat, if the argument poisson=TRUE, else it is round(n*prop).

k

An integer representing the number of NNs considered for each initial case, i.e., kNNs of each initial case are candidates to be infected to become cases.

rho

A parameter for labeling the kNNs of each initial case as cases such that kNNs of each initial case is infected with decreasing probabilities prob=c(prop+((1-prop)*rho)/(1:k)) where rho has to be between -prop/(1-prop) and 1 for prob to be a vector of probabilities.

poisson

A logical argument (default is FALSE) to determine whether the number of cases n_1, will be random or fixed. If poisson=TRUE then the n_1 is from a Poisson distribution, n_1=rpois(1,round(n*prop,0)) otherwise it is fixed, n_1=round(n*prop,0).

init.from.cases

A logical argument (default is TRUE) to determine whether the initial cases at each round will be take from cases or controls. At first round, the initial cases are taken from controls. And in the subsequent rounds, the initial cases are taken from cases if init.from.cases=TRUE, and from controls otherwise.

Value

A list with the elements

pat.type

="cc" for the case-control patterns for RL or non-RL of the given data points, dat

type

The type of the point pattern

parameters

prop, rho, and k values for this non-RL pattern, see the description for these parameters.

dat.points

The set of points non-RL procedure is applied to obtain cases and controls randomly in the type I fashion

lab

The labels of the points as 1 for cases and 0 for controls after the type I nonRL procedure is applied to the data set, dat. Cases are denoted as red dots and controls as black circles in the plot.

init.cases

The initial cases in the data set, dat. Marked with red crosses in the plot of the points.

gen.points, ref.points

Both are NULL for this function, as initial set of points, dat, are provided for the non-RL procedure.

desc.pat

Description of the point pattern

mtitle

The "main" title for the plot of the point pattern

num.points

The vector of two numbers, which are the number of cases and controls.

xlimit, ylimit

The possible ranges of the x- and y-coordinates of the generated and the reference points

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

rnonRLII, rnonRLIII, rnonRLIV, and rnonRL

Examples

n<-40;  #try also n<-20; n<-100;
#data generation
dat<-cbind(runif(n,0,1),runif(n,0,1))

prop<-.5; #try also .25, .75
rho<- .3
knn<-3 #try 2 or 5

Xdat<-rnonRLI(dat,prop,knn,rho,poisson=FALSE,init=FALSE) 
#labeled data try also poisson=TRUE or init=FALSE
Xdat

table(Xdat$lab)

summary(Xdat)
plot(Xdat,asp=1)
plot(Xdat)

#normal original data
n<-40;  #try also n<-20; n<-100;
#data generation
dat<-cbind(rnorm(n,0,1),rnorm(n,0,1))

prop<-.50; #try also .25, .75
rho<- .3
knn<-5 #try 2 or 3

Xdat<-rnonRLI(dat,prop,knn,rho,poisson=FALSE) #labeled data try also poisson=TRUE
Xdat

table(Xdat$lab)

summary(Xdat)
plot(Xdat,asp=1)
plot(Xdat)


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