-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathunif0w.R
67 lines (60 loc) · 2.5 KB
/
unif0w.R
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
# Auto-Arima
umodel <- "AutoArima"
fit <- auto.arima(Yin)
fout <- forecast(fit, h=1, bootstrap=TRUE, npaths=B, level=seq(51,99,1), fan=FALSE)
zout <- c(fout$mean, rev(as.numeric(fout$lower))[1], rev(fout$lower),
fout$mean, fout$upper, as.numeric(fout$upper)[49])
uni0w[as.character(uD[i]), ,umodel] <- zout
# baggedETS
umodel <- "baggedETS"
fit <- baggedETS(Yin)
fout <- forecast(fit, h=1, level=seq(51,99,1), fan=FALSE)
sigmah <- sd(fit$residuals)
spseq <- qnorm(seq(0.51, 0.99, 0.01))*sigmah
fout <- as.numeric(fout$mean)
zout <- c(fout, fout-rev(spseq)[1], fout-rev(spseq), fout,
fout+spseq, fout+spseq[NROW(spseq)])
uni0w[as.character(uD[i]), ,umodel] <- zout
# bats
umodel <- "bats"
fit <- bats(Yin)
fout <- forecast(fit, h=1, bootstrap=TRUE, npaths=B, level=seq(51,99,1), fan=FALSE)
zout <- c(fout$mean, rev(as.numeric(fout$lower))[1], rev(fout$lower),
fout$mean, fout$upper, as.numeric(fout$upper)[49])
uni0w[as.character(uD[i]), ,umodel] <- zout
# ets
umodel <- "ets"
fit <- ets(Yin)
fout <- forecast(fit, h=1, bootstrap=TRUE, npaths=B, level=seq(51,99,1), fan=FALSE)
zout <- c(fout$mean, rev(as.numeric(fout$lower))[1], rev(fout$lower),
fout$mean, fout$upper, as.numeric(fout$upper)[49])
uni0w[as.character(uD[i]), ,umodel] <- zout
# nnetar
umodel <- "nnetar"
fit <- nnetar(Yin)
fout <- forecast(fit, h=1, level=seq(51,99,1), fan=FALSE)
sigmah <- sd(fit$residuals, na.rm=TRUE)
spseq <- qnorm(seq(0.51, 0.99, 0.01))*sigmah
fout <- as.numeric(fout$mean)
zout <- c(fout, fout-rev(spseq)[1], fout-rev(spseq), fout,
fout+spseq, fout+spseq[NROW(spseq)])
uni0w[as.character(uD[i]), ,umodel] <- zout
# spline
umodel <- "spline"
fout <- splinef(Yin, h=1, level=seq(51,99,1), fan=FALSE)
zout <- c(fout$mean, rev(as.numeric(fout$lower))[1], rev(fout$lower),
fout$mean, fout$upper, as.numeric(fout$upper)[49])
uni0w[as.character(uD[i]), ,umodel] <- zout
# tbats
umodel <- "tbats"
fit <- tbats(Yin)
fout <- forecast(fit, h=1, bootstrap=TRUE, npaths=B, level=seq(51,99,1), fan=FALSE)
zout <- c(fout$mean, rev(as.numeric(fout$lower))[1], rev(fout$lower),
fout$mean, fout$upper, as.numeric(fout$upper)[49])
uni0w[as.character(uD[i]), ,umodel] <- zout
# theta
umodel <- "theta"
fout <- thetaf(Yin, h=1, level=seq(51,99,1), fan=FALSE)
zout <- c(fout$mean, rev(as.numeric(fout$lower))[1], rev(fout$lower),
fout$mean, fout$upper, as.numeric(fout$upper)[49])
uni0w[as.character(uD[i]), ,umodel] <- as.numeric(zout)