inla.spde.make.index {INLA} | R Documentation

## SPDE model index vector generation

### Description

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

### Usage

    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(s)

Finn Lindgren finn.lindgren@gmail.com

### See Also

`inla.spde.make.A()`, `inla.spde2.result()`

### Examples

    loc <- matrix(runif(100 * 2), 100, 2)
    mesh <- fmesher::fm_mesh_2d_inla(loc.domain = loc, max.edge = c(0.1, 0.5))
    spde <- inla.spde2.matern(mesh)
    index <- inla.spde.make.index("spatial", spde$n.spde, n.repl = 2)
    spatial.A <- inla.spde.make.A(mesh, loc,
        index = rep(1:nrow(loc), 2),
        repl = rep(1:2, each = nrow(loc))
    )
    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"
    )
    data <- inla.stack.data(stack, spde = spde)
    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))
    )
    spde.result <- inla.spde2.result(result, "spatial", spde)

[Package INLA version 26.02.05 Index]