---
title: "Example Models"
output: 
  rmarkdown::html_vignette:
    toc: true
vignette: >
  %\VignetteIndexEntry{Example Models}
  %\VignetteEncoding{UTF-8}
  %\VignetteEngine{knitr::rmarkdown}
editor_options: 
  chunk_output_type: console
---

[![status](https://img.shields.io/badge/status-mature%20draft-yellow)](https://canmod.github.io/macpan2/articles/vignette-status#mature-draft)

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(macpan2)
```

## Finding Example Models

The `macpan2` comes with a set of example model definitions, which can be listed with the `show_models` function.
```{r eval = FALSE}
show_models()
```
```{r echo = FALSE}
kableExtra::kable(show_models(for_markdown = TRUE))
```

There are three things that you can do with the items on this list: read them, use them, and modify them. To read them, just click on the links above to take you to each model. To use them and modify them, please continue reading.

## Using Examples

To use the `sir` example it can be read into R using the following code.
```{r}
sir_dir = system.file("starter_models", "sir", package = "macpan2")
sir = mp_tmb_library(sir_dir)
print(sir)
```
To see how to actually generate simulations from this model see [this article](https://canmod.github.io/macpan2/articles/quickstart). To use another model, again, replace `sir` with another entry in the `dir` column above.

## Modifying Examples

To take `sir` as a jumping-off point for producing your own model one may use the following code.
```{r}
my_sir_dir = file.path(tempdir(), "my_sir")
mp_model_starter("sir", my_sir_dir)
```

After running this code you can go to the files in `my_sir_dir` and modify what you see there. Note that you typically want to chose a specific directory for your model instead of using `tempdir`. You still need to read your own model in the usual way.
```{r}
my_sir = mp_tmb_library(my_sir_dir)
print(my_sir)
```
These look identical to what came before, but that's just because it hasn't been modified ... yet ...
