Learn R Programming

INLAtools (version 0.0.8)

cgeneric-class: Organize data for the latent GMRF C interface for INLA.

Description

A GMRF is defined from model parameters \(\theta\) that would parametrize a (sparse) precision matrix.

The elements of a GMR are:

  • graph to define the non-zero precision matrix pattern. only the upper triangle including the diagonal is needed.

  • Q vector where the

    • first element (N) is the size of the matrix,

    • second element (M) is the number of non-zero elements in the upper part (including) diagonal

    • the remaining (M) elements are the actual precision (upper triangle plus diagonal) elements whose order shall follow the graph definition.

  • mu the mean vector,

  • initial vector with

    • first element as the number of the parameters in the model

    • remaining elements should be the initials for the model parameters.

  • log.norm.const log of the normalizing constant.

  • log.prior log of the prior for the model parameters.

Usage

cgeneric(model, ...)

# S3 method for character cgeneric(model, ...)

# S3 method for `function` cgeneric(model, ...)

# S3 method for cgeneric cgeneric(model, ...)

# S3 method for inla.cgeneric cgeneric(model, ...)

cgenericBuilder(...)

mapper1(model)

cgeneric_shlib(debug, package, useINLAprecomp)

# S3 method for cgeneric print(x, ...)

# S3 method for cgeneric summary(object, ...)

# S3 method for cgeneric plot(x, y, ...)

Value

a method to build a cgeneric should return a named list of cgeneric class that contains a named list f that contains (at least):

  • model a character always equal to cgeneric,

  • n an integer greater than 0, and

  • cgeneric as a named list that contains the data needed to define the model. Each element on ...$f$cgeneric is also a named list containing ints, doubles, characters, matrices and smatrices.

  • (possible) extraconstr as a named list with: A as a n times k matrix and e as a length k vector.

The cgeneric_shlib function returns a character

with the path to the shared lib.

Arguments

model

object class for what a cgeneric method exists. E.g., if it is a character, a specific function will be called. E.g. cgeneric("iid", ...") calls cgeneric_iid(...).

...

not used

debug

integer, used as verbose in debug.

package

character giving the name of the package that contains the cgeneric model.

useINLAprecomp

logical, indicating if it is to use the shared object previously copied and compiled by INLA.

x

a cgeneric object

object

a cgeneric object

y

not used

Functions

  • cgeneric(cgeneric): Returns the model object unchanged.

  • cgeneric(inla.cgeneric): Converts a regular inla.cgeneric object to cgeneric.

  • mapper1(): A default mapper for a cgeneric/rgeneric model

  • print(cgeneric): Print the cgeneric object

  • summary(cgeneric): A summary for a cgeneric object

  • plot(cgeneric): A plot for a cgeneric object

See Also

INLA::cgeneric() and INLAtools-methods()

Examples

Run this code
library(INLAtools)

R <- Sparse(crossprod(diff(diag(10))))
R

m <- cgeneric("generic0", R = R,
	      scale = FALSE,
	      param = c(1, 0.01))
m

all.equal(R, Sparse(prec(m, theta = 0)))

graph(m)
prior(m, theta = 0)
prior(m, theta = matrix(-1:1, 1)) ## see ?prior.cgeneric

Run the code above in your browser using DataLab