cagr - Compond Annual Growth Rate

Prev Next

Function Names

cagr

Description

Calculates the compound annual growth rate (CAGR). The traditional appraoch is to calculate the growth by considering the first value and the last value, taking the ratio of them and annualizing them. Formula: (xn / n1) ^ (1 / number of years).

Since the standard appraoch ignores some intermediate values (for example last year was lousy, but previous years were successful and should be merited), the CAGR can also be calculated using the average of the first n and last n values.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1-3

Parameters

No.TypeDescription
1
input
parameter set input values

Set of numerals (blank strings are allowed and recognized as zero) to be used to calculate the CAGR

Opt. 2
input
numeral Grouping

Use the average of the first n and the last n values for the CAGR. This feature eliminates the limited focus on just the first and last value. If the parameter set contains fewer values, then the grouping figure will be reduced anyway. Example: Grouping of 3 for parameter with 5 elements would overlap in the middle, therefore it will be reduced to 2 in order to compare first two and last two figures.

Default value: 1
Opt. 3
input
string time base

Accepts following three values: year, semesters, quarters, and months in order to identify wheter the values provided are on an annual, quarterly or monthly base. If quarter or month are chosen, then the compound avarage growth rate will be automatically adjusted to years.

Default value: years

Return value

TypeDescription
numeral CAGR result

0 if parameter set provided contains 0 or 1 parameter only.

Exceptions

Growth figure from zero yields mathematics error.

Examples

      echo( cagr( { 1, 3, 2, 3, 4, 6, 8, 3 } ) );  // ca 17%. Ignores values in the middle
      echo( cagr( { 1, 3, 2, 3, 4, 6, 8, 3 }, 3 ) );  // ca 23%, looks better now
      echo( cagr( { 1, 1.2, 1.1, 1.2, 1.3 }, 1, quarters ) );  // 30% growth in 1 year

Output

0.1699308128
0.2315712276
0.3
Try it yourself: Open LIB_Function_cagr.b4p in B4P_Examples.zip. Decompress before use.

See also

average