Learn R Programming

mra (version 2.1)

F.step.cjs: F.step.cjs - Stepwise model selection for CJS models.

Description

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.

Usage

F.step.cjs(cap.covars, surv.covars, fit.crit = "qaicc", signif.drop = 0, signif.increase = 0, plot = TRUE, ...)

Arguments

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
signif.drop
A scalar specifying the decrease in fit.crit that should be considered "significant" during forward steps. This argument controls stopping and is functionally equivalent to the alpha-to-enter
signif.increase
A scalar specifying the increase in fit.crit that should be is considered "significant" during backward looks. This argument controls elimination, but not stoppage. A variable in the current model
plot
A scalar specifying whether the minimum fit.crit at the end on each forward-backward step should be plotted. This plot can be useful for assessing which variable(s) cause relatively "big" and which cause
...
Additional arguments to F.cjs.estim, like histories= , nhat.v.meth=, c.hat=, control=, etc.

Value

  • 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.

Details

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.

See Also

F.cjs.estim, F.fit.table

Examples

Run this code
#   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 <- males
#   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) )

Run the code above in your browser using DataLab