createDensity: Generates a density using random walks on a lattice.

Description Usage Arguments Details Value Author(s) References Examples

View source: R/createDensity.R

Description

Given a lattice and a point pattern of observations, createDensity starts random walks at each observation. k steps are taken and the output is a densityOut object, which can be used to plot a density estimate. If you wish to perform non-parametric regression, you should use the functions addQuantVar and createNparReg instead.

Usage

1
2
3
4
5
6
7
8
createDensity(
  formLatticeOutput,
  PointPattern = NULL,
  M = 0.5,
  k,
  intensity = FALSE,
  sparse = TRUE
)

Arguments

formLatticeOutput

An object from formLattice or editLattice.

PointPattern

A 2-column matrix or data frame of locations.

M

Maximum probability of random walk moving.

k

The smoothing parameter (number of steps).

intensity

Plot an intensity vs a density.

sparse

If TRUE, matrix computations are sparse.

Details

We start with an initial probability density p0 where the ith entry in p0 is the fraction of the point pattern that is nearest to the ith node. This is the empirical density function with no smoothing. If T is the transition matrix, and given a number of steps in the diffusion, T k p0 is the probability density of the diffusion after k steps. This is the major output of this function, along with information needed to produce a plot, including the polygons for the boundary and holes, and a vector of NS coordinates and EW coordinates used by the contour function. All of the necessary information for plotting is bundled in the object of class densityOutLBDE. Details of this process can be found in Barry and McIntyre (2011).

Value

An object of type densityOut

Author(s)

Ronald P. Barry

References

Ronald P. Barry, Julie McIntyre. Estimating animal densities and home range in regions with irregular boundaries and holes: A lattice-based alternative to the kernel density estimator. Ecological Modelling 222 (2011) 1666-1672. <doi:10.1080/10618600.2017.1375935>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
plot.new()
data(polygon1)
nodeFillingOutput <- nodeFilling(poly=polygon1, node_spacing=0.02)
plot(nodeFillingOutput)
formLatticeOutput <- formLattice(nodeFillingOutput)
plot(formLatticeOutput)
Pointdata <- splancs::csr(polygon1,75)
Pointdata <- Pointdata[Pointdata[,1]<0.5,]
plot(polygon1,type="n")
polygon(polygon1)
points(Pointdata,pch=19)
out <- crossvalDensity(formLatticeOutput,PointPattern=Pointdata,
                      M=0.5,max_steps = 35)
densityOut <- createDensity(formLatticeOutput,
                           PointPattern=Pointdata, 
                           k=out$k,intensity=FALSE, sparse = TRUE)
plot(densityOut)
homerange(densityOut, percent = 0.95)

latticeDensity documentation built on April 18, 2021, 5:06 p.m.