Using rgenoud to fit LPPL model

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Open this post in threaded view
Report Content as Inappropriate

Using rgenoud to fit LPPL model

apologies if this appears too simplistic/poorly worded a question, this
is my first time coding in R

I am attempting to fit the LPPL model to a price series in order to test
for its predictive power for financial crashes. As I understand the
difficulty in fitting the model is due to the number of variables
leading to multiple local minima. So far I have attempted to fit the
model using the nls.lm function, my code is below:

mydata<-fread("data.csv", sep="," , header=TRUE)

f <- function(pars, xx)
    with(pars,(a + b*(tc - xx)^m * (1 + c * cos(omega*log(tc - xx) +

resids <- function(p, observed, xx) {mydata$Logp - f(p,xx)}

nls.out <- nls.lm(par=list(a=1,b=-1,tc=100, m=0.5, omega=1, phi=1, c=1
               fn = resids, observed = mydata$Logp, xx = mydata$day,
               control=nls.lm.control(maxiter=10000, ftol=1e-6,

However the fit for this model is still poor and irrespective of how I
alter the starting parameters it fails to predict a crash occurring one
day later with any degree of accuracy. This is troublesome as the data I
have fitted the model to has been successfully modelled using the LPPL
model in numerous papers.

 From what I have read online I believe using the rgenoud package is a
more powerful global optimiser tool. However I am not able to generate
the correct code to run the package successfully. Any help in doing so
would be greatly appreciated.

[hidden email] mailing list
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.