Skip to contents

Compute compound interest for a given number of periods, compounding with an indicated frequency per period.

Usage

compoundInterest(interest, periods = 1, frequency = 1, net.value = FALSE)

simple2logReturns(R)

Arguments

interest

rate of interest per period (usually per year).

periods

number of periods over which to compound.

frequency

number of times per period to compound; frequency = Inf to convert simple to log returns.

net.value

if TRUE, return the total value per unit invested; otherwise return net increase = (net value - 1).

R

simple interest to be converted to log(returns).

Details

These functions are vectorized for all arguments. The code uses optionally expm1(x) = exp(x) - 1 and log1p(x) = log(1+x) which can preserve numerical precision for x very close to 0.

Value

vector of the length of the longest argument.

References

Ruey Tsay (2005) Analysis of Financial Time Series, 2nd ed. (Wiley, p. 6)

Examples

# "Net Value" column of Tsay Table 1.1, p. 4
compoundInterest(0.1, frequency = c(1, 2, 4, 12, 52, 365, Inf),
                      net.value = FALSE)
#> [1] 1.100000 1.102500 1.103813 1.104713 1.105065 1.105156 1.105171
# Example 1.1, p. 6
compoundInterest(.0446, freq = Inf)
#> [1] 1.04561
# Inverse of Example 1.1
simple2logReturns(.0456)
#> [1] 0.04459088