跳到内容
当前位置:首页>Excel>Stata学习笔记(二十四)-收益率的标准误与波动率聚集

Stata学习笔记(二十四)-收益率的标准误与波动率聚集

  • 2026-11-23 08:19:39
Stata学习笔记(二十四)-收益率的标准误与波动率聚集

本期我们将结合Stata官方自带的sp500.dta数据集,来聊一聊标准误和波动率聚集。虽然前面我们已经讲过标准误相关的话题(感兴趣的小伙伴可以去看看),

第十五

Zed Liu,公众号:钻石村Stata学习笔记(十五)-二维聚类标准误(Two-way Clustering)

和

第二十一期

123,公众号:钻石村Stata学习笔记(二十一)-多向聚类(Multiway Clustering)

但在时间序列上,这个问题还不太一样。

这个数据集包含了2001 年全年共计248个交易日标普 500 日行情数据。这一年里不仅出现了互联网泡沫破灭、股指连续暴跌的情况,还发生了911这样的极端事件冲击,可以说在平静期和疯狂期都留下了痕迹。

另外,什么是波动率聚集(volatility clustering)呢?感兴趣的小伙伴可以去查阅这篇论文:Robert F. Engle (1982). Autoregressive Conditional Heteroscedasticity with Estimates of the Variance of United Kingdom Inflation[J]. Econometrica, 50(4): 987-1007.

在这篇论文中,Engle 指出:传统模型假设每期预测方差是常数,但现实往往是昨天波动那么大,今天大概也不会平静。他提出让条件方差随过去冲击而变化。Bollerslev (1986) 则进一步将其推广为 GARCH。

Engle, R. F. (1982). Autoregressive Conditional Heteroscedasticity with Estimates of the Variance of United Kingdom Inflation. Econometrica, 50(4): 987-1007.

话不多说,回到我们的主题。

sp500.dta 是 Stata 附带的官方示例数据,可以从本地路径加载 E:/SoftWare/ado/base/s/sp500.dta:

// Initialize	clear allset more offset seed 20250725
	cd "E:/SoftWare"global figures "./"
use "E:/SoftWare/ado/base/s/sp500.dta", cleardescribe
Contains data from E:/SoftWare/ado/base/s/sp500.dta  obs:           248                          S&P 500 vars:             7                          22 Apr 2018 10:52                                              (_dta has notes)------------------------------------------------------------------------------              storage   display    valuevariable name   type    format     label      variable label------------------------------------------------------------------------------date            int     %td                   Dateopen            float   %9.0g                 Opening pricehigh            float   %9.0g                 High pricelow             float   %9.0g                 Low priceclose           float   %9.0g                 Closing pricevolume          double  %12.0gc               Volume (thousands)change          float   %9.0g                 Closing price change------------------------------------------------------------------------------Sorted by: date
summarize
    Variable |        Obs        Mean    Std. Dev.       Min        Max-------------+---------------------------------------------------------        date |        248    15156.85    105.3335      14977      15340        open |        248    1194.884    87.12808      965.8    1373.73        high |        248    1204.044    86.53465     984.54    1383.37         low |        248    1183.334    87.47576     944.75    1364.66       close |        248    1194.179    86.79468      965.8    1373.73-------------+---------------------------------------------------------      volume |        248    12320.68    2585.929       4103    23308.3      change |        247   -.5473282    15.84464  -53.77002   64.29004

通过简单的描述性统计,可以看到, 总共248 个交易日,即2001 年 1 月 2 日到 12 月 31 日。收盘价最低 965.8,最高 1373.73。

收益率的计算

收益率可以通过对数价格差计算,也可以计算简单收益率:

gen int t = _ntsset tgen double ret = 100*(ln(close) - ln(close[_n-1]))label variable ret "对数收益率(%)"gen double sret = 100*(close - close[_n-1])/close[_n-1]label variable sret "简单收益率(%)"

两种算法放一起对比一下:

summarize ret
    Variable |        Obs        Mean    Std. Dev.       Min        Max-------------+---------------------------------------------------------         ret |        247   -.0450691     1.34928  -5.046796   4.888407
summarize sret
    Variable |        Obs        Mean    Std. Dev.       Min        Max-------------+---------------------------------------------------------        sret |        247   -.0359952    1.349251  -4.921561   5.009861
corr ret sret
             |      ret     sret-------------+------------------         ret |   1.0000        sret |   0.9999   1.0000

相关系数 0.9999。通常教材会推荐对数收益率,因为连续复利且可加;简单收益率在极端值上会有截断偏差。但是二者差距很小,选哪个都可以。

不过上面代码中的 gen int t = _n 不是随便写的,这里有个容易出错的地方。

不要使用日期做时间轴

如果图省事直接 tsset date:

preserve    tsset date    tsreport    gen double ret_L = L.ret    count if missing(ret_L)    list date ret ret_L if date >= td(4,9,2001) & date <= td(21,9,2001), noobs    restore
        time variable:  date, 02jan2001 to 31dec2001, but with gaps                delta:  1 day
