Description Usage Arguments Details Value Author(s) See Also Examples
Conducts automated stepwise model selection of CJS models. Selection includes forward steps followed by backward looks. Steps consider covariates in both the survival and probability of capture models.
1 2 | F.step.cjs(cap.covars, surv.covars, fit.crit = "qaicc", signif.drop = 0,
signif.increase = 0, plot = TRUE, ...)
|
cap.covars |
A character vector containing the names of single covariates or combinations of covariates to consider in the capture equation. See Details. |
surv.covars |
A character vector containing the names of single covariates or combinations of covariates to consider in the survival equation. See Details. |
fit.crit |
A character scalar specifying the model fit criterion to use during each step. This criterion
will be used to rank variables
during the forward steps and backward looks. Possible values are "qaicc" (the default),
"aic", "qaic", and "aicc". During forward (addition) steps, the variable(s) that
decreased |
signif.drop |
A scalar specifying the decrease in |
signif.increase |
A scalar specifying the increase in |
plot |
A scalar specifying whether the minimum |
... |
Additional arguments to |
Elements of both the cap.covars
and surv.covars
arguments can specify the names of single covariates or sets of
covariates to consider as a group to be included or excluded
together. For example, if cap.covars = c("sex",
"ageclass1 + ageclass2 + ageclass3" )
, the routine will
include and exclude sex
as a single covariate with 1
estimated coefficient and ageclass1 + ageclass2 +
ageclass3
as a set of 3 covariates (with 3 estimated
coefficients) to be included and excluded as a set. This is
useful if factor covariates are pre-coded as indicator variables. In the
example above, specifying ageclass1 + ageclass2 +
ageclass3
would make sense if age of an individual was
classified into 1 of 4 classes, and ageclassX
was a
matrix with elements equal to 1 if the individual was in age
class X during a capture occasion, and 0 otherwise.
Specifying a term like a +
b + ab
would ensure that main effect matrices (a
and b
) are included whenever the interaction matrix
(ab
) is included during model selection. However, this way
of including interactions will only be useful if the main effects
are not considered separately. That is, specifying
cap.covars = c("a", "b", "a + b + ab")
will not work
because the routine does not know that "a" and "b" are
components of "a + b + ab". Nonsense models like
"a + b + ab + a + b" could result. Thus, this routine is
likely only useful for terms that do not include interactions.
A useful way to proceed in this case may be to use stepwise
to select a model of main effects, then consider interactions.
Time varying and individual varying variables can be specified
using the tvar
and ivar
functions in the elements
of cap.covars
and surv.covars
. For example,
specifying "tvar(year,nan=nrow(ch))"
as an element of
surv.covars
, where year = 1:ncol(ch)
and
ch
is the capture history matrix, will fit a linear
year effect (1 coefficient) when this element is added during
stepwise selection. Likewise, factors are preserved during
selection. If year
in the above example had been a
factor (i.e., year = as.factor(1:ncol(ch))
), separate
effects for each year (ncol(ch) - 1
coefficients) would
have been fitted when this effect came up for consideration
during stepwise selection.
The variable to add or eliminate is selected after all variables
in both the capture and survival models are considered. That is, the
variable that decreases (or increases) fit.crit
the most over both
models is added.
Selection does not iteratively fix one model and select variables
in the other. For example, on one step, the variable that decreases fit.crit
the most may be a survival covariate, while on the next step
the variable that decreases fit.crit
the most may be a capture covariate.
The final CJS model resulting from application of stepwise model selection. This object
is a valid MRA CJS model and has class 'cjs'. See help for F.cjs.estim
for a
description of the components of this object.
Trent McDonald, WEST-INC, tmcdonald@west-inc.com
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 | # Aquire data and intermediate variables
data(dipper.histories)
data(dipper.males)
ch <- dipper.histories
males <- dipper.males
ns <- ncol(ch)
nan <- nrow(ch)
# Construct covariates
small.t <- as.factor( paste("T",1:ns, sep=""))
post.flood <- as.numeric( 1:ns >= 4 )
year <- 1:ns - (ns / 2)
males.postflood <- outer( c(males), post.flood ) # individual and time varying
print(dim(males.postflood))
# Attach attributes to covariates. For convienence only.
attr(small.t, "nan") <- nan
attr(small.t, "drop") <- c(1,2)
attr(year, "nan") <- nan
attr(post.flood, "nan") <- nan
attr(males, "ns") <- ns
# Define pool of variables to be considered in each model
cap.vars <- c("tvar(small.t)","tvar(year)")
surv.vars <- c("tvar(small.t)","tvar(year)", "tvar(post.flood)", "ivar(males)",
"males.postflood")
# Do stepwise selection
final.fit <- F.step.cjs( cap.vars, surv.vars, histories=ch,
control=mra.control(maxfn=500, cov.meth=2) )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.