-
Notifications
You must be signed in to change notification settings - Fork 0
/
ar_1_simulation.Rmd
70 lines (58 loc) · 1.41 KB
/
ar_1_simulation.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
---
title: "Simulate Time Series"
runtime: shiny
output: html_document
---
This is an interactive document. It interactively simmulates a Moving average order 1 model.
The same code that could simulate the series non interactively is also included.
Make sure you have the following packages installed on your system.
```{r,echo=FALSE,message=FALSE}
# load packages ####
# if you do not have these packages - install.packages('package name')
library(tidyquant)
library(quantmod)
library(dplyr)
library(tidyverse)
library(ggplot2)
library(lubridate)
library(xts)
library(shiny)
```
```{r,echo=FALSE}
inputPanel(
sliderInput("phi","Correlation: ",min=0, max=.9999,value=0.5)
)
```
```{r,echo=FALSE}
x <- reactive({
date <- seq.Date(as.Date("2001/01/01"),as.Date("2013/01/01"),"days")
l <- length(date)
y <-arima.sim(model=list(ar=c(input$phi)),n=l)
d <- data.frame(date=date,y=y)
x <- xts(d[,-1],order.by = d[,1])
})
```
all the results of the fit.
```{r,echo=FALSE}
renderPlot({
plot(x())
})
```
```{r,echo=FALSE}
renderPlot({
pacf(x())
})
```
```{r,echo=FALSE,include=FALSE,eval=FALSE}
date <- seq.Date(as.Date("2001/01/01"),as.Date("2013/01/01"),"days")
l <- length(date)
y <-arima.sim(model=list(ar=c(0.5)),n=l)
d <- data.frame(date=date,y=y)
x <- xts(d[,-1],order.by = d[,1])
```
```{r,echo=FALSE,include=FALSE,eval=FALSE}
plot(x)
```
```{r,echo=FALSE,include=FALSE,eval=FALSE}
pacf(x)
```