R/restrict_sh.R

Defines functions restrict_sh

Documented in restrict_sh

#' Restricted VAR
#'
#' This is a modification of vars::restrict() for the class "varshrinkest".
#' Warning: THIS CODE IS NOT COMPLETE:
#' this function may raise an error because it ignores shrinkage
#' estimation.
#'
#' @param x An object of class "varshrinkest"
#' @param ... Other arguments to vars::restrict()
#' @examples
#' data(Canada, package = "vars")
#' y <- diff(Canada)
#' estim <- VARshrink(y, p = 2, type = "const", method = "ridge")
#' restrict_sh(estim)
#' @seealso \code{\link[vars]{restrict}}
#' @export
restrict_sh <- function(x, ...) {
  if (inherits(x, "varest")) {
    class(x) <- "varest"
  } else {
    stop("\nPlease provide an object inheriting class 'varest'.\n")
  }
  result <- vars::restrict(x, ...)
  return(result)
}

Try the VARshrink package in your browser

Any scripts or data that you put into this service are public.

VARshrink documentation built on Oct. 9, 2019, 5:06 p.m.