/
README.Rmd
114 lines (82 loc) · 2.07 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
output:
md_document:
variant: gfm
html_document:
keep_md: true
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE, results='hide'}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-images/",
message = FALSE
)
Sys.setlocale("LC_TIME", "C")
```
# prophetExt
[![Travis-CI Build Status](https://travis-ci.org/hoxo-m/prophetExt.svg?branch=master)](https://travis-ci.org/hoxo-m/prophetExt)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/prophetExt)](https://cran.r-project.org/package=prophetExt)
Extension for Facebook [Prophet](https://github.com/facebookincubator/prophet).
## Installation
You can install prophetExt from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("hoxo-m/prophetExt")
```
or
```{r githubinstall, eval=FALSE}
# install.packages("githubinstall")
githubinstall::githubinstall("prophetExt")
```
## Example
Ready data.
```{r ready-data}
df <- read.csv("https://raw.githubusercontent.com/facebook/prophet/master/examples/example_wp_peyton_manning.csv")
df$y <- log(df$y)
```
Fit model.
```{r fit-model, results='hide'}
library(prophet)
m <- prophet(df, daily.seasonality = FALSE)
```
### Change Points
Pick changepoints.
```{r example-pick-changepoints}
library(prophetExt)
cpts <- prophet_pick_changepoints(m)
head(cpts)
```
Draw changepoints.
```{r draw-changepoints}
future <- make_future_dataframe(m, 365)
fore <- predict(m, future)
plot(m, fore) + autolayer(cpts)
```
### Outliers
Detect outliers.
```{r detect-outliers, results='hide'}
outliers <- prophet_detect_outliers(m)
```
```{r print-outliers}
head(outliers)
```
Draw outliers.
```{r draw-outliers}
plot(m, fore) + autolayer(outliers)
```
Draw outliers using calendar plot.
```{r draw-calendar-plot, fig.height=7.5, fig.width=10}
prophet_calendar_plot(outliers)
```
### SHF (Simulated Historical Forcast)
```{r shf, results='hide'}
shf <- prophet_shf(m, periods = 365)
```
```{r shf-result}
head(shf$estimated)
```
```{r plot-shf}
plot(shf)
```