# make a trapping grid with simple covariates
temptrap <- make.grid(nx = 6, ny = 8, detector = "proximity")
covariates (temptrap) <- data.frame(matrix(
c(rep(1,48*3),rep(2,48*2)), ncol = 5))
head(covariates (temptrap))
# identify columns 1-5 as daily covariates
timevaryingcov(temptrap) <- list(blockt = 1:5)
timevaryingcov(temptrap)
## Not run: ------------------------------------
#
# # default density = 5/ha, noccasions = 5
# CH <- sim.capthist(temptrap, detectpar = list(g0 = c(0.15, 0.15,
# 0.15, 0.3, 0.3), sigma = 25))
#
# fit.1 <- secr.fit(CH, trace = FALSE)
# fit.tvc2 <- secr.fit(CH, model = g0 ~ blockt, trace = FALSE)
#
# # because variation aligns with occasions, we get the same with:
# fit.t2 <- secr.fit(CH, model = g0 ~ tcov, timecov = c(1,1,1,2,2),
# trace = FALSE)
#
# predict(fit.t2, newdata = data.frame(tcov = 1:2))
# predict(fit.tvc2, newdata = data.frame(blockt = 1:2))
#
# # now model some more messy variation
# covariates (traps(CH))[1:10,] <- 3
# fit.tvc3 <- secr.fit(CH, model = g0 ~ blockt, trace = FALSE)
#
# AIC(fit.tvc2, fit.t2, fit.tvc3)
# # fit.tvc3 is the 'wrong' model
#
## ---------------------------------------------
Run the code above in your browser using DataLab