This comment is based on the nest survival example on page C-89 of Appendix C of the Mark manual. The input file for the mallard example has the different habitat groups coded as four individual covariates for native, planted, wetland and roadside. The example dataset also has a few nests not assigned to any of these four strata. The input file could be recoded with a single variable with a categorical response variable. I drop the unknown and roadside nests to make comparisons to the example in Appendix C. A note of caution for RMark users - it looks like the way that groups are handled can have an effect on the parameter count for the models. R script as follows.
- Code: Select all
library(RMark)
data(mallard)
# Treat dummy variables for habitat types as factors
mallard$Native=factor(mallard$Native)
mallard$Planted=factor(mallard$Planted)
mallard$Wetland=factor(mallard$Wetland)
mallard$Roadside=factor(mallard$Roadside)
# coding habitat as a single variable
mallard$Habitat <- "Unknown"
mallard$Habitat[mallard$Native==1] <- "Native"
mallard$Habitat[mallard$Planted==1] <- "Planted"
mallard$Habitat[mallard$Wetland==1] <- "Wetland"
mallard$Habitat[mallard$Roadside==1] <- "Roadside"
# drop nests in unknown and roadside habitats
mallard <- subset(mallard, mallard$Habitat!="Unknown" & mallard$Habitat!="Roadside")
mallard$Habitat=factor(mallard$Habitat)
# Examine a summary of the groups
summary(mallard$Habitat)
# Write a function for evaluating a set of competing models
run.mallard=function()
{
# 2. DSR varies by habitat type treats habitats as factors
# and the output provides S hats for each habitat type
Hab=mark(mallard,nocc=90,model="Nest",
model.parameters=list(S=list(formula=~Native+Planted+Wetland)),
groups=c("Native","Planted","Wetland"))
# 2A. Alternative coding for habitat model
Hab2=mark(mallard,nocc=90,model="Nest",
model.parameters=list(S=list(formula=~Habitat)), groups="Habitat")
return(collect.models() )
}
mallard.results=run.mallard()
mallard.results
The [edited] parameter estimates and model selection from running this script then look like:
- Code: Select all
Output summary for Nest model
Name : S(~Native + Planted + Wetland)
Npar : 4 (unadjusted=3)
-2lnL: 1445.949
AICc : 1453.956 (unadjusted=1451.953)
Beta
estimate se lcl ucl
S:(Intercept) 2.2750844 0 2.2750844 2.2750844
S:Native1 0.5878466 0 0.5878466 0.5878466
S:Planted1 0.8105261 0 0.8105261 0.8105261
S:Wetland1 0.6807600 0 0.6807600 0.6807600
Real Parameter S
1
Group:Native1.Planted0.Wetland0 0.9459833
Group:Native0.Planted1.Wetland0 0.9562953
Group:Native0.Planted0.Wetland1 0.9505390
Output summary for Nest model
Name : S(~Habitat)
Npar : 3
-2lnL: 1445.949
AICc : 1451.953
Beta
estimate se lcl ucl
S:(Intercept) 2.8629310 0.0992682 2.6683653 3.0574967
S:HabitatPlanted 0.2226796 0.1273492 -0.0269249 0.4722841
S:HabitatWetland 0.0929133 0.2454493 -0.3881674 0.5739940
Real Parameter S
1
Group:HabitatNative 0.9459833
Group:HabitatPlanted 0.9562953
Group:HabitatWetland 0.9505390
> mallard.results
model npar AICc DeltaAICc weight Deviance
2 S(~Habitat) 3 1451.953 0.000000 0.7313373 1445.949
1 S(~Native + Planted + Wetland) 4 1453.956 2.002837 0.2686627 1445.949
Both models produce the same parameter estimates for the three habitats and have the same deviance. However, the model based on habitats coded as individual covariates has an adjusted parameter count of four because the model has an intercept plus one parameter for each of three habitat levels. In Table 3 of Rotella et al. 2004, the parameter count for this model is given as K=4. The model for the recoded Habitat variable has a parameter count of three, which then affects the AICc value, delta-AICc and model rankings.
I suggest K=3 should be the correct parameter count for a model with three levels of habitat. If the model is fit with groups as individual covariates, it might be best to use the unadjusted count for K. Posting this information to the forum in case anybody else is working through the examples to learn RMark.
Cheers, Brett.