[R-SIG-Finance] Using rgenoud to fit LPPL model

K. Upadhyay ku218 at cam.ac.uk
Fri Feb 17 01:50:30 CET 2017


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) + 
phi))))`

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, 
maxfev=1e6))

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.



More information about the R-SIG-Finance mailing list