I have the MATLAB code pasted below that calculates yields to maturity. IRR = zeros(length(c),length(M))
The ith row and jth column is the price of the bond with coupon c(i) and maturity M(j). for i = 1:3 for j = 1:3 if j == 1 IRR(i,j) = bndyield(mPricecon(i,j),c_org(i),'07-Apr-2016','07-Apr-2026'); elseif j == 2 IRR(i,j) = bndyield(mPricecon(i,j),c_org(i),'07-Apr-2016','07-Apr-2036'); elseif j == 3 IRR(i,j) = bndyield(mPricecon(i,j),c_org(i),'07-Apr-2016','07-Apr-2046'); end end end; mPricecon represents the prices calculated from zero coupon bond prices, and c_org represents the coupon payments. This then gives IRR. I need to convert this MATLAB code to R code, and ideally one to one. The problem is that bndyield is a MATLAB function and there does not seem be an exact equivalent in R. What is the best way to go? ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.