-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBigVAR.r
More file actions
45 lines (35 loc) · 1022 Bytes
/
BigVAR.r
File metadata and controls
45 lines (35 loc) · 1022 Bytes
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
#install.packages("BigVAR")
library(BigVAR)
library(reshape)
library(ggplot2)
# Fit a Basic VAR-L(3,4) on simulated data
data(Y)
T1=floor(nrow(Y)/3)
T2=floor(2*nrow(Y)/3)
m1=constructModel(Y,p=4,struct="Basic",gran=c(50,10),verbose=FALSE,T1=T1,T2=T2,IC=FALSE)
plot(m1)
results=cv.BigVAR(m1)
plot(results)
predict(results,n.ahead=1)
SparsityPlot.BigVAR.results(results)
str(results)
results@preds
results@alpha
results@Granularity
results@Structure
results@lagmax
results@Data
plot(results@Data)
########################################
df.melted <- melt(results@Data, id="x")
ggplot(data=df.melted, aes(x=X1, y=value, color=X2)) +
geom_line()
ggplot(data=df.melted, aes(x=X1, y=value, color=X2)) +
geom_line() + facet_grid(X2 ~ .)
df.with.pred <- rbind(results@Data, t(predict(results, n.ahead=1)))
df.melted.with.pred <- melt(df.with.pred, id="x")
ggplot(data=df.melted.with.pred, aes(x=X1, y=value, color=X2)) +
geom_line() + facet_grid(X2 ~ .)
#?cv.BigVAR
#?SparsityPlot.BigVAR.results
#?VarptoVar1MC