sim_ays_covar_spde: Simulate age-year-space covariance using SPDE approach

Description Usage Arguments Value Examples

View source: R/sim_dist_spde.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
sim_ays_covar_spde(
  sd = 2.8,
  range = 300,
  model = "barrier",
  phi_age = 0.5,
  phi_year = 0.9,
  group_ages = 5:20,
  group_years = NULL,
  mesh,
  barrier.triangles
)

Arguments

sd

Variance (can be age specific)

range

Decorrelation range

model

String indicating "barrier" or "spde" to generate Q with

phi_age

Defines autocorrelation through ages. Can be one value or a vector of the same length as ages.

phi_year

Defines autocorrelation through years. Can be one value or a vector of the same length as years.

group_ages

Make space-age-year variance equal across these ages

group_years

Make space-age-year variance equal across these years

mesh

The mesh used to generate the precision matrix

barrier.triangles

the set of triangles in the barrier of the mesh for the barrier model

Value

Returns a function for use in sim_distribution.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
##SPDE Approach

##Make a grid
MyGrid <- make_grid(res = c(10,10))
##Make a mesh based off it
MyMesh <- make_mesh(MyGrid)
sim <- sim_abundance(ages=1:10,years = 1:10) %>%
         sim_distribution(grid = MyGrid,
                          ays_covar = sim_ays_covar_spde(phi_age = 0.8,
                                                         phi_year = 0.1,
                                                         model = "spde",
                                                         mesh = MyMesh),
                          depth_par = sim_parabola(mu = 200,
                                                   sigma = 50))
plot_distribution(sim,ages = 1:5, years = 1:5,type="heatmap")

##Barrier Approach
sim <- sim_abundance(ages=1:10,years=1:10) %>%
         sim_distribution(grid = survey_grid,
                          ays_covar = sim_ays_covar_spde(phi_age = 0.8,
                                                         phi_year = 0.1,
                                                         model = "barrier",
                                                         mesh = survey_lite_mesh$mesh,
                                                         barrier.triangles =
                                                         survey_lite_mesh$barrier_tri),
                          depth_par = sim_parabola())
plot_distribution(sim,ages = 1:5, years = 1:5,type="heatmap")

SimSurvey documentation built on Jan. 16, 2021, 5:31 p.m.