Generates a list of named index vectors for an SPDE model.

inla.spde.make.index(name,
                     n.spde,
                     n.group = 1,
                     n.repl = 1,
                     ...)

Arguments

name

A character string with the base name of the effect.

n.spde

The size of the model, typically from spde$n.spde.

n.group

The size of the group model.

n.repl

The number of model replicates.

...

Additional parameters. Currently unused.

Value

A list of named index vectors.

name

Indices into the vector of latent variables

name.group

'group' indices

name.repl

Indices for replicates

Author

Finn Lindgren finn.lindgren@gmail.com

Examples

loc = matrix(runif(100*2),100,2)
mesh = inla.mesh.create.helper(points.domain=loc, max.edge=c(0.1,0.5))
#> Warning: error in running command
#> Error in fmesher.read(prefix, "manifold"): File '/tmp/Rtmp4ztB6d/fmesher53bd668806f7.manifold' does not exist.
spde = inla.spde2.matern(mesh)
#> Error: object 'mesh' not found
index = inla.spde.make.index("spatial", spde$n.spde, n.repl=2)
#> Error: object 'spde' not found
spatial.A = inla.spde.make.A(mesh, loc,
                             index=rep(1:nrow(loc), 2),
                             repl=rep(1:2, each=nrow(loc)))
#> Error: object 'mesh' not found
y = 10+rnorm(100*2)
stack = inla.stack(data=list(y=y),
                   A=list(spatial.A),
                   effects=list(c(index, list(intercept=1))),
                   tag="tag")
#> Error: object 'spatial.A' not found
data = inla.stack.data(stack, spde=spde)
#> Error in inla.require.inherits(stack, "inla.data.stack", "'stack'"): 'stack' must inherit from class "inla.data.stack".
formula = y ~ -1 + intercept + f(spatial, model=spde,
                                 replicate=spatial.repl)
result = inla(formula, family="gaussian", data=data, 
              control.predictor=list(A=inla.stack.A(stack)))
#> Error in inla(formula, family = "gaussian", data = data, control.predictor = list(A = inla.stack.A(stack))): 
#> 	Argument `data' must be a data.frame or a list.
spde.result = inla.spde2.result(result, "spatial", spde)
#> Error: object 'result' not found