R/alpha.R

Defines functions alpha

Documented in alpha

#' @title Set new alpha of a portfolio.model
#' 
#' @description
#' \code{alpha} sets a new alpha for VaR and Expected Shortfall
#'
#' @param model the portfolio.model to be changed
#' @param alpha the value alpha (between 0 and 1)
#' 
#' @return the adapted portfolio.model
#' 
#' @author Ronald Hochreiter, \email{ronald@@algorithmic.finance}
#'
#' @export
#' 
#' @examples
#' data(sp100w17av30s)
#' model <- optimal.portfolio(scenario.set)
#' cvar95 <- optimal.portfolio(objective(model, "expected.shortfall"))
#' cvar90 <- optimal.portfolio(alpha(cvar95, 0.1))
#'
alpha <- function(model, alpha) {
  # check alpha
  if ((alpha < 0) | (alpha > 1)) { 
    warning("Invalid alpha chosen, switching back to 95%")
    alpha <- 0.05 
  }
  
  # set alpha and return model
  model$alpha <- alpha
  return(model)
}

Try the portfolio.optimization package in your browser

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

portfolio.optimization documentation built on May 2, 2019, 8:16 a.m.