Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

im trying to predict crash time by using lppl model(JLS). My codes can run, but the error is to high....I try with some other initial values, but still can't reduce the error.....How i can reduce Standard Residual Error???or i need to change my data window????

 library(tseries)
 library(zoo)
 ts <- get.hist.quote(instrument="^KLSE", start="1992-01-01", end="1997-01-01",
                      quote="Close", provider="yahoo", origin="1970-01-01", 
                      compression="d", retclass="zoo")
 df <- data.frame(ts)
 df <- data.frame(Date=as.Date(rownames(df)),Y=df$Close)
     df <- df[!is.na(df$Y),]
 library(minpack.lm)
 df$days <- as.numeric(df$Date-df[1,]$Date)\
f <- function(pars, xx){pars$a+pars$b*(pars$tc-xx)^pars$m*   (1+pars$c*cos(pars$omega*log(pars$tc-xx)+pars$phi))}
 resids <- function(p,observed,xx){df$Y-f(p,xx)}
 nls.out<-nls.lm(par=list(a=300, b=-400, tc=1308, m=0.5, omega=19.5, phi=-30, c=-14), fn=resids, observed=df$Y, xx=df$days, control=nls.lm.control(maxiter=1024, ftol=1e-6, maxfev=1e6))
 par <- nls.out$par
 nls.final<-nls(Y~a+(tc-days)^m*(b+c*cos(omega*log(tc-days)+phi)), data=df, start=par, algorithm="plinear", control=nls.control(maxiter=1024, minFactor=1e-8))
 summary(nls.final)

Formula: Y ~ a + (tc - days)^m * (b + c * cos(omega * log(tc - days) + phi))

  Parameters:
         Estimate Std. Error t value Pr(>|t|)
   a      1.138e+04  1.929e+08   0.000    1.000
   b     -1.071e+04  1.816e+08   0.000    1.000
  tc      1.331e+03  9.911e+02   1.343    0.180
   m      3.032e-03  1.888e+00   0.002    0.999
   omega  2.399e+01  1.985e+03   0.012    0.990
   phi   -5.955e+01  1.298e+04  -0.005    0.996
   c      1.715e-03  2.915e+01   0.000    1.000
   .lin   2.351e+00  3.982e+04   0.000    1.000

    Residual standard error: 75.75 on 752 degrees of freedom

Number of iterations to convergence: 55    
Achieved convergence tolerance: 3.632e-06 
share|improve this question
    
I get an error that the max. number of iterations was exceeded?!? –  vonjd Jul 3 at 10:49
    
yup...exceeded... –  user3610659 Jul 14 at 3:37
    
@vonjd is that selection of time window wrong?? –  user3610659 Jul 14 at 4:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.