Skip to contents

Extract field and parameter values and distributions for an rspde effect from an inla result object.

Usage

rspde.result(inla, name, rspde, compute.summary = TRUE)

Arguments

inla

An inla object obtained from a call to inla().

name

A character string with the name of the rSPDE effect in the inla formula.

rspde

The inla_rspde object used for the effect in the inla formula.

compute.summary

Should the summary be computed?

Value

If the model was fitted with matern parameterization (the default), it returns a list containing:

marginals.range

Marginal densities for the range parameter

marginals.log.range

Marginal densities for log(range)

marginals.std.dev

Marginal densities for std. deviation

marginals.log.std.dev

Marginal densities for log(std. deviation)

marginals.values

Marginal densities for the field values

summary.log.range

Summary statistics for log(range)

summary.log.std.dev

Summary statistics for log(std. deviation)

summary.values

Summary statistics for the field values

If compute.summary is TRUE, then the list will also contain

summary.kappa

Summary statistics for kappa

summary.tau

Summary statistics for tau

If the model was fitted with the spde parameterization, it returns a list containing:

marginals.kappa

Marginal densities for kappa

marginals.log.kappa

Marginal densities for log(kappa)

marginals.log.tau

Marginal densities for log(tau)

marginals.tau

Marginal densities for tau

marginals.values

Marginal densities for the field values

summary.log.kappa

Summary statistics for log(kappa)

summary.log.tau

Summary statistics for log(tau)

summary.values

Summary statistics for the field values

If compute.summary is TRUE, then the list will also contain

summary.kappa

Summary statistics for kappa

summary.tau

Summary statistics for tau

For both cases, if nu was estimated, then the list will also contain

marginals.nu

Marginal densities for nu

If nu was estimated and a beta prior was used, then the list will also contain

marginals.logit.nu

Marginal densities for logit(nu)

summary.logit.nu

Marginal densities for logit(nu)

If nu was estimated and a truncated lognormal prior was used, then the list will also contain

marginals.log.nu

Marginal densities for log(nu)

summary.log.nu

Marginal densities for log(nu)

If nu was estimated and compute.summary is TRUE, then the list will also contain

summary.nu

Summary statistics for nu

Examples

 #devel version
if (requireNamespace("INLA", quietly = TRUE)){
library(INLA)

set.seed(123)

m <- 100
loc_2d_mesh <- matrix(runif(m * 2), m, 2)
mesh_2d <- inla.mesh.2d(
  loc = loc_2d_mesh,
  cutoff = 0.05,
  max.edge = c(0.1, 0.5)
)
sigma <- 0.01
range <- 0.2
nu <- 0.8
kappa <- sqrt(8 * nu) / range
op <- matern.operators(
  mesh = mesh_2d, nu = nu,
  kappa = kappa, sigma = sigma, m = 2
)
u <- simulate(op)
A <- inla.spde.make.A(
  mesh = mesh_2d,
  loc = loc_2d_mesh
)
sigma.e <- 0.1
y <- A %*% u + rnorm(m) * sigma.e
Abar <- rspde.make.A(mesh = mesh_2d, loc = loc_2d_mesh)
mesh.index <- rspde.make.index(name = "field", mesh = mesh_2d)
st.dat <- inla.stack(
  data = list(y = as.vector(y)),
  A = Abar,
  effects = mesh.index
)
rspde_model <- rspde.matern(
  mesh = mesh_2d,
  nu_upper_bound = 2
)
f <- y ~ -1 + f(field, model = rspde_model)
rspde_fit <- inla(f,
  data = inla.stack.data(st.dat),
  family = "gaussian",
  control.predictor =
    list(A = inla.stack.A(st.dat)),
           inla.mode = "experimental"
)
result <- rspde.result(rspde_fit, "field", rspde_model)
summary(result)
plot(result)
}
#> Error in inla.inlaprogram.has.crashed() : 
#>   The inla-program exited with an error. Unless you interupted it yourself, please rerun with verbose=TRUE and check the output carefully.
#>   If this does not help, please contact the developers at <help@r-inla.org>.
#> 
#>  *** inla.core.safe:  inla.program has crashed: rerun to get better initial values. try=1/2 
#> 
#>  *** inla.core.safe:  rerun with improved initial values 



#devel.tag