Skip to contents

Description

Computes the future value of an investment using a combined formula for a single lump-sum principal and a series of monthly contributions (Ordinary Annuity). It handles edge cases where the interest rate is zero to prevent calculation errors.The function assumed payments are made at the end of each month (an “ordinary annuity”)

Usage

calc_wealth(principal, monthly, rate, years)

Arguments

  • principal: Numeric. Initial lump-sum investment.
  • monthly: Numeric. Monthly contribution amount made at the end of each month.
  • rate: Numeric. Annual nominal rate of return (as a decimal, e.g., 0.05 for 5%). Must be non-negative.
  • years: Numeric. Total duration of the investment.

Value

A numeric vector representing the account balance at each monthly interval throughout the specified duration.

Example

# Project wealth with $10,000 start, $500 monthly additions at 6% return for 30 years
wealth_trajectory <- calc_wealth(principal = 10000, monthly = 500, rate = 0.06, years = 30)
wealth_trajectory
#>   [1]  10550.00  11102.75  11658.26  12216.56  12777.64  13341.53  13908.23
#>   [8]  14477.77  15050.16  15625.41  16203.54  16784.56  17368.48  17955.32
#>  [15]  18545.10  19137.83  19733.52  20332.18  20933.84  21538.51  22146.21
#>  [22]  22756.94  23370.72  23987.58  24607.51  25230.55  25856.70  26485.99
#>  [29]  27118.42  27754.01  28392.78  29034.74  29679.92  30328.32  30979.96
#>  [36]  31634.86  32293.03  32954.50  33619.27  34287.37  34958.80  35633.60
#>  [43]  36311.76  36993.32  37678.29  38366.68  39058.52  39753.81  40452.58
#>  [50]  41154.84  41860.61  42569.92  43282.77  43999.18  44719.18  45442.77
#>  [57]  46169.99  46900.84  47635.34  48373.52  49115.38  49860.96  50610.27
#>  [64]  51363.32  52120.13  52880.73  53645.14  54413.36  55185.43  55961.36
#>  [71]  56741.16  57524.87  58312.49  59104.06  59899.58  60699.08  61502.57
#>  [78]  62310.08  63121.63  63937.24  64756.93  65580.71  66408.62  67240.66
#>  [85]  68076.86  68917.25  69761.83  70610.64  71463.70  72321.01  73182.62
#>  [92]  74048.53  74918.78  75793.37  76672.34  77555.70  78443.48  79335.69
#>  [99]  80232.37  81133.53  82039.20  82949.40  83864.14  84783.47  85707.38
#> [106]  86635.92  87569.10  88506.94  89449.48  90396.73  91348.71  92305.45
#> [113]  93266.98  94233.32  95204.48  96180.51  97161.41  98147.21  99137.95
#> [120] 100133.64 101134.31 102139.98 103150.68 104166.43 105187.27 106213.20
#> [127] 107244.27 108280.49 109321.89 110368.50 111420.34 112477.45 113539.83
#> [134] 114607.53 115680.57 116758.97 117842.77 118931.98 120026.64 121126.77
#> [141] 122232.41 123343.57 124460.29 125582.59 126710.50 127844.06 128983.28
#> [148] 130128.19 131278.83 132435.23 133597.40 134765.39 135939.22 137118.91
#> [155] 138304.51 139496.03 140693.51 141896.98 143106.46 144322.00 145543.61
#> [162] 146771.32 148005.18 149245.21 150491.43 151743.89 153002.61 154267.62
#> [169] 155538.96 156816.65 158100.74 159391.24 160688.20 161991.64 163301.60
#> [176] 164618.10 165941.20 167270.90 168607.26 169950.29 171300.04 172656.54
#> [183] 174019.83 175389.93 176766.87 178150.71 179541.46 180939.17 182343.87
#> [190] 183755.59 185174.36 186600.24 188033.24 189473.40 190920.77 192375.37
#> [197] 193837.25 195306.44 196782.97 198266.88 199758.22 201257.01 202763.29
#> [204] 204277.11 205798.50 207327.49 208864.13 210408.45 211960.49 213520.29
#> [211] 215087.89 216663.33 218246.65 219837.88 221437.07 223044.26 224659.48
#> [218] 226282.78 227914.19 229553.76 231201.53 232857.54 234521.82 236194.43
#> [225] 237875.41 239564.78 241262.61 242968.92 244683.76 246407.18 248139.22
#> [232] 249879.92 251629.31 253387.46 255154.40 256930.17 258714.82 260508.40
#> [239] 262310.94 264122.49 265943.10 267772.82 269611.68 271459.74 273317.04
#> [246] 275183.63 277059.54 278944.84 280839.57 282743.76 284657.48 286580.77
#> [253] 288513.67 290456.24 292408.52 294370.57 296342.42 298324.13 300315.75
#> [260] 302317.33 304328.92 306350.56 308382.32 310424.23 312476.35 314538.73
#> [267] 316611.42 318694.48 320787.95 322891.89 325006.35 327131.38 329267.04
#> [274] 331413.38 333570.44 335738.30 337916.99 340106.57 342307.10 344518.64
#> [281] 346741.23 348974.94 351219.81 353475.91 355743.29 358022.01 360312.12
#> [288] 362613.68 364926.75 367251.38 369587.64 371935.58 374295.25 376666.73
#> [295] 379050.06 381445.32 383852.54 386271.80 388703.16 391146.68 393602.41
#> [302] 396070.42 398550.78 401043.53 403548.75 406066.49 408596.82 411139.81
#> [309] 413695.51 416263.99 418845.31 421439.53 424046.73 426666.96 429300.30
#> [316] 431946.80 434606.53 437279.57 439965.96 442665.79 445379.12 448106.02
#> [323] 450846.55 453600.78 456368.79 459150.63 461946.38 464756.11 467579.89
#> [330] 470417.79 473269.88 476136.23 479016.91 481912.00 484821.56 487745.67
#> [337] 490684.39 493637.82 496606.01 499589.04 502586.98 505599.92 508627.92
#> [344] 511671.05 514729.41 517803.06 520892.07 523996.53 527116.52 530252.10
#> [351] 533403.36 536570.38 539753.23 542951.99 546166.75 549397.59 552644.57
#> [358] 555907.80 559187.34 562483.27