F.cr.model.matrix {mra} | R Documentation |
Returns the model matrix for a capture-recapture model in the form of a (giant) 2D matrix.
F.cr.model.matrix(capture, survival)
capture |
Formula for the capture model. Must be a formula object with no response, then ~, followed by the names of 2-D arrays of covariates to fit in the capture model. For example: capture = ~ age + sex, where age and sex are matrices. |
survival |
Formula for the survival model. Must be a formula object with no response, then ~, followed by the names of 2-D arrays of covariates to fit in the survival model. For example: capture = ~ age + sex, where age and sex are matrices. |
This routine is intended to be called internally by model fitting routines of MRA. General users should never have to call this routine.
This routine uses a call to eval
with a model frame, and calls the
R internal model.matrix
to
resolve the matrices in the formula. All matrices specified in the models
should be in the current scope and accessible to both eval
and model.matrix
.
A list containing the following components:
capX |
A NAN by IX+(NX*NS) matrix containing covariate values for the capture
model. Matrices specified in the model are column appended together.
NAN = nrow(x) where x is a 2-D matrix in the model (i.e.,
number of animals). NS = ncol(x) (i.e., number of capture occasions).
NX = number of matrices specified in the model. IX = 1 if an intercept is included,
0 otherwise. The j-th covariate matrix specified in the model can be accessed directly with
capX[, IX+1+(NS*(j-1)):(NS*j) ] . |
surX |
A NAN by IY+(NY*NS) matrix containing covariate values for the survival
model. Matrices specified in the model are column appended together.
NAN = nrow(x) where y is a 2-D matrix in the model (i.e.,
number of animals). NS = ncol(y) (i.e., number of capture occasions).
NY = number of matrices specified in the model. IY = 1 if an intercept is included,
0 otherwise. The j-th covariate matrix specified in the model can be accessed directly with
capY[, IY+1+(NS*(j-1)):(NS*j) ] . |
n.cap.covars |
Number of matrices specified in the capture model (NX above). |
n.sur.covars |
Number of matrices specified in the survival model (NY above). |
cap.intercept |
TRUE or FALSE depending on whether an intercept was included in the capture model |
sur.intercept |
TRUE or FALSE depending on whether an intercept was included in the survival model |
cap.vars |
Vector of names for the NX covariates in the capture model. |
sur.vars |
Vector of names for the NY covariates in the survival model. |
Trent McDonald, WEST-INC, tmcdonald@west-inc.com
F.cjs.estim
, model.matrix
, eval
# Synthetic example with 10 animals and 5 occasions nan <- 10 ns <- 5 sex <- matrix( as.numeric(runif( nan ) > 0.5), nrow=nan, ncol=ns ) x <- matrix( runif( nan*ns ) , nrow=nan, ncol=ns ) F.cr.model.matrix( capture= ~ sex + x, survival= ~ -1 + x )