---
title: "Case Study - Fitting SARS-CoV-2"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Case Study - Fitting SARS-CoV-2}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

```{r setup}
library(intervalcalc)
```

## Prepare the data

First, we'll prepare some data:

```{r}
dat <- prep_interval_data(nishiura)
```

## Fit the Models

Now using the formatted data, we can pass the data to a series of or a particular distribution. 


```{r echo=FALSE}
#saveRDS(fits, here::here("vignettes", "fits.rds"))

fits <- readRDS("fits.rds")
```


```r
fits <- fit_interval_data(interval_data = dat, distribution = c("gamma", "lognormal"))
```


We can then inspect the outputs:

```{r}
knitr::kable(fits$gamma$sumz, digits = 2)
```

```{r}
knitr::kable(fits$lognormal$sumz, digits = 2)
```

```{r}
fits$gamma$loo
```

## Determine Best Fit

```{r}
loo::loo_compare(fits$gamma$loo, fits$lognormal$loo)
```

