# pMove: Probability Distribution After Movement In openCR: Open Population Capture-Recapture

## Description

Compute the compounding effect of a random walk defined by a discrete kernel. The number of steps and the edge algorithm are specified by the user. The final distribution may be summed for points lying within an arbitrary polygon. This is a simple way to compute the expected proportion remaining within a particular region (i.e. not “emigrating").

## Usage

 ```1 2 3``` ```cumMove(X, mask, kernel, edgemethod = c("truncate", "wrap", "none"), nstep = 1) proportionInPolygon(mask, poly, cov = "pm") ```

## Arguments

 `X` initial location(s) (see Details) `mask` habitat mask `kernel` kernel object `edgemethod` character `nstep` non-negative integer `poly` a polygon (see Details) `cov` character name of covariate of `mask`

## Details

The input `X` may be -

• a vector of length 2 for the coordinates of a single point

• a mask with covariate 'pm' representing the initial distribution

• a SpatialPolygons object from sp. Animals are assumed initially to be distributed uniformly across mask points that lie within the polygon.

The default edgemethod truncates the kernel at the edge and re-normalizes the cell probabilities so that all destinations lie within the boundary of the mask.

For `proportionInPolygon`, the input mask may be the output from `cumMove`. The polygon `poly` may be specified as for `pointsInPolygon` (e.g., SpatialPolygons object or 2-column matrix of coordinates) or as a list with components x and y. A list of polygon specifications is also accepted.

## Value

For cumMove - a mask object with initial probability distribution in covariate 'pm0' and final distribution in covariate 'pm'.

For proportionInPolygon - vector of the summed weights (probabilities) for cells centred in the polygon(s) as a proportion of all non-missing weights.

`make.kernel`, `pointsInPolygon`
 ``` 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 44 45``` ```sp <- 10 msk <- make.mask(nx = 51, ny = 51, type = 'rect', spacing = sp, buffer = 0) k <- make.kernel('BVN', 20, spacing = sp, move.a = 50, clip = TRUE, sparse = TRUE) # initial distribution a central point X <- apply(msk, 2, mean) par(mfrow = c(1,4), mar = c(1,1,2,1)) for (step in 0:2) { X <- cumMove(X, msk, k, nstep = min(step,1)) plot(X, cov = 'pm', dots = FALSE, legend = FALSE, breaks = seq(0,0.006,0.0001)) mtext(side = 3, line = 0, paste('Step', step), cex = 0.9) contour( x = unique(X\$x), y = unique(X\$y), z = matrix(covariates(X)\$pm, nrow = length(unique(X\$x))), levels = c(0.0002), drawlabels = FALSE, add = TRUE) } ## Not run: # initial distribution across a polygon X0 <- matrix(c(200,200,300,300,200,200,300,300,200,200), ncol = 2) X <- X0 par(mfrow = c(1,4), mar = c(1,1,2,1)) for (step in 0:3) { X <- cumMove(X, msk, k, nstep = min(step,1)) plot(X, cov = 'pm', dots = FALSE, legend = FALSE, breaks = seq(0,0.006,0.0001)) mtext(side = 3, line = 0, paste('Step', step), cex = 0.9) contour( x = unique(X\$x), y = unique(X\$y), z = matrix(covariates(X)\$pm, nrow = length(unique(X\$x))), levels = c(0.0002), drawlabels = FALSE, add = TRUE) } polygon(X0) proportionInPolygon(X, X0) ## End(Not run) ```