-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFORECAST_AR.R
More file actions
70 lines (45 loc) · 1.24 KB
/
Copy pathFORECAST_AR.R
File metadata and controls
70 lines (45 loc) · 1.24 KB
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
#DONE
{
library(corrplot)
library(ggplot2)
library(quantmod)
library(xts)
library(rms)
library(glmulti)
library(leaps)
library(stats)
library(stats4)
library(MASS)
library(scatterplot3d)
library(rgl)
library(RollingWindow)
library(lmtest)
library(randtests)
library(tseries)
library(egcm)
library(urca)
library(forecast)
} # package liberaries
data <- new.env()
tickers <- c("WSAVNS"
)
# import data from FRED database
getSymbols( tickers
, src = "FRED" # needed!
, env = data
, adjust = TRUE
)
RANGE <- '2016-01/2017-02'
data$x0 <- ts(data$WSAVNS[RANGE])
data$x1 <- ((data$x0))
data$x1[1] = data$x1[2]
X3 <- ar(data$x1, aic = TRUE, order.max = NULL, method = "ols")
plot(forecast.ar(X3))
grid(20, 20, lwd = 2) # grid only in y-direction
plot(X3)
plot(data$WSAVNS[RANGE], main = "Total Savings Deposits at all Depository Institutions")
# plot((data$WSAVNS[RANGE]), main = "Total Savings Deposits at all Depository Institutions")
# plot(forecast.ar(ar(data$x0, aic = TRUE, order.max = NULL, method = "mle")))
# ar(data$x0, aic = TRUE, order.max = NULL,
# method = c("yule-walker", "burg", "ols", "mle", "yw"),
# na.action, series)