-
Notifications
You must be signed in to change notification settings - Fork 4
/
README.Rmd
89 lines (64 loc) · 2.08 KB
/
README.Rmd
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
output:
github_document:
html_preview: false
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.align = "center")
knitr::opts_chunk$set(fig.width = 12, fig.height = 7, fig.path = "README-", dpi = 200)
knitr::opts_chunk$set(warning = FALSE)
# options(width = 100)
```
[![Travis-CI Build Status](https://travis-ci.org/ErickChacon/mbsi.svg?branch=master)](https://travis-ci.org/ErickChacon/mbsi)
# mbsi: Model-based standardized index
The mbsi package provide tools to compute and visualize extreme
hydro-climatic events using the standardized precipitation index
(SPI) and the model-based standardized index (MBSI). The
difference with between the MBSPI and the classical SPI index is
that it consider the association between continuous times using
cycle P-splines ‘pbc’. The package can also with work with
precipitation series containing missing values (NA), 0 or only
non-zero values.
# Installation
This package is not still on CRAN, so installation is done using the `devtools`
package as shown below:
```{r, eval = FALSE}
devtools::install_github("ErickChacon/mbsi")
```
# How to use it?
## Analysing the standardized precipitation with time-scale 1
```{r mbsi}
library(mbsi)
data(simrain)
# Compute mbsi
spi_rain <- mbsi(y = simrain$rain, time = simrain$time, tscale = 1, period = 52)
```
```{r mbsi_fit}
# Visualize model fitting
plot(spi_rain)
```
```{r mbsi_ecdf}
# Visualize distribution of empirical cumulative density function
plot(spi_rain, which = "ecdf", binwidth = 0.05)
```
```{r mbsi_extremes}
# Visualize extreme events
plot_extremes(spi_rain, threshold = 2)
```
## Analysing the standardized precipitation with time-scale 8
```{r mbsi_8}
# Compute mbsi
spi_rain_8 <- mbsi(y = simrain$rain, time = simrain$time, tscale = 8, period = 52)
```
```{r mbsi_fit_8}
# Visualize model fitting
plot(spi_rain_8)
```
```{r mbsi_ecdf_8}
# Visualize distribution of empirical cumulative density function
plot(spi_rain_8, which = "ecdf", binwidth = 0.05)
```
```{r mbsi_extremes_8}
# Visualize extreme events
plot_extremes(spi_rain_8, threshold = 2)
```