R/discount.rate.vector.R

Defines functions disc

Documented in disc

#' Vectorize the Discount Rate
#'
#' @name discount.rate.vector
#'
#' @aliases disc
#'
#' @param interest.rate A number that represents the nominal Interest Rate,
#' presented by year.
#'
#' @param number.of.periods Times that interest rate should be applied.
#'
#' @param begin.of.period A boolean that represents if the Tax Rate will be
#' applied at the begining of period. FALSE by default, represents that Tax Rate will be
#' applied at second period .
#'
#' @description Generate a vector with discount rate to be applied to each of
#' the time periods.
#'
#' @return vector with discount rates
#'
#' @export
#'
#' @keywords discount rate, interest rate
#'
#' @family financial
#'
#' @examples
#'
#' ex.disc.vector <- discount.rate.vector(0.0619, 12)
#'
discount.rate.vector <- disc <-
function(interest.rate, number.of.periods, begin.of.period=FALSE) {
  tax.rate <- 1/(1+interest.rate)
  time.instance<- if(begin.of.period) {0:(number.of.periods-1)} else {1:number.of.periods}
  return(tax.rate^time.instance)
}
antoanne/ifmFramework documentation built on Aug. 5, 2023, 6:03 p.m.