Description Usage Arguments Value Examples

View source: R/sim_dist_spde.R

Returns a function to use inside `sim_distribution`

to
generate the error term.

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
)
``` |

`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 |

Returns a function for use in `sim_distribution`

.

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")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.