Create an inla.spde1 model object.

## Create an SPDE model object:
inla.spde1.create(mesh,
                  model = c("matern", "imatern", "matern.osc"),
                  param = NULL,
                  ...)

## Shortcuts to the matern, imatern and matern.osc models:
inla.spde1.matern(mesh, ...)
inla.spde1.imatern(mesh, ...)
inla.spde1.matern.osc(mesh, ...)

Arguments

mesh

The mesh to build the model on, as an inla.mesh object.

model

The name of the model.

param

Model specific parameters.

...

Additional parameters passed on to other methods.

Details

Note: This is an old spde object format retained for backwards compatibility. Please use inla.spde2 models for new code.

This method constructs an object for SPDE models. Currently implemented:

model="matern"

$$(\kappa^2(u)-\Delta)^{\alpha/2}(\tau(u) x(u))=W(u)$$

param:

  • alpha = 1 or 2

  • basis.T = Matrix of basis functions for \(\log\tau(u)\)

  • basis.K = Matrix of basis functions for \(\log\kappa^2(u)\)

model="imatern"

$$(-\Delta)^{\alpha/2}(\tau(u) x(u))=W(u)$$

param:

  • alpha = 1 or 2

  • basis.T = Matrix of basis functions for \(\log\tau(u)\)

Value

An inla.spde1 object.

Author

Finn Lindgren finn.lindgren@gmail.com

Examples

n = 100
field.fcn = function(loc) (10*cos(2*pi*2*(loc[,1]+loc[,2])))
loc = matrix(runif(n*2),n,2)
## One field, 2 observations per location
idx.y = rep(1:n,2)
y = field.fcn(loc[idx.y,]) + rnorm(length(idx.y))

mesh = inla.mesh.create(loc, refine=list(max.edge=0.05))
#> Warning: error in running command
#> Error in fmesher.read(prefix, "manifold"): File '/tmp/Rtmp4ztB6d/fmesher53bd675122b5.manifold' does not exist.
spde = inla.spde.create(mesh, model="matern")
#> Error: object 'mesh' not found
data = list(y=y, field=mesh$idx$loc[idx.y])
#> Error: object 'mesh' not found
formula = y ~ -1 + f(field, model=spde)
result = inla(formula, data=data, family="normal")
#> Error in inla(formula, data = data, family = "normal"): 
#> 	Argument `data' must be a data.frame or a list.

## Plot the mesh structure:
plot(mesh)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'mesh' not found
# \donttest{
if (require(rgl)) {
  ## Plot the posterior mean:
  plot(mesh, rgl=TRUE,
       result$summary.random$field[,"mean"],
       color.palette = colorRampPalette(c("blue","green","red")))
  ## Plot residual field:
  plot(mesh, rgl=TRUE,
       result$summary.random$field[,"mean"]-field.fcn(mesh$loc),
       color.palette = colorRampPalette(c("blue","green","red")))
}
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'mesh' not found
# }