Individuals' age are separated into 3 classes for Survival: φ age(0, 1-3, 4+)
Transition matrix:
- Individuals transition from 1 to 2 only from age 2 minimum
- Individuals transition from 2 to 3 only from age 3 minimum
- Individuals transition back to 2 from stratum 3 only at age 4 minimum (has to go to post-breeder state first at age 3, then can go back to breeding state at age 4)
- Individuals can't go back to state "1" once they reached state "2" or "3"
Fixing detection:
- Individuals can't be seen at breeder state (2) before the age of 2
You can see in the code below all the fixed impossible transitions to 0, and the fixed detection at 0:
- Code: Select all
# 2. Process the data----
ms_proc <- process.data(rmark_data, model = "Multistrata")
# 3. Create design data----
ms_ddl <- make.design.data(ms_proc);str(ms_ddl)
{
# Create age classes for survival "S"
ms_ddl$S$ageclass3=cut(ms_ddl$S$Age,c(0, 1, 4, Inf), right =FALSE)
levels(ms_ddl$S$ageclass3)=c("Juveniles","Adults(1-3)","Adults(4+)")
# Create an indicator for juveniles (age0)
ms_ddl$S$is_juvenile <- ifelse(ms_ddl$S$ageclass3 == "Juveniles", 1, 0)
# Create an indicator for young adults (age1-3)
ms_ddl$S$youngA <- ifelse(ms_ddl$S$ageclass3 == "Adults(1-3)", 1, 0)
# Create an indicator for older adults (age4+)
ms_ddl$S$olderA <- ifelse(ms_ddl$S$ageclass3 == "Adults(4+)", 1, 0)
# Create age classes for re-capture "p"
ms_ddl$p$ageclass6=cut(ms_ddl$p$Age,c(-Inf,2,3,4,5,6,Inf),right=FALSE)
levels(ms_ddl$p$ageclass6) <- c("1","2","3","4","5","6+") # 6 age classes
#Fix p = 0 at Age 1 for breeding state
ms_ddl$p$fix[ms_ddl$p$stratum == "2" &
(ms_ddl$p$Age == 1)] <- 0
ms_ddl$p$fix[ms_ddl$p$stratum == "3" &
(ms_ddl$p$Age < 3)] <- 0
# Create constraint matrix for transitions "Psi"
ms_ddl$Psi$fix <- NA
# Set impossible transitions to 0
ms_ddl$Psi$fix[ms_ddl$Psi$stratum == "1" & ms_ddl$Psi$tostratum == "3"] <- 0 # PB to PO
ms_ddl$Psi$fix[ms_ddl$Psi$stratum == "2" & ms_ddl$Psi$tostratum == "1"] <- 0 # B to PB
ms_ddl$Psi$fix[ms_ddl$Psi$stratum == "3" & ms_ddl$Psi$tostratum == "1"] <- 0 # PO to PB
#PB to B transition for age < 2 = 0
ms_ddl$Psi$fix[ms_ddl$Psi$stratum == "1" &
ms_ddl$Psi$tostratum == "2" &
(ms_ddl$Psi$Age < 2)] <- 0
#B to PO transition for age < 3 = 0
ms_ddl$Psi$fix[ms_ddl$Psi$stratum == "2" &
ms_ddl$Psi$tostratum == "3" &
(ms_ddl$Psi$Age < 3)] <- 0
#PO to B transition for age < 4 = 0
ms_ddl$Psi$fix[ms_ddl$Psi$stratum == "3" &
ms_ddl$Psi$tostratum == "2" &
(ms_ddl$Psi$Age < 4)] <- 0
# 4. Run model
ms_model <- mark(ms_proc, ms_ddl,
model.parameters = list(
S = list(formula = ~-1 + stratum:youngA + stratum:olderA + is_juvenile:time),
p = list(formula = ~stratum:ageclass6),
Psi = list(formula = ~-1+stratum:tostratum:age))
)
I would like to add constraints on transitions. Transition probability likely depends on the age of individuals but could also be impacted by resource availability ("SF") by changing their probability of going to a breeder state. Also, density could have a negative impact on recruitment, so it could impact transition probability from state 1 to state 2.
1. Is my way of fixing impossible transitions to 0 the correct way of doing it in Rmark?
2. When running the model, how should I code to test for the impact of SF or density on a specific transition (1 to 2)?
Thank you for your help