You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:如何通过tabuSearch确定LPPL模型初始值以拟合KLSE指数

解决LPPL模型拟合KLSE指数的初始值问题

Hey there, I’ve wrestled with LPPL fitting for financial indices before, so I get exactly why those bad initial values are giving you garbage NLS results. Let’s walk through how to fix this—starting with the tabu search method the literature recommends, plus some practical hacks to get solid initial parameters.

1. 实现Tabu Search获取初始参数(文献推荐方案)

Tabu search works well here because it avoids getting stuck in local minima while searching the non-linear parameter space. Here’s how to implement it in R, using the tabuSearch package alongside your time series tools:

First, define the LPPL model and a residual function that penalizes invalid parameter ranges (super important—LPPL has strict parameter constraints from financial theory):

library(tseries)
library(tabuSearch)

# Assume your KLSE data is stored as a time series object named klse_ts
klse_log <- log(klse_ts)
n <- length(klse_log)
t <- 1:n  # Time index (1 to number of observations)

# LPPL residual function: minimizes sum of squared errors, with parameter constraints
lppl_rss <- function(params) {
  A <- params[1]
  B <- params[2]
  m <- params[3]
  C <- params[4]
  omega <- params[5]
  phi <- params[6]
  Tc <- params[7]
  
  # Enforce critical constraints from LPPL theory
  if (Tc <= max(t)) return(1e10)  # Tc must be a future time point
  if (m <= 0 || m >= 1) return(1e10)  # m ∈ (0,1)
  if (omega < 6 || omega > 15) return(1e10)  # ω typically 6-15 for financial bubbles
  if (B >= 0) return(1e10)  # B is negative in bubble regimes
  
  # Calculate LPPL predicted values
  time_to_crash <- Tc - t
  term1 <- B * time_to_crash^m
  term2 <- C * time_to_crash^m * cos(omega * log(time_to_crash) + phi)
  predicted <- A + term1 + term2
  
  # Return sum of squared residuals
  sum((klse_log - predicted)^2)
}

# Define parameter search ranges (adjust based on your data's scale)
param_bounds <- list(
  A = c(min(klse_log), max(klse_log)),
  B = c(-1, -0.01),  # Negative range for bubble regimes
  m = c(0.2, 0.8),
  C = c(-0.5, 0.5),
  omega = c(7, 13),
  phi = c(-pi, pi),
  Tc = c(max(t) + 5, max(t) + 40)  # Assume crash within next 5-40 trading days
)

# Run Tabu Search
tabu_output <- tabuSearch(
  size = 7,  # Number of parameters
  iters = 150,  # Number of iterations
  objFunc = lppl_rss,
  ranges = param_bounds,
  listSize = 6,  # Tabu list size (prevents revisiting recent solutions)
  nRestarts = 4  # Restart multiple times to avoid local minima
)

# Extract the best initial parameters from tabu search
init_params <- tabu_output$bestSol
names(init_params) <- c("A", "B", "m", "C", "omega", "phi", "Tc")

2. 手动初始化技巧(如果Tabu Search太耗时)

If tabu search is taking too long for your dataset, you can use domain knowledge to bootstrap initial parameters step-by-step:

  • Fix m and ω first: Use literature defaults—start with m = 0.5 and omega = 10 (common values for equity bubbles).
  • Estimate A and B: Fit a linear regression to log(P_t) = A + B*(Tc - t)^m (pick a reasonable Tc, e.g., max(t)+15) to get initial A and B.
  • Estimate C and φ: Treat (Tc - t)^m * cos(omega*log(Tc - t)) and (Tc - t)^m * sin(omega*log(Tc - t)) as predictors, then run a linear regression on log(P_t) - A - B*(Tc - t)^m. Calculate C as the magnitude of the coefficients, φ as the arctangent of the sine/cosine coefficient ratio.

3. Fit LPPL with NLS using the Initial Parameters

Once you have solid initial values, plug them into nls()—you’ll see way better convergence and statistical significance:

# Define the LPPL formula for NLS
lppl_formula <- log(P) ~ A + B*(Tc - t)^m + C*(Tc - t)^m * cos(omega*log(Tc - t) + phi)

# Fit the model
lppl_fit <- nls(
  formula = lppl_formula,
  data = data.frame(P = klse_ts, t = t),
  start = init_params,
  control = nls.control(maxiter = 1000, tol = 1e-7)
)

# Check the results
summary(lppl_fit)

Key Notes to Avoid Issues

  • Stick to parameter constraints: Ignoring LPPL’s theoretical bounds (like B being negative) will lead to meaningless fits.
  • Restart tabu search multiple times: Tabu can get stuck in local minima—running it 3-4 times and taking the best result improves reliability.
  • Adjust search ranges: If your fit is still bad, tweak the bounds for Tc (maybe the crash is further out) or omega (some markets have slightly different frequency ranges).

内容的提问来源于stack exchange,提问作者user3610659

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 03:41:59