spatial_data: Simulate random data for SRR function

View source: R/spatial_data.R

spatial_dataR Documentation

Simulate random data for SRR function

Description

Generate random two-group data for a spatial relative risk function.

Usage

spatial_data(
  win = spatstat.geom::unit.square(),
  sim_total = 2,
  x_case,
  y_case,
  samp_case = c("uniform", "MVN", "CSR", "IPP"),
  samp_control = c("uniform", "systematic", "MVN", "CSR", "IPP", "clustered"),
  x_control = NULL,
  y_control = NULL,
  n_case = NULL,
  n_control = NULL,
  npc_control = NULL,
  r_case = NULL,
  r_control = NULL,
  s_case = NULL,
  s_control = NULL,
  l_case = NULL,
  l_control = NULL,
  e_control = NULL,
  ...
)

Arguments

win

Window in which to simulate the random data. An object of class "owin" or something acceptable to as.owin.

sim_total

Integer, specifying the number of simulation iterations to perform.

x_case

Numeric value, or numeric vector, of x-coordinate(s) of case cluster(s).

y_case

Numeric value, or numeric vector, of y-coordinate(s) of case cluster(s).

samp_case

Character string specifying whether to randomize the case locations uniformly (samp_control = "uniform"), multivariate normal (samp_control = "MVN"), with complete spatial randomness (samp_control = "CSR"), or using the inhomogeneous Poisson process (samp_control = "IPP") around each case centroid.

samp_control

Character string specifying whether to randomize the control locations uniformly (samp_control = "uniform"), systematically (samp_control = "systematic"), multivariate normal (samp_control = "MVN"), with complete spatial randomness (samp_control = "CSR"), using the inhomogeneous Poisson process (samp_control = "IPP"), or a realization of the Neyman-Scott cluster process (samp_control = "clustered").

x_control

Numeric value, or numeric vector, of x-coordinate(s) of case cluster(s). Ignored if samp_control != "MVN".

y_control

Numeric value, or numeric vector, of y-coordinate(s) of case cluster(s). Ignored if samp_control != "MVN".

n_case

Numeric value, or numeric vector, of the sample size for case locations in each cluster.

n_control

Numeric value, or numeric vector, of the sample size for control locations in each cluster.

npc_control

Optional. Numeric value of the number of clusters of control locations. Ignored if samp_control != "clustered".

r_case

Optional. Numeric value, or numeric vector, of radius (radii) of case cluster(s) in the units of win. Ignored if samp_case = "MVN".

r_control

Optional. Numeric value, or numeric vector, of radius (radii) of control cluster(s) in the units of win. Ignored if samp_control != "clustered".

s_case

Optional. Numeric value, or numeric vector, for the standard deviation(s) of the multivariate normal distribution for case locations in the units of win. Ignored if samp_control != "MVN".

s_control

Optional. Numeric value, or numeric vector, for the standard deviation(s) of the multivariate normal distribution for control locations in the units of win. Ignored if samp_control != "MVN".

l_case

Optional. A single positive number, a vector of positive numbers, a function(x,y, ...), or a pixel image. Intensity of the Poisson process for case clusters. Ignored if samp_control != "IPP".

l_control

Optional. A single positive number, a vector of positive numbers, a function(x,y, ...), or a pixel image. Intensity of the Poisson process for control clusters. Ignored if samp_control = "uniform", samp_control = "systematic", samp_control = "MVN", or samp_control = "CSR".

e_control

Optional. A single non-negative number for the size of the expansion of the simulation window for generating parent points. Ignored if samp_control != "clustered".

...

Arguments passed to runifdisc, disc, rpoispp, rsyst, or rNeymanScott depending on samp_control or samp_control.

Details

This function generates random data for a spatial relative risk function (nonparametric estimate of relative risk by kernel smoothing) using various random point pattern generators from the spatstat.random package to generate data.

If samp_case = "uniform" the case locations are randomly generated uniformly within a disc of radius r_case (or discs of radii r_case) centered at coordinates (x_case, y_case).

If samp_case = "MVN" the case locations are randomly generated assuming a multivariate normal distribution centered at coordinates (x_case, y_case) with a standard deviation of s_case.

If samp_case = "CSR" the case locations are randomly generated assuming complete spatial randomness (homogeneous Poisson process) within a disc of radius r_case (or discs of radii r_case) centered at coordinates (x_case, y_case) with lambda = n_case / area of disc.

If samp_case = "IPP" the case locations are randomly generated assuming an inhomogeneous Poisson process with a disc of radius r_case (or discs of radii r_case) centered at coordinates (x_case, y_case) with lambda = l_case, a function.

If samp_control = "uniform" the control locations are randomly generated uniformly within the window win.

If samp_control = "systematic" the control locations are randomly generated systematically within the window win consisting of a grid of equally-spaced points with a random common displacement.

If samp_control = "MVN" the control locations are randomly generated assuming a multivariate normal distribution centered at coordinates (x_control, y_control) with a standard deviation of s_control.

If samp_control = "CSR" the control locations are randomly generated assuming complete spatial randomness (homogeneous Poisson process) within the window win with a lambda = n_control / [resolution x resolution]. By default, the resolution is an integer value of 128 and can be specified using the resolution argument in the internally called risk function.

If samp_control = "IPP" the control locations are randomly generated assuming an inhomogeneous Poisson process within the window win with a lambda = l_control, a function.

If samp_control = "clustered" the control locations are randomly generated with a realization of the Neyman-Scott process within the window win with the intensity of the Poisson process cluster centres (kappa = l_control), the size of the expansion of the simulation window for generative parent points (e_control), and the radius (or radii) of the disc for each cluster (r_control).

Value

An object of class "ppplist". This is a list of marked point patterns that have a single mark with two levels: case and control.

See Also

runifdisc, disc, rpoispp, rsyst, or rNeymanScott for additional arguments for random point pattern generation.

Examples

 spatial_data(x_case = c(0.25, 0.5, 0.75),
              y_case = c(0.75, 0.25, 0.75),
              samp_case = "MVN", 
              samp_control = "MVN",
              x_control = c(0.25, 0.5, 0.75),
              y_control = c(0.75, 0.25, 0.75),
              n_case = 100,
              n_control = c(100,500,300),
              s_case = c(0.05,0.01,0.05),
              s_control = 0.05,
              verbose = FALSE)
 


sparrpowR documentation built on May 29, 2024, 12:02 p.m.