1
$\begingroup$

I have the following data:

mat <- c(88.96438,21.20548,53.06301,76.89863,112.99726,83.96712,119.80274,53.06301 ,112.99726,53.06301)
ytm <- c(0.09380442,0.07378878,0.08823629,0.09428388,0.10381418,0.09652231 ,0.10485382,0.08865775,0.10345890,0.09040975)

Where $mat$ are bond maturities (in months, as the function requires) and $ytm$ are the corresponding yields (in years).

I get however the following error when performing the estimation:

Nelson.Siegel(rate=ytm, maturity = mat)
Error in seq.default(maturity[1], maturity[pillars.number], by = 0.5) : 
  wrong sign in 'by' argument

Can anyone please tell me why?

Thanks

$\endgroup$

1 Answer 1

1
$\begingroup$

If you want people to help you, you really should provide a reproducible example. In particular, you should mention where the Nelson.Siegel function comes from. But as a guess, the maturities (mat) very likely have to be sorted in increasing order.

$\endgroup$
2
  • $\begingroup$ Arranging in increasing order did the trick! Thanks! And I think I could not have been more explicit about where the function Nelson.Siegel comes from, please read the tittle. $\endgroup$
    – Nobody
    Feb 11, 2020 at 12:27
  • $\begingroup$ Yes, indeed. But for people (like me) who copy/paste code into R sessions, adding a call to require/librarywould have helped ;-) Anyway, I am glad it worked. $\endgroup$ Feb 11, 2020 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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