File: clusterfunctions.R

package info (click to toggle)
r-cran-spatstat.core 2.4-4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,440 kB
  • sloc: ansic: 4,402; sh: 13; makefile: 5
file content (43 lines) | stat: -rw-r--r-- 1,236 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
## clusterfunctions.R
##
## Contains methods for the generic functions
##  - clusterkernel
##  - clusterfield
##  - clusterradius.
##
##   $Revision: 1.11 $  $Date: 2022/02/21 02:24:34 $
##

## The generic clusterkernel() is now in spatstat.random

clusterkernel.kppm <- function(model, ...) {
  kernelR <- Kpcf.kppm(model, what = "kernel")
  f <- function(x, y = 0, ...){
    kernelR(sqrt(x^2+y^2))
  }
  return(f)
}

## The generic clusterradius() is now in spatstat.random

clusterfield.kppm <- function(model, locations = NULL, ...) {
    f <- clusterkernel(model)
    if(is.null(locations)){
        if(!is.stationary(model))
            stop("The model is non-stationary. The argument ",
                 sQuote("locations"), " must be given.")
        locations <- centroid.owin(Window(model), as.ppp = TRUE)
    }
    clusterfield.function(f, locations, ..., mu = model$mu)
}

## The generic clusterradius is defined in spatstat.random

clusterradius.kppm <- function(model, ..., thresh = NULL, precision = FALSE){
    a <- list(model = model$clusters,
              thresh = thresh,
              precision = precision)
    a <- append(a, as.list(c(model$clustpar, model$clustargs)))
    do.call(clusterradius.character, a)
}