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.

  • 2
    $\begingroup$ You might want to try the YieldCurve package. I found it easier to use. $\endgroup$ Commented Dec 20, 2012 at 14:09
  • $\begingroup$ Thanks, Josh. My understanding is that the YieldCurve package doesn't handle variable coupon bonds which will eventually limit my data set. $\endgroup$ Commented Dec 21, 2012 at 14:57

2 Answers 2


You can create the data using the procedure described in the reference manual on pages 31 and 32. The necessary code is copied below:

# The following code may be used to generate an empty data set,
# which can then be filled with bond data:
ISIN <- vector()
MATURITYDATE <- vector()
STARTDATE <- vector()
COUPONRATE <- vector()
PRICE <- vector()
ACCRUED <- vector()
CFISIN <- vector()
CF <- vector()
DATE <- vector()
names(CASHFLOWS) <- c("ISIN","CF","DATE")
TODAY <- vector()

names(mycountry1) <- c("ISIN","MATURITYDATE","STARTDATE","COUPONRATE",
names(mycountry2) <- c("ISIN","MATURITYDATE","STARTDATE","COUPONRATE",
mybonds <- list(mycountry1,mycountry2)
names(mybonds) <- c("mycountry1","mycountry2")

Finally set the class of the object just created:

  • 1
    $\begingroup$ Thanks! After an hour or two of skimming through 80 pages, I would never have found that tidbit without any reference to the couponbonds class. $\endgroup$ Commented Dec 20, 2012 at 13:33
  • $\begingroup$ I spent the day replicating this format and it does not solve the original problem. Producing an object with the exact same structure as the "couponbonds" class is still a list that is rejected by the est_nss function. $\endgroup$ Commented Dec 21, 2012 at 20:22

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:


That's it!

  • $\begingroup$ So the docs are wrong? $\endgroup$
    – Bob Jansen
    Commented Dec 22, 2012 at 17:34
  • $\begingroup$ They appear to be. $\endgroup$ Commented Dec 30, 2012 at 20:12
  • $\begingroup$ I've mailed the package maintainer and added that last line to my answer. $\endgroup$
    – Bob Jansen
    Commented Jan 1, 2013 at 14:43
  • $\begingroup$ The author mailed me that this change will be considered for the next revision of the package. $\endgroup$
    – Bob Jansen
    Commented Jan 3, 2013 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.