Learn R Programming

smacpod (version 1.2.3)

logrr: Log ratio of spatial densities

Description

logrr computes envelopes for the log ratio of spatial density functions. The numerator in this ratio is related to the "cases" and the denominator to the "controls".

Usage

logrr(x, sigma = NULL, sigmacon = NULL, case = 2, nsim = 0,
  level = 0.9, alternative = "two.sided", ..., bwargs = list(),
  weights = NULL, edge = TRUE, varcov = NULL, at = "pixels",
  leaveoneout = TRUE, adjust = 1, diggle = FALSE, nreport = 50)

Arguments

x
Point pattern (object of class "ppp").
sigma
Standard deviation of isotropic Gaussian smoothing kernel for cases. Either a numerical value, or a function that computes an appropriate value of sigma.
sigmacon
Standard deviation of isotropic Gaussian smoothing kernel for controls. Default is the same as sigma.
case
The position of the name of the "case" group in levels(x$marks). The default is 2.
nsim
The number of simulated data sets from which to construct the envelopes under the random labeling hypothesis. Default is 0.
level
The level for Monte Carlo test using tolerance intervals.
alternative
The direction of the test. Default is "two.sided". The values "less" and "greater" are also valid.
...
Additional arguments passed to spatstat::pixellate.ppp or spatstat::as.mask to determine the pixel resolution.
bwargs
A list of arguments for the bandwidth function supplied to sigma, if applicable.
weights
Optional weights to be attached to the points. A numeric vector, numeric matrix, or an expression.
edge
Logical flag: if TRUE, apply edge correction.
varcov
Variance-covariance matrix of anisotropic Gaussian kernel. Incompatible with sigma.
at
String specifying whether to compute the intensity values at a grid of pixel locations (at="pixels") or only at the points of x (at="points").
leaveoneout
Logical value indicating whether to compute a leave-one-out estimator. Applicable only when at="points".
adjust
Optional. Adjustment factor for the smoothing parameter.
diggle
Logical. If TRUE, use Diggle's edge correction, which is more accurate but slower to compute than the correction described under Details.
nreport
How frequently to report progress on the simulation. Default is 50.

Value

  • The function produces an object of type logrrenv. It's components are similar to those returned by the density.ppp function from the spatstat package, with the intensity values replaces by the log ratio of spatial densities of f and g. Includes an array simr of dimension c(nx, ny, nsim + 1), where nx and ny are the number of x and y grid points used to estimate the spatial density. simr[,,1] is the log ratio of spatial densities for the observed data, and the remaining nsim elements in the third dimension of the array are the log ratios of spatial densities from a new ppp simulated under the random labeling hypothesis.

Details

The two.sided alternative test assesses whether the observed ratio of log densities deviates more what is expected under the random labelling hypothesis. When the test is significant, this suggests that the cases and controls are clustered, relative to the either. The greater alternative test assesses whehter the cases are more clustered than the controls. The less alternative test assesses whether the controls are more clustered than the cases. If the estimated density of the case or control group becomes two small, this function may produce warnings due to numerical underflow. Increasing the bandwidth (sigma) may help.

References

Waller, L.A. and Gotway, C.A. (2005). Applied Spatial Statistics for Public Health Data. Hoboken, NJ: Wiley. Kelsall, Julia E., and Peter J. Diggle. "Kernel estimation of relative risk." Bernoulli (1995): 3-16. Kelsall, Julia E., and Peter J. Diggle. "Non-parametric estimation of spatial variation in relative risk." Statistics in Medicine 14.21-22 (1995): 2335-2342.

Examples

Run this code
data(grave)
r = logrr(grave)
plot(r)
r2 = logrr(grave, sigma = spatstat::bw.scott)
plot(r2)
rsim = logrr(grave, nsim = 9)
plot(rsim)

Run the code above in your browser using DataLab