View source: R/NNCTFunctions.R
rnonRLIII | 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=rho (1-d_{ij}/d_{\max})^{pow}
where d_{ij}
is the
distance from Z_j
to Z_i
for j \ne i
, d_{\max}
is the maximum of d_{ij}
values, rho
is a scaling parameter for
the infection probabilities and pow
is a parameter in the power adjusting the distance dependence.
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
has to be positive for prob
to be a vector
of probabilities,
and for a given rho
, pow
must be > - \ln(rho)/\ln(1-d_{ij}/d_{\max})
,
also when pow
is given, rho
must be < (1-d_{ij}/d_{\max})^{-pow}
.
If rand.init=TRUE
, initial case is selected randomly among the data points,
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 = 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 as a case.
The selection of initial case is determined based on the argument rand.init
(with default=TRUE
)
where if rand.init=TRUE
then the initial case is selected randomly from the data points, and if rand.init=
FALSE
, the first entry in the data set, dat
, is selected as the case.
step 2: Then it assigns the label case to the remaining points
with infection probabilities prob=rho (1-d_{ij}/d_{\max})^{pow}
, see the description for the details
of the parameters in the prob
.
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 contagious case) 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, and initial contagious case is marked with a red cross
in the plot of the pattern.
Note that the infection probabilities of the points is inversely proportional to their distances to the
initial case and increase with increasing rho
.
This function might take a long time for certain choices of the arguments. For example, if pow
is taken to be
too large, the infection probabilities would be too small, and case assignment will take a rather long time.
See \insertCiteceyhan:SiM-seg-ind2014;textualnnspat for more detail where type III non-RL pattern is the
case 3 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 k_{den}=1
and pow
is represented as k_{pow}
.
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.
rnonRLIII(dat, prop, rho, pow, rand.init = TRUE, poisson = FALSE)
dat |
A set of points the non-RL procedure is applied to obtain cases and controls randomly in the type III 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 case, i.e., number of newly infected cases (in addition to the first case) is Poisson
with |
rho |
A scaling parameter for the probabilities of labeling the points as cases (see the description). |
pow |
A parameter in the power adjusting the distance dependence in the probabilities of labeling the points as cases (see the description). |
rand.init |
A logical argument (default is |
poisson |
A logical argument (default is |
A list
with the elements
pat.type |
|
type |
The type of the point pattern |
parameters |
rho and pow, where |
dat.points |
The set of points non-RL procedure is applied to obtain cases and controls randomly in the type III fashion |
lab |
The labels of the points as 1 for cases and 0 for controls after the type III nonRL procedure is
applied to the data set, |
init.cases |
The initial case in the data set, |
cont.cases |
The contagious 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 |
Elvan Ceyhan
rnonRLI
, rnonRLII
, rnonRLIV
, and rnonRL
n<-40; #try also n<-20; n<-100;
prop<- .5; #try also .25, .75
#data generation
dat<-cbind(runif(n,0,1),runif(n,0,1))
rho<-.8
pow<-2
Xdat<-rnonRLIII(dat,prop,rho,pow,poisson=FALSE) #labeled data, try also poisson=TRUE
Xdat
table(Xdat$lab)
summary(Xdat)
plot(Xdat,asp=1)
plot(Xdat)
#normal original data
n<-40; #try also n<-20; n<-100;
dat<-cbind(rnorm(n,0,1),rnorm(n,0,1))
prop<- .5; #try also .25, .75
rho<-.8
pow<-2
Xdat<-rnonRLIII(dat,prop,rho,pow,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.