Learn R Programming

sp500SlidingWindow (version 0.1.0)

CAGR: Compound Annual Growth Rate

Description

  • geometric FV = PV * (1 + geometric) ** years
  • continuous FV = PV * exp(continuous * years)

Usage

CAGR(PV, FV, fractional_years, type = "geometric")

Arguments

PV
the price at the beginning of the period
FV
the price at the end of the period
fractional_years
the length of the period in (fractional) years
type
either "geometric" or "continuous"

Value

the compounded rate of return, annualized

Examples

Run this code
PV    <- 9000
FV    <- 13000
years <- 3
(geometric  <- CAGR(9000, 13000, years, type="geometric"))
(continuous <- CAGR(9000, 13000, years, type="continuous"))
9000 * (1 + geometric) ** years
9000 * exp(continuous * years)

## Not run: 
# error <- CAGR(9000, 13000, years, type="error")## End(Not run)

Run the code above in your browser using DataLab