R/SingleUnitRoot.R

Defines functions piar1unit

Documented in piar1unit

#' @title Function to compute the coefficients of periodic integrated filter
#' @description  Function to compute the coefficients of periodic integrated filter.
#'               Assume there is a single unit root in the process.
#' @param Xsim similarity matrix for Jordan decomposition of the multi-companion matrix F
#' @param d period
#' @param eigval eigen value of F
#'
#' @return coefficients of $(1-\alpha_{s}L)$
#' @export
#' @examples
#' library(mcompanion)
#' Fd <- sim_mc(dim = 4, mo = 4, mo.col = 1, eigval = c(1), len.block = c(1))
#' icoef <- piar1unit(Xsim = Fd$eigvec, d = 4, eigval = 1)
piar1unit <- function(Xsim, d, eigval = c(1, -1)) {
  vecX1 <- Xsim[, 1]
  # (1-\alphasL)
  alpha <- c()
  for (i in 1:(d - 1)) {
    vecX1[i + d] <- vecX1[i]
    alpha[i] <- vecX1[d - i + 1]/vecX1[d - i + 2]
  }
  alpha[d] <- eigval * (vecX1[1]/vecX1[2])
  return(par = list(alpha = alpha))
  # check
  if (prod(alpha) != 1)
    stop("restriction fails")
}
YueyunZhu/UnitRootsofPIAR documentation built on Feb. 13, 2020, 12:32 a.m.