Learn R Programming

spatstat.linnet (version 3.2-2)

envelope.lpp: Envelope for Point Patterns on Linear Network

Description

Enables envelopes to be computed for point patterns on a linear network.

Usage

# S3 method for lpp
envelope(Y, fun=linearK, nsim=99, nrank=1, ..., 
  funargs=list(), funYargs=funargs,
  simulate=NULL, fix.n=FALSE, fix.marks=FALSE, verbose=TRUE, 
  transform=NULL,global=FALSE,ginterval=NULL,use.theory=NULL,
  alternative=c("two.sided", "less", "greater"),
  scale=NULL, clamp=FALSE,
  savefuns=FALSE, savepatterns=FALSE,
  nsim2=nsim, VARIANCE=FALSE, nSD=2, Yname=NULL,
  maxnerr=nsim, rejectNA=FALSE, silent=FALSE,
  do.pwrong=FALSE, envir.simul=NULL)

# S3 method for lppm envelope(Y, fun=linearK, nsim=99, nrank=1, ..., funargs=list(), funYargs=funargs, simulate=NULL, fix.n=FALSE, fix.marks=FALSE, verbose=TRUE, transform=NULL,global=FALSE,ginterval=NULL,use.theory=NULL, alternative=c("two.sided", "less", "greater"), scale=NULL, clamp=FALSE, savefuns=FALSE, savepatterns=FALSE, nsim2=nsim, VARIANCE=FALSE, nSD=2, Yname=NULL, maxnerr=nsim, rejectNA=FALSE, silent=FALSE, do.pwrong=FALSE, envir.simul=NULL)

Value

Function value table (object of class "fv") with additional information, as described in envelope.

Arguments

Y

A point pattern on a linear network (object of class "lpp") or a fitted point process model on a linear network (object of class "lppm").

fun

Function that is to be computed for each simulated pattern.

nsim

Number of simulations to perform.

nrank

Integer. Rank of the envelope value amongst the nsim simulated values. A rank of 1 means that the minimum and maximum simulated values will be used.

...

Extra arguments passed to fun.

funargs

A list, containing extra arguments to be passed to fun.

funYargs

Optional. A list, containing extra arguments to be passed to fun when applied to the original data Y only.

simulate

Optional. Specifies how to generate the simulated point patterns. If simulate is an expression in the R language, then this expression will be evaluated nsim times, to obtain nsim point patterns which are taken as the simulated patterns from which the envelopes are computed. If simulate is a function, then this function will be repeatedly applied to the data pattern Y to obtain nsim simulated patterns. If simulate is a list of point patterns, then the entries in this list will be treated as the simulated patterns from which the envelopes are computed. Alternatively simulate may be an object produced by the envelope command: see Details.

fix.n

Logical. If TRUE, simulated patterns will have the same number of points as the original data pattern.

fix.marks

Logical. If TRUE, simulated patterns will have the same number of points and the same marks as the original data pattern. In a multitype point pattern this means that the simulated patterns will have the same number of points of each type as the original data.

verbose

Logical flag indicating whether to print progress reports during the simulations.

transform

Optional. A transformation to be applied to the function values, before the envelopes are computed. An expression object (see Details).

global

Logical flag indicating whether envelopes should be pointwise (global=FALSE) or simultaneous (global=TRUE).

ginterval

Optional. A vector of length 2 specifying the interval of \(r\) values for the simultaneous critical envelopes. Only relevant if global=TRUE.

use.theory

Logical value indicating whether to use the theoretical value, computed by fun, as the reference value for simultaneous envelopes. Applicable only when global=TRUE.

alternative

Character string determining whether the envelope corresponds to a two-sided test (side="two.sided", the default) or a one-sided test with a lower critical boundary (side="less") or a one-sided test with an upper critical boundary (side="greater").

scale

Optional. Scaling function for global envelopes. A function in the R language which determines the relative scale of deviations, as a function of distance \(r\), when computing the global envelopes. Applicable only when global=TRUE. Summary function values for distance r will be divided by scale(r) before the maximum deviation is computed. The resulting global envelopes will have width proportional to scale(r).

clamp

