compute_GMRF_matrices: Compute (I)GMRF incidence, precision and restriction matrices corresponding to a generic model component
Description
This function computes incidence, precision and restriction matrices, or
a subset thereof, for a Gaussian Markov Random Field (GMRF).
A GMRF is specified by a formula passed to the factor argument,
in the same way as for the factor argument of gen.
A list containing some or all of the components D (incidence matrix),
Q (precision matrix) and R (restriction matrix).
Arguments
factor
factor formula of a generic model component,
see gen.
data
data frame to be used in deriving the matrices.
D
if TRUE compute the incidence matrix.
Q
if TRUE compute the precision matrix.
R
if TRUE compute the restriction matrix.
cols2remove
if an integer vector is passed, the dimensions (columns of D,
rows and columns of Q and rows of R) that are removed. This can be useful in the
case of empty domains.
remove.redundant.R.cols
whether to test for and remove redundant restrictions from restriction matrix R
enclos
enclosure to look for objects not found in data.
n.parent
for internal use; in case of custom factor, the number of frames up
the calling stack in which to evaluate any custom matrices
n <- 1000
dat <- data.frame(
x = rnorm(n),
f1 = factor(sample(1:50, n, replace=TRUE)),
f2 = factor(sample(1:10, n, replace=TRUE))
)
mats <- compute_GMRF_matrices(~ f1 * RW1(f2), dat)
str(mats)