MyNixOS website logo
Description

Power Analysis to Detect Spatial Relative Risk Clusters.

Calculate the statistical power to detect clusters using kernel-based spatial relative risk functions that are estimated using the 'sparr' package. Details about the 'sparr' package methods can be found in the tutorial: Davies et al. (2018) <doi:10.1002/sim.7577>. Details about kernel density estimation can be found in J. F. Bithell (1990) <doi:10.1002/sim.4780090616>. More information about relative risk functions using kernel density estimation can be found in J. F. Bithell (1991) <doi:10.1002/sim.4780101112>.

sparrpowR: Power analysis to detect spatial relative clusters

R-CMD-check CRAN status CRAN version CRAN RStudio mirror downloads total CRAN RStudio mirror downloads monthly License GitHub last commit DOI

Date repository last updated: January 23, 2024

Overview

The sparrpowR package is a suite of R functions to calculate the statistical power to detect clusters using the kernel-based spatial relative risk function that is estimated using the sparr package. Basic visualization is also supported.

Installation

To install the release version from CRAN:

install.packages("sparrpowR")

To install the development version from GitHub:

devtools::install_github("machiela-lab/sparrpowR")

Available functions

FunctionDescription
spatial_powerMain function. Compute the statistical power of a spatial relative risk function using randomly generated data.spatial_dataGenerate random bivariate data for a spatial relative risk function.jitter_powerCompute the statistical power of a spatial relative risk function using previously collected data.spatial_plotsEasily make multiple plots from spatial_power, spatial_data, and jitter_power outputs.pval_correctCalled within spatial_power and jitter_power, calculates various multiple testing corrections for the alpha level.

Authors

  • Ian D. Buller - Social & Scientific Systems, Inc., a division of DLH Corporation, Silver Spring, Maryland (current) - Occupational and Environmental Epidemiology Branch, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland (original) - GitHub - ORCID

  • Derek W. Brown - Integrative Tumor Epidemiology Branch, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland (original) - GitHub - ORCID

See also the list of contributors who participated in this package, including:

  • Tim A. Myers - Laboratory of Genetic Susceptibility, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland - GitHub

Usage

set.seed(1234) # for reproducibility

# ------------------ #
# Necessary packages #
# ------------------ #

library(sparrpowR)
library(spatstat.geom)
library(stats)

# ----------------- #
# Run spatial_power #
# ----------------- #

# Circular window with radius 0.5
# Uniform case sampling within a disc of radius of 0.1 at the center of the window
# Complete Spatial Randomness control sampling
# 20% prevalence (n = 300 total locations)
# Statistical power to detect both case and control relative clustering
# 100 simulations (more recommended for power calculation)

unit.circle <- spatstat.geom::disc(radius = 0.5, centre = c(0.5,0.5))

foo <- sparrpowR::spatial_power(win = unit.circle,
                                sim_total = 100,
                                x_case = 0.5,
                                y_case = 0.5,
                                samp_case = "uniform",
                                samp_control = "CSR",
                                r_case = 0.1,
                                n_case = 50,
                                n_control = 250)
                     
# ----------------------- #
# Outputs from iterations #
# ----------------------- #

# Mean and standard deviation of simulated sample sizes and bandwidth
stats::mean(foo$n_con); stats::sd(foo$n_con)    # controls
stats::mean(foo$n_cas); stats::sd(foo$n_cas)    # cases
stats::mean(foo$bandw); stats::sd(foo$bandw)    # bandwidth of case density (if fixed, same for control density) 

# Global Test Statistics
## Global maximum relative risk: Null hypothesis is mu = 1
stats::t.test(x = foo$s_obs, mu = 0, alternative = "two.sided")

## Integral of log relative risk: Null hypothesis is mu = 0
stats::t.test(x = foo$t_obs, mu = 1, alternative = "two.sided")

# ----------------- #
# Run spatial_plots #
# ----------------- #

# Statistical power for case-only clustering (one-tailed test)
sparrpowR::spatial_plots(foo)

# Statistical power for case clustering and control
clustering (two-tailed test)
## Only showing second and third plot
sparrpowR::spatial_plots(foo, cascon = TRUE)

# --------------------------- #
# Multiple Testing Correction #
# --------------------------- #

# Same parameters as above
# Apply a conservative Bonferroni correction

set.seed(1234) # reset RNG

# Run spatial_power()
foo <- sparrpowR::spatial_power(win = unit.circle,
                                sim_total = 100,
                                x_case = 0.5,
                                y_case = 0.5,
                                samp_case = "uniform",
                                samp_control = "CSR",
                                r_case = 0.1,
                                n_case = 50,
                                n_control = 250,
                                alpha = 0.05,
                                p_correct = "Bonferroni")
                     
median(foo$alpha) # critical p-value of 3e-6 

# Run spatial_plots() for case-only clustering
## Only showing third plot
sparrpowR::spatial_plots(foo, cascon = TRUE)

Funding

This package was developed while the authors were originally postdoctoral fellows supported by the Cancer Prevention Fellowship Program at the National Cancer Institute. Any modifications since December 05, 2022 were made while the author I.D.B. was an employee of Social & Scientific Systems, Inc., a division of DLH Corporation.

Acknowledgments

When citing this package for publication, please follow:

citation("sparrpowR")

Questions? Feedback?

For questions about the package please contact the maintainer Dr. Ian D. Buller or submit a new issue.

Metadata

Version

0.2.8

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows