kernrat.Rd
Return the ratio of two kernel smoothings
kernrat(pts1,pts2,poly,h1,h2,nx=20,ny=20,kernel='quartic')
Point data sets
A polygon data set
The kernel width parameters, h1
for pts1
, and h2
for pts2
Number of points along the x-axis of the returned grid.
Number of points along the y-axis of the returned grid.
Type of kernel function to use. Currently only the quartic kernel is implemented.
A list with the following components:
List of x-coordinates at which the kernel function has been evaluated.
List of y-coordinates at which the kernel function has been evaluated.
A matrix of dimension nx
by ny
containing the ratio of the kernel functions.
A vector of length 2 containing h1
and h2
a character string containing the kernel name.
Berman M. and Diggle P.J. (1989) Estimating Weighted Integrals of the Second-Order Intensity of Spatial Point Patterns. J. R. Statist Soc B51 81-92; Rowlingson, B. and Diggle, P. 1993 Splancs: spatial point pattern analysis code in S-Plus. Computers and Geosciences, 19, 627-655; the original sources can be accessed at: https://www.maths.lancs.ac.uk/~rowlings/Splancs/. See also Bivand, R. and Gebhardt, A. 2000 Implementing functions for spatial statistical analysis using the R language. Journal of Geographical Systems, 2, 307-317.
data(okwhite)
data(okblack)
okpoly <- list(x=c(okwhite$x, okblack$x), y=c(okwhite$y, okblack$y))
kr <- kernrat(as.points(okwhite), as.points(okblack), bboxx(bbox(as.points(okpoly))),
h1=50, h2=50)
#> Xrange is 111 382
#> Yrange is 64 341
#> Doing quartic kernel
#> Xrange is 111 382
#> Yrange is 64 341
#> Doing quartic kernel
image(kr, asp=1)
brks <- quantile(c(kr$z), seq(0,1,1/10), na.rm=TRUE)
lbrks <- formatC(brks, 3, 6, "g", " ")
cols <- heat.colors(length(brks)-1)
def.par <- par(no.readonly = TRUE)
layout(matrix(c(1,0,1,2), 2, 2, byrow = TRUE), c(2.5,1.5), c(1,3), TRUE)
image(kr, breaks=brks, col=cols, asp=1)
plot.new()
legend(c(0,1), c(0,1), legend=paste(lbrks[-length(lbrks)], lbrks[-1], sep=":"), fill=cols, bty="n")
par(def.par)