#' Forecast for covariate matrix: using true generating process (correlated series type 1)
#'
#' @param horizon a number. Forecast horizon.
#' @param sigmax a number. Standard deviation of noise of x.
#' @param p.block a list. Number of covariates x for each block. I think it's useless here.
#' @param A.block a list of 3 matrices. Each contains 3 AR coefficient matrices for the 3 lags.
#' @param Xinput a matrix. The original training X matrix for forecast, DAT$X.for.fcst (10 series)
#' @param nsize a number. Size (nrow(Xinput)).
#'
#' @return a matrix
#'
#' \item{X.trueforecast}{a matrix. Forecast values for each series produced by true method, simple scenario.}
#'
#'
#' @export
#'
#' @examples
#' ##
XTrueCorr <- function(horizon,
sigmax,
p.block,
A.block,
Xinput,
nsize){
initialX <- matrix(rep(0, (horizon + 3)*10), (horizon+3), 10) # 7+3 rows, 10 col
initialX[1:3, ] <- Xinput[((nsize-2):nsize), ]
for (m in 1:horizon){
# ----------- no intervention
x.last <- list(x1 = initialX[(m+2), ],
x2 = initialX[(m+1), ],
x3 = initialX[m, ])
# need to separate the 3
x1.last <- list(x1 = x.last$x1[1:3],
x2 = x.last$x2[1:3],
x3 = x.last$x3[1:3])
tempX1 <- A.block$block1$A1 %*% x1.last$x1 + A.block$block1$A2 %*% x1.last$x2 + A.block$block1$A3 %*% x1.last$x3 + sigmax
x2.last <- list(x1 = x.last$x1[4:6],
x2 = x.last$x2[4:6],
x3 = x.last$x3[4:6])
tempX2 <- A.block$block2$A1 %*% x2.last$x1 + A.block$block2$A2 %*% x2.last$x2 + A.block$block2$A3 %*% x2.last$x3 + sigmax
x3.last <- list(x1 = x.last$x1[7:10],
x2 = x.last$x2[7:10],
x3 = x.last$x3[7:10])
tempX3 <- A.block$block3$A1 %*% x3.last$x1 + A.block$block3$A2 %*% x3.last$x2 + A.block$block3$A3 %*% x3.last$x3 + sigmax
# combine the 3
tempX <- c(tempX1, tempX2, tempX3)
initialX[(m+3), ] <- tempX
}
X.trueforecast <- initialX[(4:10), ]
return(X.trueforecast = X.trueforecast)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.