Time variable:    date---------------------------Starting period = 02jan2001Ending period   = 31dec2001Observations    =       248Number of gaps  =        55

but with gaps:出现55 个缺口。这是由于tsset 认定时间轴应该等间隔,但通常股市周末是不开市的,也就是说,"下一个日历日"未必是"下一个交易日"。

再看 L. 算子的结果。9 月 11 日之后美股休市四天,9 月 10 日直接跳到 9 月 17 日:

  +-------------------------------------+  |      date          ret        ret_L |  |-------------------------------------|  | 04sep2001   -.05647554            . |  | 05sep2001   -.10597094   -.05647554 |  | 06sep2001   -2.2644739   -.10597094 |  | 07sep2001   -1.8812874   -2.2644739 |  | 10sep2001    .62066466            . |  |-------------------------------------|  | 17sep2001   -5.0467957            . |  | 18sep2001   -.58218848   -5.0467957 |  | 19sep2001   -1.6243709   -.58218848 |  | 20sep2001   -3.155252   -1.6243709 |  | 21sep2001   -1.9217744   -3.155252 |  +-------------------------------------+

可以看到10sep2001 和 17sep2001 的 ret_L 都是缺失的。L. 找的是"上一个日历日",但是那天没有交易记录,于是 9 月 10 日就得不到 9 月 7 日的收益率。

而用交易日序号做时间轴时:

