forked from Shamar-Stewart/ForecastingS22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ARIMA_shiny_active.Rmd
63 lines (45 loc) · 2.31 KB
/
ARIMA_shiny_active.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
---
title: "Simulating AR(1) and MA(1) models"
author: "Amso Proud"
date: ""
output:
html_document:
toc: true
toc_float: true
theme: journal
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, size = "small")
require(mosaic)
require(fpp2)
theme_set(theme_bw())
```
## Interactive Plot of ARMA processes.
This R Markdown document is created to help with you understanding of how to identify AR and MA processes. You can slide the scales to select the $\phi$ ($\omega$) parameter value in the AR (MA) equations.
For simplicity, I have ignored the case where we have an ARMA model-- lags of both $y$ and $\varepsilon$ are added as regressors in our model. Additionally, our model will accept only 1 parameter vale -- AR(1) or MA(1) models only.
These graphs are created using the `shiny` application builder in `R`.
## Inputs and Outputs
In this section we will define the Shiny inputs and output. The cool thing about the interactive shiny document is that the outputs are automatically updated whenever inputs change.
```{r arma, echo = FALSE, eval = TRUE}
inputPanel(
numericInput(inputId = ________, ______________ , value = _____________), # Input the desired size of the sample we will be generating.
sliderInput(
withMathJax(),
inputId = _____________, label = ________________,
min = __________, max = ______________, value = ________, step = _____), # We will use the slider to determine the AR and MA coefs
radioButtons(inputId = "show", ___________________,
choices = c(`AR` = "ar",
`MA` = "ma"), # Use radio buttons to specify the model under consideration
selected = ________________) # By default, we will choose the ar model
)
renderPlot({
set.seed(123) # Set seeds to ensure reproducibility
if ("ar" %in% ____________) #if ar is selected above, we will execute this equation.
ggtsdisplay(______________________), main = paste0(______________________))
if ("ma" %in% ___________) #if ma is selected above, we will execute this equation.
ggtsdisplay(_______________________, main = paste0(___________________________))
})
```
## Want to learn more about `shiny`?
To learn more, see [Interactive Documents](http://rmarkdown.rstudio.com/authoring_shiny.html).