Skip to contents

rSPDE inlabru mapper

Usage

ibm_n.bru_mapper_inla_rspde_fintrinsic(mapper, ...)

ibm_values.bru_mapper_inla_rspde_fintrinsic(mapper, ...)

ibm_jacobian.bru_mapper_inla_rspde_fintrinsic(mapper, input, ...)

bru_get_mapper.inla_rspde(model, ...)

ibm_n.bru_mapper_inla_rspde(mapper, ...)

ibm_values.bru_mapper_inla_rspde(mapper, ...)

ibm_jacobian.bru_mapper_inla_rspde(mapper, input, ...)

Arguments

mapper

A bru_mapper_inla_rspde object

...

Arguments passed on to other methods

input

The values for which to produce a mapping matrix

model

An inla_rspde object for which to construct or extract a mapper

Examples

# \donttest{
if (rspde_safe_inla() &&
  requireNamespace("inlabru", quietly = TRUE)) {
  library(INLA)
  library(inlabru)

  set.seed(123)
  m <- 50
  loc_2d_mesh <- matrix(runif(m * 2), m, 2)
  mesh_2d <- inla.mesh.2d(
    loc = loc_2d_mesh,
    cutoff = 0.1,
    max.edge = c(0.5, 0.5)
  )
  sigma <- 1
  range <- 0.2
  nu <- 0.8
  kappa <- sqrt(8 * nu) / range
  op <- matern.operators(
    mesh = mesh_2d, nu = nu,
    range = range, sigma = sigma, m = 1,
    parameterization = "matern"
  )
  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
  y <- as.vector(y)

  data_df <- data.frame(
    y = y, x1 = loc_2d_mesh[, 1],
    x2 = loc_2d_mesh[, 2]
  )
  rspde_model <- rspde.matern(
    mesh = mesh_2d,
    nu_upper_bound = 1
  )

  cmp <- y ~ Intercept(1) +
    field(cbind(x1,x2), model = rspde_model)


  rspde_fit <- bru(cmp, data = data_df)
  summary(rspde_fit)
}
#> Changing INLA option num.threads from '4:1' to '1:1:1'.
#> 
#> Warning: `inla.mesh.2d()` was deprecated in INLA 23.08.18.
#>  Please use `fmesher::fm_mesh_2d_inla()` instead.
#>  For more information, see
#>   https://inlabru-org.github.io/fmesher/articles/inla_conversion.html
#>  To silence these deprecation messages in old legacy code, set
#>   `inla.setOption(fmesher.evolution.warn = FALSE)`.
#>  To ensure visibility of these messages in package tests, also set
#>   `inla.setOption(fmesher.evolution.verbosity = 'warn')`.
#> inlabru version: 2.15.0 
#> INLA version: 26.08.22 
#> Latent components:
#> Intercept: main = linear(1)
#> field: main = cgeneric(cbind(x1, x2))
#> Observation models:
#>   Model tag: <No tag>
#>     Family: 'gaussian'
#>     Data class: 'data.frame'
#>     Response class: 'numeric'
#>     Predictor: y ~ Intercept + field
#>     Additive/Linear/Rowwise: TRUE/TRUE/TRUE
#>     Used components: effect[Intercept, field], latent[] 
#> Time used:
#>     Pre = 0.0888, Running = 0.283, Post = 0.0359, Total = 0.408 
#> Fixed effects:
#>            mean    sd 0.025quant 0.5quant 0.975quant  mode kld
#> Intercept 0.315 0.196     -0.084    0.317        0.7 0.317   0
#> 
#> Random effects:
#>   Name	  Model
#>     field CGeneric
#> 
#> Model hyperparameters:
#>                                           mean     sd 0.025quant 0.5quant
#> Precision for the Gaussian observations 143.14 51.941      64.59   135.38
#> Theta1 for field                         -5.60  2.813     -12.01    -5.27
#> Theta2 for field                          2.69  0.467       1.89     2.66
#> Theta3 for field                          1.21  1.697      -1.45     1.01
#>                                         0.975quant    mode
#> Precision for the Gaussian observations     266.15 121.061
#> Theta1 for field                             -1.22  -3.659
#> Theta2 for field                              3.71   2.500
#> Theta3 for field                              5.07   0.082
#> 
#> Marginal log-Likelihood:  -34.34 
#>  is computed 
#> Posterior summaries for the linear predictor and the fitted values are computed
#> (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
#> 
# }