Logical value indicating how to compute envelopes when alternative="less" or alternative="greater". Deviations of the observed summary function from the theoretical summary function are initially evaluated as signed real numbers, with large positive values indicating consistency with the alternative hypothesis. If clamp=FALSE (the default), these values are not changed. If clamp=TRUE, any negative values are replaced by zero.

savefuns

Logical flag indicating whether to save all the simulated function values.

savepatterns

Logical flag indicating whether to save all the simulated point patterns.

nsim2

Number of extra simulated point patterns to be generated if it is necessary to use simulation to estimate the theoretical mean of the summary function. Only relevant when global=TRUE and the simulations are not based on CSR.

VARIANCE

Logical. If TRUE, critical envelopes will be calculated as sample mean plus or minus nSD times sample standard deviation.

nSD

Number of estimated standard deviations used to determine the critical envelopes, if VARIANCE=TRUE.

Yname

Character string that should be used as the name of the data point pattern Y when printing or plotting the results.

maxnerr

Maximum number of rejected patterns. If fun yields a fatal error when applied to a simulated point pattern (for example, because the pattern is empty and fun requires at least one point), the pattern will be rejected and a new random point pattern will be generated. If this happens more than maxnerr times, the algorithm will give up.

rejectNA

Logical value specifying whether to reject a simulated pattern if the resulting values of fun are all equal to NA, NaN or infinite. If FALSE (the default), then simulated patterns are rejected only when fun gives a fatal error.

silent

Logical value specifying whether to print a report each time a simulated pattern is rejected.

do.pwrong

Logical. If TRUE, the algorithm will also estimate the true significance level of the “wrong” test (the test that declares the summary function for the data to be significant if it lies outside the pointwise critical boundary at any point). This estimate is printed when the result is printed.

envir.simul

Environment in which to evaluate the expression simulate, if not the current environment.

Author

Ang Qi Wei aqw07398@hotmail.com and Adrian Baddeley Adrian.Baddeley@curtin.edu.au

Details

This is a method for the generic function envelope applicable to point patterns on a linear network.

The argument Y can be either a point pattern on a linear network, or a fitted point process model on a linear network. The function fun will be evaluated for the data and also for nsim simulated point patterns on the same linear network. The upper and lower envelopes of these evaluated functions will be computed as described in envelope.

The type of simulation is determined as follows.

  • if Y is a point pattern (object of class "lpp") and simulate is missing or NULL, then random point patterns will be generated according to a Poisson point process on the linear network on which Y is defined, with intensity estimated from Y.

  • if Y is a fitted point process model (object of class "lppm") and simulate is missing or NULL, then random point patterns will be generated by simulating from the fitted model.

  • If simulate is present, it specifies the type of simulation as explained below.

  • If simulate is an expression (typically including a call to a random generator), then the expression will be repeatedly evaluated, and should yield random point patterns on the same linear network as Y.

  • If simulate is a function (typically including a call to a random generator), then the function will be repeatedly applied to the original point pattern Y, and should yield random point patterns on the same linear network as Y.

  • If simulate is a list of point patterns, then these will be taken as the simulated point patterns. They should be on the same linear network as Y.

The function fun should accept as its first argument a point pattern on a linear network (object of class "lpp") and should have another argument called r or a ... argument.

References

Ang, Q.W. (2010) Statistical methodology for events on a network. Master's thesis, School of Mathematics and Statistics, University of Western Australia.

Ang, Q.W., Baddeley, A. and Nair, G. (2012) Geometrically corrected second-order analysis of events on a linear network, with applications to ecology and criminology. Scandinavian Journal of Statistics 39, 591--617.

Okabe, A. and Yamada, I. (2001) The K-function method on a network and its computational implementation. Geographical Analysis 33, 271-290.

See Also

envelope, linearK

Examples

Run this code
   if(interactive()) {
     ns <- 39
     np <- 40
   } else { ns <- np <- 3 }
   X <- runiflpp(np, simplenet)

   # uniform Poisson: random numbers of points
   envelope(X, nsim=ns)

   # uniform Poisson: conditional on observed number of points
   envelope(X, fix.n=TRUE, nsim=ns)

   # nonuniform Poisson
   fit <- lppm(X ~x)
   envelope(fit, nsim=ns)

   #multitype
   marks(X) <- sample(letters[1:2], np, replace=TRUE)
   envelope(X, nsim=ns)

Run the code above in your browser using DataLab