Saturday, March 5, 2016

yield curve - Using the termstrc package in R


I am attempting to use the function estim_nss from the termstrc package in R to find the spot curve from constant maturity rates published by the Fed. I am using this package because I will need to deal with variable rate coupon bonds in the future. The function requires an object of class "couponbonds" but I cannot figure out how to create this class. I tried creating a list object with similar data but the function rejects this object with the following message:


Error in UseMethod("estim_nss") : no applicable method for 'estim_nss' applied to an object of class "list"


Any assistance would be appreciated.



Answer



It turned out to be more simple than I thought. First, be sure to replace "STARTDATE" with "ISSUEDATE" when building the list. Once the list is build simply reclassify it using the following command:




class(mybonds)="couponbonds"



That's it!


No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...