In 'secr.fit', group effects are specified in two stages: grouping is defined with the 'groups' argument, and the term 'g' may be used in models for D, g0, sigma etc.
Defining groups fundamentally changes the structure of the likelihood, so AIC should not be compared between models fitted with different 'groups' arguments, or with and without groups defined. To evaluate the effect of adding a group effect to a model, compare models with and without 'g', making sure to define 'groups' in both cases.
For example:
- Code: Select all
library(secr)
tempgrid <- make.grid()
tempCH <- sim.capthist(tempgrid)
dummysex <- sample(size=nrow(tempCH), c('F','M'), replace = T, prob=c(0.5,0.5))
covariates(tempCH) <- data.frame(sex=dummysex)
fit.0 <- secr.fit (tempCH, model = list(g0 ~ 1, sigma ~ 1), groups = 'sex', trace = F)
fit.sex <- secr.fit (tempCH, model = list(g0 ~ g, sigma ~ g), groups = 'sex', trace = F)
AIC (fit.0, fit.sex)
This should give a result something like
- Code: Select all
model detectfn npar logLik AIC AICc dAICc AICwt
fit.0 D~1 g0~1 sigma~1 halfnormal 3 -229.0988 464.198 465.698 0.000 0.9654
fit.sex D~1 g0~g sigma~g halfnormal 5 -229.0356 468.071 472.357 6.659 0.0346
Do NOT do this:
- Code: Select all
fit.1 <- secr.fit (tempCH, model = list(g0 ~ 1, sigma ~ 1), trace = F)
AIC(fit.1, fit.sex)
As an aside - the issue does not arise when 'sex' is used as a categorical individual covariate in a model fitted by maximising the conditional likelihood (CL = T).
Murray