convertOutput: Convert JAGS output back to the original coordinates

Description Usage Arguments Value Author(s) See Also Examples

View source: R/convertOutput.R

Description

The activity centre locations output from a JAGS run using a habitat mask is in units of pixels. This function converts them to the original coordinate system.

Usage

1
convertOutput(ACs, JAGSmask)

Arguments

ACs

A 2-column matrix or data frame, or an array of dimensions iterations x animals x 2, with the MCMC output for x and y coordinates of the ACs. It can also be a list with 2 elements, the first specifying the x coordinates and the second the y coordinates.

JAGSmask

The object of class JAGSmask that was used as input to the JAGS run.

Value

An object of the same class as ACs with the x and y coordinates of the ACs in the original coordinate system.

Author(s)

Mike Meredith

See Also

convertMask, plotACs.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data(simSCR)
str(simSCR, 1)
str(simSCR$sims.list)

# The output in simSCR$sims.list$S has MCMC chains for the coordinates
#  of activity centres on the pixel scale. Convert to the original units:
AC <- convertOutput(simSCR$sims.list$S, simSCR$JAGSmask)
str(AC)

# Plot the posterior distribution for 1 animal:
require(sp)
plot(simSCR$patchSP)
points(simSCR$traps, pch=3, col='red')
points(AC[, 1, ], pch=16, cex=0.2, col='blue')

# To plot the ACs for animals not captured, we need to remove the iterations
#  where the animal was not available for capture (ie, was a "phantom").
AC[simSCR$sims.list$w == 0] <- NA
points(AC[, 6, ], pch=16, cex=0.2, col='darkgreen')

mikemeredith/makeJAGSmask documentation built on May 19, 2021, 1:10 a.m.