Learn R Programming

umx (version 4.9.0)

fin_interest: Compute the value of a principal & annual deposits at a compound interest over a number of years

Description

Allows you to determine the final value of an initial principal (with optional periodic deposits), over a number of years (yrs) at a given rate of interest. Principal and deposits are optional. You control compounding periods each year (n) and whether deposits occur at the beginning or end of the year. The function outputs a nice table of annual returns, formats the total using a user-settable currency symbol. Can also report using a web table.

Usage

fin_interest(
  principal = 0,
  deposits = 0,
  dinflate = 0,
  interest = 0.05,
  yrs = 10,
  final = NULL,
  n = 12,
  when = "beginning",
  symbol = "$",
  largest_with_cents = 0,
  baseYear = as.numeric(format(Sys.time(), "%Y")),
  table = TRUE,
  report = c("markdown", "html")
)

Arguments

principal

The initial investment at time 0.

deposits

Optional periodic additional investment each year.

dinflate

How much to inflate deposits over time (default = 0)

interest

Annual interest rate (default = .05)

yrs

Duration of the investment (default = 10).

final

if set (default = NULL), returns the rate that turns principal into final after yrs

n

Compounding intervals per year (default = 12 (monthly), 365 for daily)

when

Deposits made at the "beginning" (of each year) or "end"

symbol

Currency symbol to embed in the result.

largest_with_cents

Default = 0

baseYear

Default = 0, can set, e.g. to 2020 for printing

table

Whether to print a table of annual returns (default TRUE)

report

"markdown" or "html",

Value

  • Value of balance after yrs of investment.

References

See Also

Other Miscellaneous Functions: deg2rad(), fin_percent(), fin_valuation(), loadings.MxModel(), rad2deg(), umxBrownie()

Examples

Run this code
# NOT RUN {
# 1. Value of a principal after yrs years at 5% return, compounding monthly.
# Report in browser as a nice table of annual returns and formatted totals.
fin_interest(principal = 5000, interest = 0.05, rep= "html")
# }
# NOT RUN {
# Report as a nice markdown table
fin_interest(principal = 5000, interest = 0.05, yrs = 10)


# 2 What rate is needed to increase principal to final value in yrs time?
fin_interest(final = 1.4, yrs=5)
fin_interest(principal = 50, final=200, yrs = 5)

# 3. What's the value of deposits of $100/yr after 10 years at 7% return?
fin_interest(deposits = 100, interest = 0.07, yrs = 10, n = 12)

# 4. What's the value of <U+00A3>20k + <U+00A3>100/yr over 10 years at 7% return?
fin_interest(principal= 20e3, deposits= 100, interest= .07, yrs= 10, symbol="<U+00A3>")

# 5. What is $10,000 invested at the end of each year for 5 years at 6%?
fin_interest(deposits = 10e3, interest = 0.06, yrs = 5, n=1, when= "end")

# 6. What will <U+00A3>20k be worth after 10 years at 15% annually (n=1)?
fin_interest(deposits=20e3, interest = 0.15, yrs = 10, n=1, baseYear=1)
# $466,986

# manual equivalent
sum(20e3*(1.15^(10:1))) # 466985.5

# 7. Annual (rather than monthly) compounding (n=1)
fin_interest(deposits = 100, interest = 0.07, yrs = 10, n=1)

# 8 Interest needed to increase principal to final value in yrs time.
fin_interest(principal = 100, final=200, yrs = 5)

# }

Run the code above in your browser using DataLab