dcatState1Alive1Dead {nimbleSCR} | R Documentation |
Density and random generation of a categorical distribution describing state transition with one alive and one dead states.
Description
The dcatState1Alive1Dead
distribution is a NIMBLE custom distribution which can be used to model and simulate
individual state transition. This function can be used to model transitions from one alive and one dead state.
If z_i,t = 1, individual i can be recruited (transition to state 2) with probability prob1To2_t, so z_i,t+1 ~ dcat(1- prob1To2_t, prob1To2_t, 0,0 , 0) where prob1To2_t represent the probability of an unborn individual to be recruited.
If z_i,t = 2, individual i can die and transition to z_i,t+1=3 with probability prob2To3, or survive with probability 1-prob2To3
Individuals in dead states (z_i,t = 3 ) remain in that state with probability 1, the absorbing state.
If transition probabilities are spatially variable, a probability vector containing the transition probability value in each habitat window can be provided using the "Hab" arguments (e.g. prob1To2Hab,prob2To3Hab).
Usage
dcatState1Alive1Dead(
x,
z,
prob1To2 = -999,
prob1To2Hab,
prob2To3 = -999,
prob2To3Hab,
s,
habitatGrid,
log = 0
)
rcatState1Alive1Dead(
n,
z,
prob1To2 = -999,
prob1To2Hab,
prob2To3 = -999,
prob2To3Hab,
s,
habitatGrid
)
Arguments
x |
Scalar, individual state z_i,t+1. |
z |
Scalar, initial individual state z_i,t. |
prob1To2 |
scalar, probability to transition from state 1 to 2. |
prob1To2Hab |
vector, Spatially-explicit probability to transition from state 2 to 3. The length of the vector should be equal the number of habitat windows in |
prob2To3 |
scalar, probability to transition from state 2 to 3. |
prob2To3Hab |
vector, Spatially-explicit probability to transition from state 2 to 3. The length of the vector should be equal the number of habitat windows in |
s |
Vector of x- and y-coordinates corresponding to the AC location of the individual. Used to extract transition spatially-explicit probabilities when they are provided. |
habitatGrid |
Matrix of habitat window indices. Cell values should correspond to the
order of habitat windows in |
log |
Logical argument, specifying whether to return the log-probability of the distribution.
|
n |
Integer specifying the number of realizations to generate. Only n = 1 is supported. |
Author(s)
Cyril Milleret
Examples
# Use the distribution in R
z <- 2
prob1To2 <- 0.2
prob2To3 <- 0.7
lowerCoords <- matrix(c(0, 0, 1, 0, 0, 1, 1, 1), nrow = 4, byrow = TRUE)
upperCoords <- matrix(c(1, 1, 2, 1, 1, 2, 2, 2), nrow = 4, byrow = TRUE)
logIntensities <- log(rep(1,4))
logSumIntensity <- log(sum(c(1:4)))
habitatGrid <- matrix(c(1:4), nrow = 2, byrow = TRUE)
numGridRows <- nrow(habitatGrid)
numGridCols <- ncol(habitatGrid)
s <- rbernppAC(n=1, lowerCoords, upperCoords, logIntensities, logSumIntensity,
habitatGrid, numGridRows, numGridCols)
## No spatial mortality
zPlusOne <- rcatState1Alive1Dead( z = z
, prob1To2 = prob1To2
, prob2To3 = prob2To3
, s = s
, habitatGrid = habitatGrid)
zPlusOne
dcatState1Alive1Dead( x = zPlusOne
, z = z
, prob1To2 = prob1To2
, prob2To3 = prob2To3
, s = s
, habitatGrid = habitatGrid)
## With spatial mortality
prob2To3Hab <- c(0.60, 0.70, 0.74, 0.65)
prob1To2Hab <- c(0.4,0.5,0.1,0.3)
zPlusOne <- rcatState1Alive1Dead( z = z
, prob1To2Hab = prob1To2Hab
, prob2To3Hab = prob2To3Hab
, s = s
, habitatGrid = habitatGrid)
zPlusOne
dcatState1Alive1Dead( x = zPlusOne
, z = z
, prob1To2Hab = prob1To2Hab
, prob2To3Hab = prob2To3Hab
, s = s
, habitatGrid = habitatGrid)