# NOT RUN {
# }
# NOT RUN {
# GMAR model
params13 <- c(1.4, 0.88, 0.26, 2.46, 0.82, 0.74, 5.0, 0.68, 5.2, 0.72, 0.2)
gmar13 <- GSMAR(p=1, M=3, params=params13, model="GMAR")
sim13 <- simulateGSMAR(gmar13, nsimu=500)
ts.plot(sim13$sample)
ts.plot(sim13$component)
ts.plot(sim13$mixing_weights, col=rainbow(3), lty=2)
# FORECASTING EXAMPLE:
# Restricted GMAR model, 10000 sets of simulations with initial values 6 and 6.2.
params22r <- c(1.4, 1.8, 0.8, -0.1, 0.29, 3.18, 0.84)
gmar22r <- GSMAR(p=2, M=2, params=params22r, model="GMAR",
restricted=TRUE)
sim22r <- simulateGSMAR(gmar22r, nsimu=5, initval=c(6, 6.2), ntimes=10000)
apply(sim22r$sample, 1, median) # Point forecast
apply(sim22r$sample, 1, quantile, probs=c(0.025, 0.975)) # 95% interval
apply(sim22r$mixing_weights, MARGIN=1:2, FUN=median) # mix.weight point forecast
apply(sim22r$mixing_weights, MARGIN=1:2, FUN=quantile,
probs=c(0.025, 0.975)) # mix.weight 95% intervals
# G-StMAR model, with initial values
params12gs <- c(1.38, 0.88, 0.27, 3.8, 0.74, 3.15, 0.8, 3.6)
gstmar12 <- GSMAR(p=1, M=c(1, 1), params=params12gs,
model="G-StMAR")
sim12gs <- simulateGSMAR(gstmar12, nsimu=500, initvalues=5:6)
ts.plot(sim12gs$sample)
ts.plot(sim12gs$component)
ts.plot(sim12gs$mixing_weights, col=rainbow(3), lty=2)
# Mixture version of Heterogenuous Autoregressive (HAR) model (without data)
paramsHAR <- c(1, 0.1, 0.2, 0.3, 1, 1, 0.15, 0.25, 0.35, 1, 0.55)
r1 = c(1, rep(0, 21)); r2 = c(rep(0.2, 5), rep(0, 17)); r3 = rep(1/22, 22)
R0 = cbind(r1, r2, r3)
mixhar <- GSMAR(p=22, M=2, params=paramsHAR, model="GMAR", constraints=list(R0, R0))
simhar <- simulateGSMAR(mixhar, nsimu=1000)
ts.plot(simhar$sample)
ts.plot(simhar$component)
ts.plot(simhar$mixing_weights, col=rainbow(3), lty=2)
# }
Run the code above in your browser using DataLab