Extract or replace time varying covariates
an object of class
a list of named vectors
other arguments (not used)
The timevaryingcov attribute is a list of one or more named vectors. Each vector identifies a subset of columns of covariates(object), one for each occasion. If character values are used they should correspond to covariate names.
In secr models, time-varying covariates are restricted to traps objects. Time-varying (session-specific) individual covariates may be used in openCR. The following remarks apply to time-varying traps covariates.
The name of the vector may be used in a model formula; when the model is fitted, the value of the trap covariate on a particular occasion is retrieved from the column indexed by the vector.
For replacement, if
object already has a
attribute, the length of each vector in
value must match exactly
the number of columns in
When converting a multi-session capthist object into a robust-design “single-session” object with function
join the argument ‘timevaryingcov’ is used to collate
covariate values across sessions in a form suitable for inclusion in
openCR models (see
timevaryingcov(object) returns the timevaryingcov attribute of
object (may be NULL).
It is usually better to model varying effort directly, via the usage attribute (see secr-varyingeffort.pdf).
Models for data from detectors of type ‘multi’, ‘polygonX’ or ‘transectX’ take much longer to fit when detector covariates of any sort are used.
See secr-varyingeffort.pdf for input of detector covariates from a file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
# 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 ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.