---
title: "Multiple-Linear-Regression-Correction"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Multiple-Linear-Regression-Correction}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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


First the package should be loaded:
```{r setup}
library(aws.wrfsmn)
```

The example data to use will be 'eva' and should be call it with data:
```{r, echo = FALSE, results = FALSE}
data(eva)
```

```{r}
head(eva)
```

A Multiple Linear Regression is made between the predictand (observed evaporation) and the following predictors:
```{r}
test.predictors <- c('OUT_PREC',
                     'OUT_EVAP',
                     'OUT_RUNOFF',
                     'OUT_BASEFLOW',
                     'OUT_SOIL_MOIST_lyr_1',
                     'OUT_EVAP_CANOP',
                     'OUT_SURF_TEMP')
```

Using multiple.guidance function to obtain the regression coefficients:
```{r}
mg <- multiple.guidance(input.data = eva, predictand = 'evapo_obs', predictors = test.predictors)
mg
```

The evaluation of the correction applied from the mg regression is:
```{r}
evaluation.eva <- mg.evaluation(input.data = eva, predictand = 'evapo_obs', predictors = test.predictors, var.model = 'OUT_EVAP', lmodel = mg)

head(evaluation.eva)
```

Finally, the monthly data is calculated to be plot:
```{r, out.width = "100%", fig.align = "center", echo=FALSE}
ploting(daily2monthly(evaluation.eva[[1]]))
```