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".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)sigma."two.sided". The values "less" and "greater" are also valid.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.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.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