display "===================== 换成交易日序号后 ====================="tsreport
Time variable:    t--------------------------Starting period =        1Ending period   =      248Observations    =      248Number of gaps  =        0
gen double retL = L.retcount if missing(retL)
ounter(line  2

只有 2 个缺失(第一期和第二期,本来就应该缺失)。

当然使用日期做时间轴所带来的后果不只是样本量少 55 个,像newey 这类需要规则时间轴的命令会直接报错:

tsset datenewey ret L.ret, lag(4)
ounter(lineounter(linedate is not regularly spacedr(198);

出现r(198)整个代码运行中断,而使用交易日序号后,其运行结果则一切正常。

可以看出,对于股票、汇率这类交易日数据需要使用连续序号做时间轴,而date 可以在绘图中使用。

滚动标准差

先把收益率展示出来:

twoway (line ret t, clcolor(maroon) clwidth(thin)) ///    , ytitle("对数收益率 (%)") xtitle("交易日序号") ///    yline(0, lpattern(dash) lcolor(gs8)) ///    title("标普500 日对数收益率 (2001)") ///    graphregion(color(white)) plotregion(color(white)) ///    xlabel(40(40)240)graph export "E:\SoftWare\fig24_ret.png", width(1400) replace

收益率

最显眼的那条 -5% 尖峰就是 9 月 17 日,市场在休市四天后重新开张的结果。中间的 3 月和 4 月也有一片高高低低的锯齿状波动。

但光看单日收益率不太能说明问题,大波动和小波动混在一起,看不出什么规律。可以尝试换个指标,如计算 20 日滚动标准差:

gen double rollsd = .forvalues i = 20/247 {    local j = `i' - 19    quietly summarize ret in `j'/`i'    quietly replace rollsd = r(sd) in `i'}summarize rollsd
ounter(lineounter(lineounter(line    Variable |        Obs        Mean    Std. Dev.       Min        Max-------------+---------------------------------------------------------      rollsd |        228    1.275914    .3921197   .7591235   2.274338

最小 0.759,最大 2.274,三倍差距。结合图示:

滚动标准差

年初在 0.8 附近,二三月份上升到 2.2,四季度落回 1.0 附近。上涨和下跌成片出现,这就是波动率聚集。

分季度则看得更清楚:

gen int yr = year(date)gen int qt = quarter(date)gen byte qtr = 4*(yr-2001) + qtbysort qtr: egen sd_q = sd(ret)bysort qtr: egen n_q = count(ret)bysort qtr: gen byte first_q = (_n == 1)list qtr n_q sd_q if first_q, noobs
  +----------------------+  | qtr   n_q       sd_q |  |----------------------|  |   1    61   1.510627 |  |   2    63   1.349898 |  |   3    59   1.437218 |  |   4    64   1.058379 |  +----------------------+

四个季度的样本量都在 59 到 64 之间,标准差从 Q1 的 1.51 降到 Q4 的 1.06。

季度标准差

这里有个细节值得说明一下:Q1 的季度波动率最高(1.51),但是 9/11 明明在 Q3。3 月的暴跌全落在 Q1、Q2这两个季度,9/11 之后市场反而逐渐平静,这说明单日冲击幅度大,并不意味着整季度波动率高。

ARCH 检验

Engle (1982) 的 ARCH-LM 检验(原假设是"没有 ARCH 效应"),对应命令是 estat archlm:

regress retestat archlm
      Source |       SS           df       MS      Number of obs   =       247-------------+----------------------------------   F(0, 246)       =      0.00       Model |           0         0           .   Prob > F        =         .    Residual |  447.856583       246  1.82055521   R-squared       =    0.0000-------------+----------------------------------   Adj R-squared   =    0.0000       Total |  447.856583       246  1.82055521   Root MSE        =    1.3493------------------------------------------------------------------------------         ret |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]-------------+----------------------------------------------------------------       _cons |  -.0450691   .0858526    -0.52   0.600     -.214169    .1240309------------------------------------------------------------------------------
LM test for autoregressive conditional heteroskedasticity (ARCH)---------------------------------------------------------------------------    lags(p)  |          chi2               df                 Prob > chi2-------------+-------------------------------------------------------------       1     |          0.072               1                   0.7881---------------------------------------------------------------------------         H0: no ARCH effects      vs.  H1: ARCH(p) disturbance

现在看一看多阶的结果:

estat archlm, lags(1 2 3 4)
LM test for autoregressive conditional heteroskedasticity (ARCH)---------------------------------------------------------------------------    lags(p)  |          chi2               df                 Prob > chi2-------------+-------------------------------------------------------------       1     |          0.072               1                   0.7881       2     |          9.501               2                   0.0086       3     |         12.448               3                   0.0060       4     |         15.126               4                   0.0044---------------------------------------------------------------------------         H0: no ARCH effects      vs.  H1: ARCH(p) disturbance

这个结果有点意思。lag 1 完全不显著(p = 0.7881),加到 lag 2 就显著(p = 0.0086)。按照书本上的直觉 ,ARCH 是一阶的,lag 1 应该最显著才对。

先别急着下结论,我们来看看平方收益率的自相关。

平方收益率的自相关

ARCH 的核心机制是:波动率持续,所以平方后的收益率(也就是方差)应该也有正的自相关。ac 命令就可以验证,generate() 可以存成变量:

gen double ret2 = ret^2ac ret2, lags(10) generate(ac_ret2)list ac_ret2 in 1/10, noobs
 +------------+  |    ac_ret2 |  |------------|  |  .02009648 |  |  .18490795 |  |  .14142764 |  |  .00454729 |  |  .20409914 |  |  .01469432 |  |   .0715295 |  |  .06006271 |  |  .03875242 |  |  .03266382 |  +------------+

对照一下收益率本身的自相关:

ac ret, lags(10) generate(ac_ret)list ac_ret in 1/10, noobs
  +------------+  |    ac_ret  |  |------------|  | .04456131 |  | -.0643751 |  | .02943895 |  | .03566345 |  | -.09341863 |  | .00424318 |  | .07489238 |  | .06230824 |  | .01086303 |  +------------+

可以看出,收益率本身几乎没什么自相关(最大的也只有 0.093),符合随机游走的市场效率假说。但平方收益率的 lag 2 是 0.185,lag 5 是 0.204,明显为正,这说明ARCH 效应确实存在,只是落在 lag 2 和 lag 5 上。

平方收益自相关

lag 1 接近零、lag 2 却不低,值得多花点时间思考清楚。

分解:谁在贡献这个自协方差

自协方差的定义是 hat_gamma(k) = (1/N) * sum_t (r_t^2 - mean(r^2)) * (r_{t-k}^2 - mean(r^2))。既然是求和,就能把每对观测的贡献拎出来看。 首先,准备好去均值化的序列和分母:

quietly summarize ret2scalar m2 = r(mean)gen double xc = ret2 - m2gen double sq = xc^2quietly summarize sq if !missing(sq)scalar den = r(sum)display "分母 sum(xc^2) = " den
分母 sum(xc^2) = 2850.2085

然后算 lag 1 的逐点贡献,再按大小排序:

gen double c1 = xc*xc[_n-1]quietly summarize c1 if !missing(c1)scalar sum1 = r(sum)display "lag1 自协方差合计 = " sum1display "ACF lag1 = " sum1/den
lag1 自协方差合计 = 57.27916ACF lag1 = .02009648

和 ac 报出来的 0.02009648 完全一致,说明公式计算没问题。再来看贡献最大的几对:

preserve    keep date ret ret2 c1    gsort -c1    list in 1/6, noobs    gsort c1    list in 1/4, noobs    restore
  +------------------------------------------------+  |      date          ret        ret2          c1 |  |------------------------------------------------|  | 12mar2001   -4.4140783   19.484087   79.027636 |  | 06apr2001   -2.0185948   4.0747251   37.198076 |  | 24sep2001    3.8242593   14.624959   24.056711 |  | 28mar2001   -2.4733009   6.1172171   19.626446 |  | 21sep2001   -1.9217744   3.6932168   15.287678 |  |------------------------------------------------|  | 20sep2001    -3.155252    9.955615   6.7025214 |  +------------------------------------------------+  +-------------------------------------------------+  |      date          ret        ret2           c1 |  |-------------------------------------------------|  | 18sep2001   -.58218848   .33894343    -34.92112 |  | 17sep2001   -5.0467957   25.470146   -33.826341 |  | 05apr2001    4.2752913   18.278116   -28.494096 |  | 04apr2001   -.29053254   .08440915   -18.058746 |  +-------------------------------------------------+

有意思的是 9 月 11 日后的那两行。即17 日收益率 -5.0468%,平方后 25.47 是全样本最大,但 lag 1 贡献是 -33.83。18 日的值更小,为-34.92。

这是为什么?9/11 后休市四天,9/17 的"上一期"用交易日序号计算的是 9/10 那个平静的日子。巨大冲击撞上平静的前一期,贡献自然是负的。

把 9 月这几天的逐对乘积算出来看看:

preserve    keep date ret ret2 xc    gen double pair = xc*xc[_n-1]    list date ret ret2 xc pair if date >= td(10,9,2001) & date <= td(21,9,2001), noobs    restore
  +--------------------------------------------------------------+  |      date          ret        ret2           xc         pair |  |--------------------------------------------------------------|  | 10sep2001    .62066466   .38522463   -1.4299911   -2.4653425 |  | 17sep2001   -5.0467957   25.470146    23.654931   -33.826341 |  | 18sep2001   -.58218848   .33894343   -1.4762723    -34.92112 |  | 19sep2001   -1.6243709    2.638581    .82336519   -1.2155113 |  | 20sep2001    -3.155252    9.955615    8.1403993    6.7025214 |  |--------------------------------------------------------------|  | 21sep2001   -1.9217744    3.6932168     1.878001    15.287678 |  +--------------------------------------------------------------+

这里我们看 17 日:xc 是 23.65(全样本最高),但前一期(10 日)的 xc 只有 -1.43。看 18 日:xc 是 -1.48,但前一期是 23.65。

这两个负贡献加起来共有-68.75,几乎把 lag 1 的正贡献抵消了。合计只剩 57.28,除以分母 2850.21 得 0.0201。

再看 lag 2,同样先算后排序:

gen double c2 = xc*xc[_n-2]quietly summarize c2 if !missing(c2)scalar sum2 = r(sum)display "lag2 自协方差合计 = " sum2display "ACF lag2 = " sum2/den
lag2 自协方差合计 = 527.02622ACF lag2 = .18490795

结果和 ac 命令一致(0.18490795)。

preserve    keep date ret ret2 c2    gsort -c2    list in 1/6, noobs    restore
 +------------------------------------------------+  |      date          ret        ret2          c2 |  |------------------------------------------------|  | 05apr2001    4.2752913   18.278116   171.76923 |  | 05jan2001   -2.6592838   7.0717904   116.07204 |  | 24sep2001    3.8242593   14.624959   104.27642 |  | 14mar2001   -2.6181893   6.8549153   89.045802 |  | 17sep2001   -5.0467957   25.470146   40.781725 |  |------------------------------------------------|  | 19sep2001   -1.6243709    2.638581   19.476647 |  +------------------------------------------------+

lag 2 就不一样了。4 月 5 日的 +4.2753%(平方 18.28)贡献 171.77,1 月 5 日贡献 116.07,9 月 24 日贡献 104.28,都是"大波动后面跟大波动"。

所以 lag 2 显著、lag 1 不显著,不是数据有问题,是 9/11 的休市把 lag 1 的结构打乱了。休市前最后一个交易日(9/10)很平静,9/17 突然暴跌,这个"平静→暴跌"在 lag 1 上是强负贡献。而在 lag 2 上,9/17 的暴跌跟 9/19 的续跌(-1.62)配对,贡献 +40.78,符合波动聚集的正向模式。

ARCH 效应的脆弱性

既然 ARCH 检验的显著性取决于几个极端日,那我们使用留一法来看看。将平方收益率最大的四天是 9/17(25.47)、1/3(23.90)、3/12(19.48)、4/5(18.28),逐个剔除:

gen byte d1 = (date == td(3,1,2001))gen byte d2 = (date == td(12,3,2001))gen byte d3 = (date == td(5,4,2001))gen byte d4 = (date == td(17,9,2001))
regress retestat archlm, lags(2)
LM test for autoregressive conditional heteroskedasticity (ARCH)---------------------------------------------------------------------------    lags(p)  |          chi2               df                 Prob > chi2-------------+-------------------------------------------------------------       2     |          9.501               2                   0.0086---------------------------------------------------------------------------         H0: no ARCH effects      vs.  H1: ARCH(p) disturbance
regress ret if d1 == 0estat archlm, lags(2)
LM test for autoregressive conditional heteroskedasticity (ARCH)---------------------------------------------------------------------------    lags(p)  |          chi2               df                 Prob > chi2-------------+-------------------------------------------------------------       2     |          6.689               2                   0.0353---------------------------------------------------------------------------         H0: no ARCH effects      vs.  H1: ARCH(p) disturbance

剔除 1 月 3 日,p 从 0.0086 变成 0.0353,还在 5% 显著水平内。继续:

regress ret if d1 == 0 & d2 == 0estat archlm, lags(2)
LM test for autoregressive conditional heteroskedasticity (ARCH)---------------------------------------------------------------------------    lags(p)  |          chi2               df                 Prob > chi2-------------+-------------------------------------------------------------       2     |          6.510               2                   0.0386---------------------------------------------------------------------------         H0: no ARCH effects      vs.  H1: ARCH(p) disturbance
regress ret if d1 == 0 & d2 == 0 & d3 == 0estat archlm, lags(2)
LM test for autoregressive conditional heteroskedasticity (ARCH)---------------------------------------------------------------------------    lags(p)  |          chi2               df                 Prob > chi2-------------+-------------------------------------------------------------       2     |          2.457               2                   0.2927---------------------------------------------------------------------------         H0: no ARCH effects      vs.  H1: ARCH(p) disturbance

p = 0.2927,ARCH 效应没了。

只剔了三天(1/3、3/12、4/5),ARCH(2) 检验就从 5% 显著掉到完全不拒绝。四个全剔掉的情况:

regress ret if d1 == 0 & d2 == 0 & d3 == 0 & d4 == 0estat archlm, lags(2)
LM test for autoregressive conditional heteroskedasticity (ARCH)---------------------------------------------------------------------------    lags(p)  |          chi2               df                 Prob > chi2-------------+-------------------------------------------------------------       2     |          2.008               2                   0.3664---------------------------------------------------------------------------         H0: no ARCH effects      vs.  H1: ARCH(p) disturbance

p = 0.3664。

这个发现值得强调一下:247 个交易日的 ARCH 检验,显著性由 3 到 4 个观测值决定。这不是在说ARCH 效应是假的,而是这个样本量下 LM 检验的功效可能比较差。"检验拒绝了同方差"这句话可能并不靠谱。

标准误应该怎么算

现在可以正式回到标准误的计算上了。先跑一个 AR(1) 模型,看同一个模型在四种标准误下的结果:

regress ret L.retestimates store m_ols
      Source |       SS           df       MS      Number of obs   =       246-------------+----------------------------------   F(1, 244)       =      0.52       Model |  .893555532         1  .893555532   Prob > F        =    0.4732    Residual |  422.524901       244  1.73165943   R-squared       =    0.0021-------------+----------------------------------   Adj R-squared   =   -0.0020       Total |  423.418457       245  1.7282386   Root MSE        =    1.3159------------------------------------------------------------------------------         ret |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]-------------+----------------------------------------------------------------         ret |         L1. |   .0447255   .0622624     0.72   0.473    -.0779148    .1673659             |       _cons |  -.0633037   .0839386    -0.75   0.451    -.2286404     .102033------------------------------------------------------------------------------

系数 0.0447255,三种标准误下完全一样,标准误只影响推断,不影响点估计。所以看 se 那列。

异方差稳健标准误:

regress ret L.ret, robustestimates store m_rob
Linear regression                               Number of obs     =        246                                                F(1, 244)         =       0.48                                                Prob > F          =     0.4884                                                R-squared         =     0.0021                                                Root MSE          =     1.3159------------------------------------------------------------------------------             |               Robust         ret |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]-------------+----------------------------------------------------------------         ret |         L1. |   .0447255   .0644543     0.69   0.488    -.0822322    .1716832             |       _cons |  -.0633037   .0836893    -0.76   0.450    -.2281493    .1015419------------------------------------------------------------------------------

Newey-West 的 lag(0):

newey ret L.ret, lag(0)estimates store m_nw0
Regression with Newey-West standard errors      Number of obs     =        246maximum lag: 0                                  F(  1,       244) =       0.48                                                Prob > F          =     0.4884------------------------------------------------------------------------------             |             Newey-West         ret |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]-------------+----------------------------------------------------------------         ret |         L1. |   .0447255   .0644543     0.69   0.488    -.0822322    .1716832             |       _cons |  -.0633037   .0836893    -0.76   0.450    -.2281493    .1015419------------------------------------------------------------------------------

跟 robust 一模一样。这不是巧合,打开Stata 帮助文件,可以看到,lag(0) 的 Newey-West 就等于 vce(robust)。

现在换成 lag(4):

newey ret L.ret, lag(4)estimates store m_nw4
Regression with Newey-West standard errors      Number of obs     =        246maximum lag: 4                                  F(  1,       244) =       0.76                                                Prob > F          =     0.3849------------------------------------------------------------------------------             |             Newey-West         ret |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]-------------+----------------------------------------------------------------         ret |         L1. |   .0447255   .0513853     0.87   0.385    -.0564899     .145941             |       _cons |  -.0633037   .0847196    -0.75   0.456    -.2301788    .1035714------------------------------------------------------------------------------

四种结果并排展示:

estimates table m_ols m_rob m_nw0 m_nw4, se(%12.6f) b(%12.6f) stats(N r2)
--------------------------------------------------------------------------    Variable |    m_ols          m_rob          m_nw0          m_nw4-------------+------------------------------------------------------------         ret |         L1. |     0.044726       0.044726       0.044726       0.044726             |     0.062262       0.064454       0.064454       0.051385             |       _cons |    -0.063304      -0.063304      -0.063304      -0.063304             |     0.083939       0.083689       0.083689       0.084720-------------+------------------------------------------------------------           N |          246            246            246            246          r2 |     0.002110       0.002110--------------------------------------------------------------------------                                                              legend: b/se

注意 L1. 的标准误:普通 OLS 是 0.062262,稳健是 0.064454,Newey-West lag(4) 反而降到 0.051385。为什么加了自相关修正,标准误反而变小?

这是因为 Newey-West 是在稳健标准误的基础上加上各阶自协方差的修正项。如果某阶的样本自协方差是负的(比如上面 lag 2 的 -0.064),修正项就是负的,标准误自然往下走。这里提醒一件事:Newey-West 的标准误不保证比 OLS 大,它是无偏的而非保守的,不能想当然地以为"用了 HAC 标准误,p 值只会更保守"。

那在实践中到底应该选哪个?先做诊断:异方差用 White 检验(estat imtest, white),自相关用 Portmanteau 检验(wntestq):

regress ret L.retestat imtest, white
White's test for Ho: homoskedasticity         against Ha: unrestricted heteroskedasticity         chi2(2)      =      0.88         Prob > chi2  =    0.6433Cameron & Trivedi's decomposition of IM-test---------------------------------------------------              Source |       chi2     df      p---------------------+-----------------------------  Heteroskedasticity |       0.88      2    0.6433            Skewness |       0.33      1    0.5665            Kurtosis |       3.25      1    0.0713---------------------+-----------------------------               Total |       4.46      4    0.3470---------------------------------------------------
wntestq ret
Portmanteau test for white noise--------------------------------------- Portmanteau (Q) statistic =    56.6315 Prob > chi2(40)           =     0.0425

White 检验 p = 0.6433,不拒绝同方差。Portmanteau 检验 p = 0.0425,在 5% 水平上拒绝白噪声,但也只是勉强通过(默认使用 40 阶)。然后按照诊断结果选择:

  • 没发现异方差也没发现自相关 → 用普通 OLS 标准误,不需要加 robust
  • 发现异方差没发现自相关 → vce(robust) 就够了
  • 发现自相关(不论有无异方差)→ newey ..., lag(k)
  • 关心条件方差本身(风险度量、VaR)→ 直接上 GARCH

lag(k) 里的 k 怎么定?Andrews (1991) 给过数据驱动的最优带宽规则,常用的简化版本是 floor(4*(T/100)^(2/9))。对 T = 247 算是 4.89,取整就是 4——我们在案例中用的 lag(4) 正好符合。

ARCH(1) 和 GARCH(1,1)

标准误修正只能报告一个标量,而GARCH 走的是另一条路:把条件方差方程写出来。

arch ret, arch(1)estimates store m_arch1
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineARCH family regressionSample: 2 - 248                                   Number of obs   =        247Distribution: Gaussian                            Wald chi2(.)    =          .Log likelihood = -423.8785                        Prob > chi2     =          .------------------------------------------------------------------------------             |                 OPG         ret |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]-------------+----------------------------------------------------------------ret          |       _cons |  -.0361172   .0866127    -0.42   0.677    -.2058751    .1336406-------------+----------------------------------------------------------------ARCH         |        arch |         L1. |   .0308143    .064716     0.48   0.634    -.0960266    .1576553             |       _cons |   1.758166   .1608056    10.93   0.000     1.442993     2.07334------------------------------------------------------------------------------

ARCH(1) 的 alpha_1 是 0.0308143,z = 0.48,p = 0.634——ARCH 系数本身不显著。这与上面 lag 1 的 LM 检验一致。

GARCH(1,1):

arch ret, arch(1) garch(1)estimates store m_garch
ARCH family regressionSample: 2 - 248                                   Number of obs   =        247Distribution: Gaussian                            Wald chi2(.)    =          .Log likelihood = -415.4358                        Prob > chi2     =          .------------------------------------------------------------------------------             |                 OPG         ret |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]-------------+----------------------------------------------------------------ret          |       _cons |  -.0183596   .0807095    -0.23   0.820    -.1765473    .1398281-------------+----------------------------------------------------------------ARCH         |        arch |         L1. |   .1122558   .0448148     2.50   0.012     .0244204    .2000913             |       garch |         L1. |   .7878249   .0882893     8.92   0.000     .6147811    .9608687             |       _cons |   .1673628   .1057118     1.58   0.113    -.0398284    .3745541------------------------------------------------------------------------------

GARCH 里两个系数都显著:alpha_1 = 0.1122558(z = 2.50,p = 0.012),beta_1 = 0.7878249(z = 8.92,p = 0.000)。

持续性(persistence)是 alpha_1 + beta_1,衡量一次冲击多久消散。可以单独计算:

matrix b = e(b)matrix list bscalar a1 = b[1,2]scalar g1 = b[1,3]display "alpha = " a1display "beta  = " g1display "alpha+beta = " a1+g1
b[1,4]           ret:       ARCH:       ARCH:       ARCH:                         L.          L.         _cons        arch       garch       _consy1  -.01835956   .11225582   .78782487   .16736282
alpha = .11225582beta  = .78782487alpha+beta = .90008069

0.900。一次冲击衰减到 10% 以下需要约 ln(0.1)/ln(0.9) ≈ 21.9 个交易日,差不多一个多月,跟"波动有持续性但会慢慢平息"符合。

对数似然也值得看一眼:

scalar ll_a = e(ll)scalar ll_g = e(ll)display "LL 差 = " ll_g - ll_a
ARCH(1) LL = -423.87852GARCH LL  = -415.43576差 = 8.4427556

GARCH 比 ARCH(1) 提升了 8.44 的对数似然。

GARCH 拟合出来的波动率长什么样

predict, variance 可以拿到条件方差的拟合值:

predict double hhat, variance

把它和平方收益率画一起:

twoway (line ret2 t, clcolor(gs12)) ///       (line hhat t if hhat > 0, clcolor(maroon) clwidth(medium)), ///    ytitle("平方收益率 / 条件方差") xtitle("交易日序号") ///    title("GARCH(1,1) 条件方差 vs 平方收益率") ///    graphregion(color(white)) plotregion(color(white))graph export "E:\SoftWare\fig24_garchfit.png", width(1400) replace
GARCH拟合

深色线是 GARCH 估出来的条件方差,浅色是实际平方收益率。

值得留意的是,模型对 9/17 那个极端尖峰的反应是渐进的——GARCH 靠"过去冲击"更新方差,单个观测跳太高不会立刻把方差路径拽上去。这既是优点(不被离群点带跑),也是局限(对突发事件反应慢)。

几个现成的命令

Stata 中有几个现成的命令可以用。比较最推荐的是 arch 命令的 arch() 与 garch() 选项,它们直接把 ARCH 族模型估出来,还能用 predict, variance 估计条件方差。使用限制是必须先 tsset,且 garch() 必须搭配 arch() 一起写。

其他比较不错的命令还有 newey 的 lag() 选项,给 Newey-West 标准误,lag(0) 等价于 vce(robust);以及 estat archlm 的 lags() 选项,做 ARCH-LM 检验,限制是必须在 regress 之后用,且lags() 超过样本量一半时会报 r(2000)。

诊断类的还有 wntestq(Portmanteau 检验,检验白噪声)和 estat imtest, white(White 异方差检验)。前者默认用 min(floor(n/2)-2, 40) 阶,后者要求模型里有协变量(regress ret 只带常数会报 imtest not allowed without covariates)。

如何报告

通常的做法是这几点:

首先是时间轴口径。交易日数据用连续序号做 tsset,date 留着做图。

标准误要交代选择依据。别只写"we report Newey-West standard errors",要写清用哪个滞后阶数、为什么。

要把诊断和标准误选择相对应:White 检验(异方差)→ Portmanteau 检验(自相关)→ 选择标准误。

报告了 ARCH/GARCH ,就要报告持续性。alpha + beta 接近 1 意味着冲击持续时间长,比单独的 alpha、beta 有用得多。此外,还需要汇报对数似然,以判断模型是否合适。

样本量小的时候对 LM 检验保持怀疑。案例的这份数据有 247 个交易日,ARCH 检验的显著性由三四个观测决定。做留一法或去掉极端值的稳健性检验,并对脆弱性进行适当探讨。

参考文献:

Robert F. Engle (1982). Autoregressive Conditional Heteroskedasticity with Estimates of the Variance of United Kingdom Inflation. Econometrica, 50(4): 987-1007.

Tim Bollerslev (1986). Generalized Autoregressive Conditional Heteroskedasticity. Journal of Econometrics, 31(3): 307-327.

Whitney K. Newey and Kenneth D. West (1987). A Simple, Positive Semi-definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix. Econometrica, 55(3): 703-708.

Halbert White (1980). A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity. Econometrica, 48(4): 817-838.

Donald W. K. Andrews (1991). Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation. Econometrica, 59(3): 817-858.

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-11-23 11:55:20 HTTP/1.1 GET : http://h.sjds.net/a/580711.html
  2. 运行时间 : 0.079973s [ 吞吐率:12.50req/s ] 内存消耗:4,396.25kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=fe4a6d5c422bb3f677c735515e237100
  1. /www/wwwroot/h.sjds.net/public/index.php ( 0.79 KB )
  2. /www/wwwroot/h.sjds.net/vendor/autoload.php ( 0.17 KB )
  3. /www/wwwroot/h.sjds.net/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /www/wwwroot/h.sjds.net/vendor/composer/platform_check.php ( 0.90 KB )
  5. /www/wwwroot/h.sjds.net/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /www/wwwroot/h.sjds.net/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /www/wwwroot/h.sjds.net/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /www/wwwroot/h.sjds.net/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /www/wwwroot/h.sjds.net/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /www/wwwroot/h.sjds.net/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /www/wwwroot/h.sjds.net/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /www/wwwroot/h.sjds.net/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /www/wwwroot/h.sjds.net/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /www/wwwroot/h.sjds.net/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /www/wwwroot/h.sjds.net/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /www/wwwroot/h.sjds.net/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /www/wwwroot/h.sjds.net/app/provider.php ( 0.19 KB )
  23. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /www/wwwroot/h.sjds.net/app/common.php ( 0.03 KB )
  27. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /www/wwwroot/h.sjds.net/config/app.php ( 0.95 KB )
  30. /www/wwwroot/h.sjds.net/config/cache.php ( 0.78 KB )
  31. /www/wwwroot/h.sjds.net/config/console.php ( 0.23 KB )
  32. /www/wwwroot/h.sjds.net/config/cookie.php ( 0.56 KB )
  33. /www/wwwroot/h.sjds.net/config/database.php ( 2.48 KB )
  34. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /www/wwwroot/h.sjds.net/config/filesystem.php ( 0.61 KB )
  36. /www/wwwroot/h.sjds.net/config/lang.php ( 0.91 KB )
  37. /www/wwwroot/h.sjds.net/config/log.php ( 1.35 KB )
  38. /www/wwwroot/h.sjds.net/config/middleware.php ( 0.19 KB )
  39. /www/wwwroot/h.sjds.net/config/route.php ( 1.89 KB )
  40. /www/wwwroot/h.sjds.net/config/session.php ( 0.57 KB )
  41. /www/wwwroot/h.sjds.net/config/trace.php ( 0.34 KB )
  42. /www/wwwroot/h.sjds.net/config/view.php ( 0.82 KB )
  43. /www/wwwroot/h.sjds.net/app/event.php ( 0.25 KB )
  44. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /www/wwwroot/h.sjds.net/app/service.php ( 0.13 KB )
  46. /www/wwwroot/h.sjds.net/app/AppService.php ( 0.26 KB )
  47. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /www/wwwroot/h.sjds.net/vendor/services.php ( 0.14 KB )
  53. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /www/wwwroot/h.sjds.net/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /www/wwwroot/h.sjds.net/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /www/wwwroot/h.sjds.net/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /www/wwwroot/h.sjds.net/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /www/wwwroot/h.sjds.net/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /www/wwwroot/h.sjds.net/app/Request.php ( 0.09 KB )
  84. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /www/wwwroot/h.sjds.net/app/middleware.php ( 0.25 KB )
  86. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /www/wwwroot/h.sjds.net/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /www/wwwroot/h.sjds.net/route/app.php ( 1.72 KB )
  100. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /www/wwwroot/h.sjds.net/app/controller/Index.php ( 4.81 KB )
  104. /www/wwwroot/h.sjds.net/app/BaseController.php ( 2.05 KB )
  105. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /www/wwwroot/h.sjds.net/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /www/wwwroot/h.sjds.net/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /www/wwwroot/h.sjds.net/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /www/wwwroot/h.sjds.net/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /www/wwwroot/h.sjds.net/runtime/temp/c1d6e8c94b2c2fa10e259903674c804d.php ( 8.11 KB )
  140. /www/wwwroot/h.sjds.net/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000538s ] mysql:host=172.18.0.4;port=3306;dbname=h_sjds;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000747s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000376s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000344s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000527s ]
  6. SELECT * FROM `set` [ RunTime:0.000526s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000953s ]
  8. SELECT * FROM `article` WHERE `id` = 580711 LIMIT 1 [ RunTime:0.000629s ]
  9. UPDATE `article` SET `lasttime` = 1795406120 WHERE `id` = 580711 [ RunTime:0.003397s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 65 LIMIT 1 [ RunTime:0.000337s ]
  11. SELECT * FROM `article` WHERE `id` < 580711 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000382s ]
  12. SELECT * FROM `article` WHERE `id` > 580711 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000401s ]
  13. SELECT * FROM `article` WHERE `id` < 580711 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000593s ]
  14. SELECT * FROM `article` WHERE `id` < 580711 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.000554s ]
  15. SELECT * FROM `article` WHERE `id` < 580711 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.000537s ]
0.092086s