nest survival modeling - example script for mallard data

This script processes the data 1 time and then sets up 9 competing models for daily survival rate (S).
- Code: Select all
# scripted analysis of mallard nest-survival data in RMark
# Example of use of RMark for modeling nest survival data
# Mallard nests example
# The example runs the 9 models that are used in the Nest
# Survival chapter of the Gentle Introduction to MARK and that
# appear in Table 3 (page 198) of
# Rotella, J.J., S. J. Dinsmore, T.L. Shaffer. 2004.
# Modeling nest-survival data: a comparison of recently
# developed methods that can be implemented in MARK and SAS.
# Animal Biodiversity and Conservation 27:187-204.
library(RMark)
# Retrieve the mallard data set that is with RMark
data(mallard)
# use the indicator variables for the 4 habitat types to yield
# 1 variable with habitat as a factor with 4 levels that
# can be used for a group variable in RMark
mallard$habitat <- as.factor(ifelse(mallard$Native == 1, "Native",
ifelse(mallard$Planted == 1, "Planted",
ifelse(mallard$Roadside == 1, "Roadside",
"Wetland"))))
# make the new variable 'habitat' a factor
mallard$habitat <- as.factor(mallard)
mallard.pr <- process.data(mallard,
nocc=90,
model="Nest",
groups=("habitat"))
# Write a function for evaluating a set of competing models
run.mallard = function()
{
# 1. A model of constant daily survival rate (DSR)
S.Dot = list(formula = ~1)
# 2. DSR varies by habitat type - treats habitats as factors
# and the output provides S-hats for each habitat type
S.Hab = list(formula = ~habitat)
# 3. DSR varies with vegetation thickness (Robel reading)
S.Robel = list(formula = ~Robel)
# 4. DSR varies with the amount of native vegetation in the surrounding area
S.PpnGr = list(formula = ~PpnGrass)
# 5. DSR follows a trend through time
S.TimeTrend = list(formula = ~Time)
# 6. DSR varies with nest age
S.Age = list(formula = ~NestAge)
# 7. DSR varies with nest age & habitat type
S.AgeHab = list(formula = ~NestAge + habitat)
# 8. DSR varies with nest age & vegetation thickness
S.AgeRobel = list(formula = ~NestAge + Robel)
# 9. DSR varies with nest age & amount of native vegetation in surrounding area
S.AgePpnGrass = list(formula = ~NestAge + PpnGrass)
# Return model table and list of models
mallard.model.list=create.model.list("Nest")
mallard.results=mark.wrapper(mallard.model.list,
data=mallard.pr, adjust=FALSE)
}
# The next line runs the 9 models above and takes a minute or 2
mallard.results=run.mallard()
mallard.results