# NOT RUN {
# Only one independent series
data(warming)
model.dlm = dlm(x = warming$NoMotorVehicles ,
y = warming$Warming , q = 2 , show.summary = TRUE)
dlmForecast(model = model.dlm , x = c(95 , 98, 101) , h = 3)
# Multiple independent series
data(M1Germany)
data = M1Germany[1:144,]
model.dlm = dlm(formula = logprice ~ interest + logm1,
data = data.frame(data) , q = 4 , show.summary = TRUE)
x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09),
ncol = 2, nrow = 2)
dlmForecast(model = model.dlm , x = x.new , h = 2 ,
interval = FALSE)
dlmForecast(model = model.dlm , x = x.new , h = 2 ,
interval = TRUE, nSim = 100)
# Some lags are removed:
# Remove lag 2 from "interest" and
# lags 1 and 3 from "logm1"
removed = matrix(c(2 , NA , 1 , 3), nrow = 2, ncol = 2 ,
byrow = TRUE)
model.dlm = dlm(formula = logprice ~ interest + logm1 ,
data = data.frame(data) , q = 4 , remove = removed ,
show.summary = TRUE)
x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09),
ncol = 2, nrow = 2)
dlmForecast(model = model.dlm , x = x.new , h = 2 ,
interval = FALSE)
dlmForecast(model = model.dlm , x = x.new , h = 2 ,
interval = TRUE, nSim = 100)
x.new = matrix(c(0.07 , 9.06 , 0.071 , 9.09, 0.08 , 9.12), ncol = 3,
nrow = 2)
dlmForecast(model = model.dlm , x = x.new , h = 3, interval = FALSE)
dlmForecast(model = model.dlm , x = x.new , h = 3, interval = TRUE,
nSim = 100)
# }
Run the code above in your browser using DataLab