View source: R/spatial_power.R

spatial_power | R Documentation |

Compute the statistical power of a spatial relative risk function using randomly generated data.

```
spatial_power(
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,
alpha = 0.05,
p_correct = "none",
verbose = TRUE,
parallel = FALSE,
n_core = 2,
...,
cascon = lifecycle::deprecated(),
lower_tail = lifecycle::deprecated(),
upper_tail = lifecycle::deprecated()
)
```

This function computes the statistical power of the spatial relative risk function (nonparametric estimate of relative risk by kernel smoothing) for randomly generated data using various random point pattern generators from the `spatstat.random`

package.

The function uses the `risk`

function to estimate the spatial relative risk function and forces the `tolerate`

argument to be TRUE in order to calculate asymptotic p-values.

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`

).

The function computes a one-sided hypothesis test for case clustering (`alpha = 0.05`

by default). The function also computes a two-sided hypothesis test for case clustering and control clustering (lower tail = 0.025 and upper tail = 0.975).

The function has functionality for a correction for multiple testing. If `p_correct = "FDR"`

, calculates a False Discovery Rate by Benjamini and Hochberg. If `p_correct = "Sidak"`

, calculates a Sidak correction. If `p_correct = "Bonferroni"`

, calculates a Bonferroni correction. If `p_correct = "none"`

(the default), then the function does not account for multiple testing and uses the uncorrected `alpha`

level. See the internal `pval_correct`

function documentation for more details.

An object of class "list". This is a named list with the following components:

`sim`

An object of class 'rrs' for the first iteration of simulated data.

`out`

An object of class 'rrs' for the observed spatial relative risk function without randomization.

`rr_mean`

Vector of length

`[resolution x resolution]`

of the mean relative risk values at each gridded knot.`pval_mean`

Vector of length

`[resolution x resolution]`

of the mean asymptotic p-value at each gridded knot.`rr_sd`

Vector of length

`[resolution x resolution]`

of the standard deviation of relative risk values at each gridded knot.`pval_prop_cascon`

Vector of length

`[resolution x resolution]`

of the proportion of asymptotic p-values that were significant for both case and control locations at each gridded knot.`pval_prop_cas`

Vector of length

`[resolution x resolution]`

of the proportion of asymptotic p-values that were significant for only case locations at each gridded knot.`rx`

Vector of length

`[resolution x resolution]`

of the x-coordinates of each gridded knot.`ry`

Vector of length

`[resolution x resolution]`

of the y-coordinates of each gridded knot.`n_cas`

Vector of length

`sim_total`

of the number of case locations simulated in each iteration.`n_con`

Vector of length

`sim_total`

of the number of control locations simulated in each iteration.`bandw`

Vector of length

`sim_total`

of the bandwidth (of numerator) used in each iteration.`s_obs`

Vector of length

`sim_total`

of the global s statistic.`t_obs`

Vector of length

`sim_total`

of the global t statistic.`alpha`

Vector of length

`sim_total`

of the (un)corrected critical p-values.

```
spatial_power(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)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.