Constructs precision matrices for first- and second-order random walk (RW1/RW2) latent models used within INLA.

inla.rw(n, order = 1L, sparse = TRUE, scale.model = FALSE)

inla.rw1(n, ...)

inla.rw2(n, ...)

Arguments

n

Number of nodes in the latent field.

order

Order of the random walk. Use 1 for RW1 and 2 for RW2.

sparse

Logical; return a sparse matrix (default TRUE).

scale.model

Logical; scale the model so that the geometric mean of the marginal variances equals one.

...

Additional arguments forwarded to inla.rw().

Details

inla.rw() builds the banded precision matrix corresponding to a random walk of a given order. The helpers inla.rw1() and inla.rw2() generate RW1 and RW2 precision matrices directly.

Value

A matrix (sparse by default) representing the RW1/RW2 precision structure.

See also

inla.doc for latent model documentation.

Examples

Q1 <- inla.rw1(10)
#> Error in inla.rw1(10): could not find function "inla.rw1"
Q2 <- inla.rw2(10, sparse = FALSE)
#> Error in inla.rw2(10, sparse = FALSE): could not find function "inla.rw2"