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

将ARMA(1,2)拟合至平稳股票对数收益率时的非平稳系数报错问题

Why Can't Some ARMA(p,q) Models Be Fitted to My Stationary Time Series?

Great question—let's unpack why you're running into issues with ARMA(1,2) even though your log returns are clearly stationary (ADF p-value ~e-14) and almost white noise. I've dealt with this exact scenario before, so here's what's going on:

1. The Initial Estimation Roadblock

That error "The computed initial AR coefficients are not stationary" boils down to statsmodels' starting guess for the AR parameters. Even if your data could theoretically support an ARMA(1,2) model, the first pass at estimating coefficients might land on values that violate stationarity (i.e., the AR characteristic equation has roots inside the unit circle). The fitting process can't recover from that, so it bails out.

2. Why Some Models Work, Others Don't

  • ARMA(1,1)/ARMA(2,1) success: For these combinations, the optimizer's initial guesses (or the path it takes during optimization) quickly locks onto valid, stationary AR coefficients and invertible MA coefficients. No hiccups here.
  • ARMA(1,2) failure & Hessian warnings: Your near-white noise data is the main culprit here:
    • Flat loss function: When most coefficients are close to zero (as in white noise), the likelihood function becomes really flat. The optimizer can wander into regions where parameters are non-stationary/non-invertible, or get stuck entirely.
    • Over-specified models: Adding an extra MA term (q=2) creates a model that's more complex than your data needs. Over-specified models often have non-unique parameter solutions—multiple sets of coefficients produce almost the same fit. This confuses the optimizer, leading to non-invertible Hessian matrices (hence the nan values) or outright failure.

3. Practical Fixes & Next Steps

Let's get you back on track with actionable steps:

  • Start with the simplest model first: Since your data is nearly white noise, an ARMA(0,0) (pure white noise) model is probably the best fit here. Test this by checking if the mean of your log returns is statistically different from zero—if not, white noise is your answer.
  • Guide the optimizer with custom initial params: You can manually set starting values for AR/MA coefficients to small, valid numbers (stationary AR, invertible MA) using the start_params argument. This helps the optimizer avoid bad initial regions:
    # Try this for ARMA(1,2)
    model = smt.ARMA(log_returns, (1,2))
    # Start with small AR coefficient and tiny MA terms
    model_fit = model.fit(start_params=[0.05, 0.02, 0.02])
    
  • Switch optimization methods: The default MLE method can struggle with flat loss functions. Try the Nelder-Mead method (method='nm'), which is more robust for these cases:
    model_fit = model.fit(method='nm')
    
  • Validate with ACF/PACF: Confirm your near-white noise claim by plotting autocorrelations—if no lags are significant, complex ARMA models are unnecessary:
    import matplotlib.pyplot as plt
    smt.graphics.plot_acf(log_returns, lags=20)
    smt.graphics.plot_pacf(log_returns, lags=20)
    plt.show()
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 07:10:17