[R] R help
R. Michael Weylandt
michael.weylandt at gmail.com
Wed Nov 30 20:42:02 CET 2011
Just throwing this out there: there's no probability distribution in
the equation you gave, so there's no context for an MLE: what is the
likelihood for m?
Knowing a little bit about the NS model, it seems like it makes more
sense to use nls() to fit all four parameters to the data at once.
Something like this:
nls(y ~ a + b*(1-exp(-m/tau))/(m/tau)+c*((1-exp(-m/tau))/(m/tau)-exp(-m/tau)),
data = data.frame(y = y, tau = tau), start = list(a = 1, b = 1, c
= 1, m = 1))
Note that as presented, this doesn't work, but it's hopefully a good
start (I'm not very good with nls).
However, the smartest thing to do is to do your homework before
jumping into a project:
library(YieldCurve)
Nelson.Siegel(y, tau, c(48, 60, 84))
Michael
On Tue, Nov 29, 2011 at 1:13 PM, Heh Ness <imostfu at yahoo.com> wrote:
> I have a model like this (Nelson and Siegel 1987)
>
> <img src="http://r.789695.n4.nabble.com/file/n4120161/31f188c684764cd431619dbb59fed5ae.png" border="0"/>
>
> where tau and y are the maturities and yields, respectively, given to me in my data file..
>
> y<-c(4.863,5.662,6.41,6.864,7.153,7.352,7.409,7.474,7.503,7.644,7.676,7.701,7.674,7.668,7.665,7.741,7.743,7.742)
> tau<-c(1,3,6,9,12,15,18,21,24,30,36,48,60,72,84,96,108,120)
>
> I firstly need to find the MLE of m which maximises the likelihood function and then I can easily find the b1, b2 and b3 constants using this m value via least squares estimation..
>
> But does anybody know how I can go abouts finding the MLE of m and if you could help with providing r code for it, I would appreciate that a lot. I have been pulling my hair out for the past week now trying to do it :)
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
More information about the R-help
mailing list