Computes present value, future value, payments and years for annuity and annuity due.

Annuity

Format

An R6 class.

Arguments

payment

Annuity payment.

rate

Interest/discount rate.

years

Number of years/annuity payments.

pv

Present value of cash flow.

fv

Future value of cash flow.

Details

$new() will instantiate an object of class Annuity.

set_payment() will set the value for payment.

set_rate() will set the value for rate.

set_years() will set the value for years.

set_pv() will set the value for present value.

set_fv() will set the value for future value.

compute_pv() computes present value of an annuity.

compute_pv_due() computes present value of an annuity due.

compute_fv() computes future value of an annuity.

compute_fv_due() computes future value of an annuity due.

compute_years() computes years.

compute_payment() computes payments.

Examples

myAnnuity <- Annuity$new() # set values myAnnuity$set_payment(1000) myAnnuity$set_rate(8) myAnnuity$set_years(5) # compute present value of annuity and annuity due myAnnuity$compute_pv()
#> [1] 3992.71
myAnnuity$compute_pv_due()
#> [1] 4312.127
# compute future value of annuity and annuity due myAnnuity$compute_fv()
#> [1] 5866.601
myAnnuity$compute_fv_due()
#> [1] 6335.929
# compute payment myAnnuity <- Annuity$new() myAnnuity$set_rate(7.35) myAnnuity$set_years(5) # compute payment given present value myAnnuity$set_pv(546.15) myAnnuity$compute_payment()
#> [1] 134.4516
# compute payment given future value myAnnuity$set_fv(941.56) myAnnuity$compute_payment(pv = FALSE)
#> [1] 162.5892
# compute years myAnnuity <- Annuity$new() myAnnuity$set_rate(10) myAnnuity$set_payment(120) # compute years given present value myAnnuity$set_pv(454.89) myAnnuity$compute_years()
#> [1] 4.999938
# compute years given future value myAnnuity$set_fv(610.51) myAnnuity$compute_years(pv = FALSE)
#> [1] 4.315248