get.pi: Generalized version of 'get.pi'

View source: R/spatialfuncs.r

get.piR Documentation

Generalized version of get.pi

Description

Generalized version of the get.pi function that takes in an arbitrary function and returns the probability that a point within a particular range of a point of interest shares the relationship specified by the passed in function with that point.

Usage

get.pi(posmat, fun, r = 1, r.low = rep(0, length(r)), data.frame = TRUE)

Arguments

posmat

a matrix with columns x, y and any other named columns columns needed by fun

fun

a function that takes in two rows of posmat and returns:

  1. for pairs included in the numerator and denominator

  2. for pairs that should only be included in the denominator

  3. for pairs that should be ignored all together

Note that names from posmat are not preserved in calls to fun, so the columns of the matrix should be referenced numerically so this is not available to the fun

r

the series of spatial distances (or there maximums) we are interested in

r.low

the low end of each range, 0 by default

data.frame

logical indicating whether to return results as a data frame (default = TRUE)

Value

pi value for each distance range that we look at. Where:

\pi(d_1, d_2) = \frac{\sum \boldsymbol{1} (d_{ij} \in [d_1,d_2)) \boldsymbol{1} (f(i,j)=1) }{\sum \sum \boldsymbol{1} [d_{ij} \in (d_1,d_2)) \boldsymbol{1} (f(i,j) \in \{1,2\}) }

Author(s)

Justin Lessler and Henrik Salje

See Also

Other get.pi: get.pi.bootstrap(), get.pi.ci(), get.pi.permute(), get.pi.typed(), get.pi.typed.bootstrap(), get.pi.typed.permute()

Other spatialtau: get.tau(), get.theta()

Examples



data(DengueSimR02)

r.max<-seq(20,1000,20)
r.min<-seq(0,980,20)

sero.type.func<-function(a,b,tlimit=20){
  if(a[5]==b[5]&(abs(a[3]-b[3])<=tlimit)){rc=1}
  else{rc=2}
  return(rc)
}

sero.pi<-get.pi(DengueSimR02,sero.type.func,r=r.max,r.low=r.min)



IDSpatialStats documentation built on Sept. 11, 2024, 5:14 p.m.