r - Can't get discount.rate function to calculate rate of return -
i'm trying use discount.rate function in package fincal calculate rate of return , doesn't seem work me.
discount.rate(n=360,pv=-100000,fv=0,pmt=500,type=0) n=360 means there 360 payments (in other words, 30 year loan)
pv= present value (meaning bank gives borrower $100,000 purchase home)
pmt = monthly payment
fv = future value (set 0 because bank gives $100,000 after 30 years receives nothing except monthly mortgage payments)
type = 0 means payments made @ end of each period
i following error:
*error in uniroot(function(r) fv.simple(r, n, pv) + fv.annuity(r, n, pmt, : f.upper = f(upper) na* i used same values in similar finance function in sas , worked fine. help.
per suggestion of 1 user, tried in excel , worked fine also. works fine in sas , excel not in r.
the fincal package not allow specify compounding/discounting frequency (12 per year in case) argument discount.rate() function , seems causing issue. if convert pmt per year (6,000 = 12*500) , set n=30 function gives 4.31%, stated annual rate:
discount.rate(n=30, pv= -100000, fv=0, pmt=6000, type=0) you use ear(r, m) function same package m=12 , r=0.04306572 effective annual rate (ear) of 4.39% :
ear(0.04306572,12) hope helps.
Comments
Post a Comment