dcatState2Alive2Dead | R Documentation |
The dcatState2Alive2Dead
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 two alive and two dead states.
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 from one cause of mortality (e.g. culling) and transition to z_i,t+1=4 with probability prob2To4, or die from another cause with probability prob2To5 z_i,t+1=5.
If the individual does not die (1-(prob2To4+prob2To5)), it can either transition to the second state alive (z_i,t+1=3) with probability prob2To3 or remain in the first state alive (z_i,t+1=2) with probability (1-prob2To3).
If z_i,t = 3, individual i can die from one cause of mortality (e.g. culling) and transition to z_i,t+1=4 with probability prob3To4, or die from another cause with probability prob3To5 z_i,t+1=5.
if the individual does not die (1-(prob3To4+prob3To5)), the individual remain in state 3.
Individuals in dead states (z_i,t = 4 or 5) transition to z_i,t+1 = 5, the absorbing state, with probability 1.
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).
dcatState2Alive2Dead( x, z, prob1To2 = -999, prob1To2Hab, prob2To3 = -999, prob2To3Hab, prob2To4 = -999, prob2To4Hab, prob3To4 = -999, prob3To4Hab, prob2To5 = -999, prob2To5Hab, prob3To5 = -999, prob3To5Hab, s, habitatGrid, log = 0 ) rcatState2Alive2Dead( n, z, prob1To2 = -999, prob1To2Hab, prob2To3 = -999, prob2To3Hab, prob2To4 = -999, prob2To4Hab, prob3To4 = -999, prob3To4Hab, prob2To5 = -999, prob2To5Hab, prob3To5 = -999, prob3To5Hab, s, habitatGrid )
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 |
prob2To4 |
scalar, probability to transition from state 2 to 4. |
prob2To4Hab |
vector, Spatially-explicit probability to transition from state 2 to 4. The length of the vector should be equal the number of habitat windows in |
prob3To4 |
scalar, probability to transition from state 3 to 4. |
prob3To4Hab |
vector, Spatially-explicit probability to transition from state 3 to 4. The length of the vector should be equal the number of habitat windows in |
prob2To5 |
scalar, probability to transition from state 2 to 5. |
prob2To5Hab |
vector, Spatially-explicit probability to transition from state 2 to 5. The length of the vector should be equal the number of habitat windows in |
prob3To5 |
scalar, probability to transition from state 3 to 5. |
prob3To5Hab |
vector, Spatially-explicit probability to transition from state 3 to 5. 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. |
dcatState2Alive2Dead
gives the (log) probability density of x
.
dcatState2Alive2Dead
gives a randomly generated individual states conditional on the initial state z
.
Cyril Milleret
# Use the distribution in R z <- 3 prob1To2 <- 0.2 prob2To3 <- 0.4 prob2To4 <- 0.1 prob2To5 <- 0.1 prob3To4 <- 0.2 prob3To5 <- 0.1 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 <- rcatState2Alive2Dead( z = z , prob1To2 = prob1To2 , prob2To3 = prob2To3 , prob2To4 = prob2To4 , prob2To5 = prob2To5 , prob3To4 = prob3To4 , prob3To5 = prob3To5 , s = s , habitatGrid = habitatGrid) dcatState2Alive2Dead( x = zPlusOne , z = z , prob1To2 = prob1To2 , prob2To3 = prob2To3 , prob2To4 = prob2To4 , prob2To5 = prob2To5 , prob3To4 = prob3To4 , prob3To5 = prob3To5 , s = s , habitatGrid = habitatGrid) ## With spatial mortality prob2To3Hab <- runif(length(habitatGrid),0,0.1) prob2To4Hab <- runif(length(habitatGrid),0,0.1) prob2To5Hab <- runif(length(habitatGrid),0,0.1) prob3To4Hab <- runif(length(habitatGrid),0,0.1) prob3To5Hab <- runif(length(habitatGrid),0,0.1) zPlusOne <- rcatState2Alive2Dead( z = z , prob1To2 = prob1To2 , prob2To3Hab = prob2To3Hab , prob2To4Hab = prob2To4Hab , prob2To5Hab = prob2To5Hab , prob3To4Hab = prob3To4Hab , prob3To5Hab = prob3To5Hab , s = s , habitatGrid = habitatGrid) dcatState2Alive2Dead( x = zPlusOne , z = z , prob1To2 = prob1To2 , prob2To3Hab = prob2To3Hab , prob2To4Hab = prob2To4Hab , prob2To5Hab = prob2To5Hab , prob3To4Hab = prob3To4Hab , prob3To5Hab = prob3To5Hab , s = s , habitatGrid = habitatGrid)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.