---
output:
  html_document:
    toc: true
    toc_float: true
    css: report.css
params:
  model: model
  type: type
  folder: folder
  plot_folder: plot_folder
  test: test
  response_curves: false
  only_presence: false
  jk: false
  env: null
  clamp: true
  permut: 10
  verbose: true
title: "`r class(params$model@model)` model for *`r params$model@data@species`*"
---

```{r setup, echo=F, message=FALSE}
options(crayon.enabled = TRUE)
```

**`r class(params$model@model)`** output produced using **SDMtune** version `r packageVersion("SDMtune")` (Vignali S. *et al.*, 2020).

```{r save files, echo=FALSE, message=FALSE}
.save_report_files(params)
```

# ROC curve

```{r plot ROC, echo=FALSE, message=FALSE}
.plot_report_roc(params)
```

# Thresholds

```{r thresholds, echo=FALSE, message=FALSE}
.compute_report_thresholds(params)
```

`r if(!params$response_curves) {"<!--"}`
# Response curves {#response}

### Marginal curves:

```{r marginal response, message=FALSE, echo=FALSE, warning=FALSE, eval=params$response_curves}
.plot_report_response_curves(params, type = "marginal")
```

### Univariate curves:

```{r univariate response, message=FALSE, echo=FALSE, warning=FALSE, eval=params$response_curves}
.plot_report_response_curves(params, type = "univariate")
```

`r if(!params$response_curves) {"-->"}`

`r if(is.null(params$env)) {"<!--"}`
# Distribution map

```{r prediction, echo=FALSE, message=FALSE, eval=!is.null(env)}
.make_report_prediction(params)
```

`r if(is.null(params$env)) {"-->"}`

# Variable importance

```{r variable importance, echo=FALSE, message=FALSE}
.compute_report_variable_importance(params)
```

`r if(!params$jk) {"<!--"}`
# Jackknife test

```{r, echo=FALSE, message=FALSE, eval=params$jk}
.compute_report_jk(params, test)
```

`r if(!params$jk) {"-->"}`

# Model settings

Shown below the settings used to train the model:

```{r model settings, echo=FALSE, message=FALSE, results='asis'}
.write_report_model_settings(params)
```

# References

- Vignali, S., Barras, A. G., Arlettaz, R., Braunisch, V. (2020). *SDMtune*: An R package to tune and evaluate species distribution models. Ecology and Evolution, **10**(20), 11488–11506. <https://doi.org/10.1002/ece3.6786>
- Vignali, S., Barras, A. G., Braunisch, V. (`r format(packageDate("SDMtune"), format = "%Y")`). *SDMtune*: Species Distribution Model Selection. R package version `r packageVersion("SDMtune")`. `r ifelse(grepl("9000",packageVersion("SDMtune")), "<https://github.com/ConsBiol-unibern/SDMtune>", "<https://CRAN.R-project.org/package=SDMtune>")`
