#' @title Periodically differenced data when there are two simple unit roots in original data
#' @description Periodically differenced data when there are two simple unit roots in original data
#' @param pcts the original time series (assumed there are two simple unit roots)
#' @param parameters the parameters of second order differencing filter \eqn{(1-\alpha_{1s}L-\alpha_{2s}L^2)}
#' @param d period
#' @details The function provides the (periodic) stationary data. The original data is with
#' two simple unit roots, and after imposing the filter \eqn{(1-\alpha_{1s}L-\alpha_{2s}L^2)}, the perioically differenced
#' data can be derived.
#' @return Periodically differenced data
#' @export
#' @examples
#' library(pcts)
#' library(mcompanion)
#' set.seed(123)
#' F <- sim_mc(dim = 4, mo = 4, mo.col = 2, eigval = c(1,1), len.block = c(1,1))
#' phi <- new("MultiFilter", mc = mCompanion(F$mat, mo = 4, mo.col = 2))
#' pc.sim <- sim_pc(model = list(phi = phi[], p = 2, period = 4), n = 500)
#' #coefficients of second order filter
#' icoef <- piar2unit.simple(Xsim = F$eigvec, d = 4, eigval = c(1,1))
#' pcdiff.pc.sim <- pcdiff.piar2unit.simple(pcts = pc.sim, parameters = icoef, d=4)
pcdiff.piar2unit.simple <- function(pcts, parameters, d) {
YT <- matrix(c(pcts), nrow = d)
YTmin1 <- cbind(rep(0, d), YT[, 1:(ncol(YT) - 1)])
Theta0 <- matrix(0, nrow = d, ncol = d)
diag(Theta0) <- c(rep(1, d))
for (i in 2:d) {
Theta0[i, i - 1] <- -parameters$alpha1[i]
Theta0[i, i - 2] <- -parameters$alpha2[i]
}
Theta1 <- matrix(0, nrow = d, ncol = d)
Theta1[1, d - 1] <- parameters$alpha2[1]
Theta1[1, d] <- parameters$alpha1[1]
Theta1[2, d] <- parameters$alpha2[2]
pcdiff <- Theta0 %*% YT - Theta1 %*% YTmin1
return(pcdiff)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.