[Experimental]

sim_ays_covar_spde(
  sd = 2.8,
  range = 300,
  model = "spde",
  phi_age = 0.5,
  phi_year = 0.9,
  group_ages = 5:20,
  group_years = NULL,
  mesh,
  barrier.triangles
)

Arguments

sd

Variance of the process (can be age-specific).

range

Decorrelation range.

model

Either "barrier" or "spde"; determines how the precision matrix Q is generated.

phi_age

Autocorrelation through ages. Can be a single value or a vector the same length as ages.

phi_year

Autocorrelation through years. Can be a single value or a vector the same length as years.

group_ages

Ages to group together for shared space-age-year variance.

group_years

Years to group together for shared space-age-year variance.

mesh

The mesh used to generate the precision matrix.

barrier.triangles

The set of mesh triangles that define the barrier (used only in the barrier model).

Value

A function that can be passed to sim_distribution() as the ays_covar argument.

Details

Returns a function for use inside sim_distribution() to generate the error term.

Examples

# \donttest{
if (requireNamespace("INLA")) {

  # Make a grid
  my_grid <- make_grid(res = c(10, 10))

  # Make a mesh based on the grid
  my_mesh <- make_mesh(my_grid)

  # Simulate and plot
  sim <- sim_abundance(ages = 1:10, years = 1:10) |>
    sim_distribution(
      grid = my_grid,
      ays_covar = sim_ays_covar_spde(
        phi_age = 0.8,
        phi_year = 0.1,
        model = "spde",
        mesh = my_mesh
      ),
      depth_par = sim_parabola(mu = 200, sigma = 50)
    )

  plot_distribution(sim, ages = 1:5, years = 1:5, type = "heatmap")
}
# }