可以,但不能直接套用 i.i.d 自助法。
时间序列存在自相关和依赖结构,简单重抽样会破坏时序关系。正确做法是用专门的时间序列自助法(Time-series Bootstrap)。下面给出 4 种常用方案、适用场景、Stata/Python 命令模板以及实现要点。
---
✅ 1 残差自助(Residual Bootstrap)
思路:先拟合模型(AR/ARIMA/回归),再对残差做 i.i.d 重抽样,把新残差加回拟合值,生成新序列。
适用:AR(p)、ARIMA、线性回归模型。
Stata
```stata
1. 拟合 AR(1)
arima y, ar(1)
predict e, residuals
predict yhat, xb
2. 残差自助 B=999 次
bootstrap _b, reps(999) seed(123) saving(ar1_boot, replace): ///
arima y, ar(1)
```
Python
```python
from statsmodels.tsa.arima.model import ARIMA
import numpy as np
model = ARIMA(y, order=(1,0,0)).fit()
e = model.resid
y_hat = model.fittedvalues
B = 999
y_star = np.empty((len(y), B))
for b in range(B):
e_star = np.random.choice(e, size=len(e), replace=True)
y_star[:,b] = y_hat + e_star
```
---
✅ 2 区块自助(Block Bootstrap)
思路:把序列切成连续块,随机重抽块后拼接,保留局部依赖结构。
变体:
- 移动块(Moving Block)
- 环形块(Circular Block)
- 平稳块(Stationary Block,块长随机几何分布)
Stata(需安装 `tsbootstrap` 用户包)
```stata
net install tsbootstrap, from("https://raw.githubusercontent.com/sergiocorreia/stata-tsbootstrap/master/")
tsbootstrap y, block(l(8)) reps(999) seed(123) clear
```
Python
```python
from arch.bootstrap import MovingBlockBootstrap, CircularBlockBootstrap, StationaryBootstrap
bs = StationaryBootstrap(8, y) # 期望块长=8
for data in bs.bootstrap(999):
y_star = data[0][0]
```
---
✅ 3 筛法自助(Sieve Bootstrap)
思路:用高阶 AR(∞) 近似任意线性过程,对其残差重抽样。
适用:未知或非线性依赖结构,但仍以线性 AR 为骨架。
Stata(无官方命令,可自编):
```stata
用高阶 AR 近似
varsoc y, maxlag(12)
local p = r(p)
reg y L(1/`p').y
predict e, residuals
重抽样同方案1
```
---
✅ 4 频域自助(Frequency-Domain Bootstrap)
思路:对傅里叶系数重抽样,再逆变换回时域,避免选块长度难题。
适用:长记忆、周期序列。
Python(简略示例)
```python
import numpy.fft as fft
D = fft.fft(y)
idx = np.random.choice(len(D), len(D), replace=True)
D_star = D[idx]
y_star = fft.ifft(D_star).real
```
---
⚠️ 注意事项
| 问题 | 解决方案 |
|---|---|
| 非平稳序列 | 先差分或去趋势,再自助 |
| 异方差 | 残差自助改用 Wild Bootstrap(乘以 ±1 随机权重) |
| 最优块长 | 经验公式 `b ≈ n^(1/3)`,或数据驱动选择(如 `bw.crit` 函数) |


雷达卡


京公网安备 11010802022788号







