View source: R/NNCTFunctions.r
| rnonRLI | R Documentation |
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=FALSEALSE.
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.
rnonRLI(dat, prop = 0.5, k, rho, poisson = FALSE, init.from.cases = TRUE)
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 |
k |
An integer representing the number of NNs considered for each initial case, i.e., |
rho |
A parameter for labeling the |
poisson |
A logical argument (default is |
init.from.cases |
A logical argument (default is |
A list with the elements
pat.type |
|
type |
The type of the point pattern |
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, |
init.cases |
The initial cases in the data set, |
gen.points,ref.points |
Both are |
desc.pat |
Description of the point pattern |
mtitle |
The |
num.points |
The |
xlimit,ylimit |
The possible ranges of the x- and y-coordinates of the generated and the reference points |
Elvan Ceyhan
rnonRLII, rnonRLIII, rnonRLIV, and rnonRL
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.