<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Econometrics on 格物堂</title><link>https://gewutang.cn/categories/econometrics/</link><description>Recent content in Econometrics on 格物堂</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><lastBuildDate>Sat, 26 Jul 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://gewutang.cn/categories/econometrics/index.xml" rel="self" type="application/rss+xml"/><item><title>如何根据事件研究来推测市场上涨幅度</title><link>https://gewutang.cn/2025/07/26/casestudy-etf-up/</link><pubDate>Sat, 26 Jul 2025 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2025/07/26/casestudy-etf-up/</guid><description>&#10;&#10;&#10;&lt;p&gt;先获取稀土ETF（代码为516780）的历史行情数据：&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;library(quantmod)&#10;XT &amp;lt;- getSymbols(&amp;quot;516780.ss&amp;quot;, src = &amp;quot;yahoo&amp;quot;, auto.assign = FALSE)&#10;# 获取子集数据&#10;XT &amp;lt;- round(XT[&amp;quot;2025::&amp;quot;],2)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;绘制蜡烛图：&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;chartSeries(XT, theme = &amp;quot;white&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2025/07/26/casestudy-etf-up/index_files/figure-html/unnamed-chunk-2-1.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;p&gt;下面标记重大事件。包括：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;2025年3月，份政府工作报告中提及要“整治行业内卷式竞争”。&lt;/li&gt;&#10;&lt;li&gt;2025年6月17日，全国人大公布修订后的《反不正当竞争法》。&lt;/li&gt;&#10;&lt;li&gt;2025年7月1日，中央财经委员会第七次会议公布要治理企业低价无序竞争。&lt;/li&gt;&#10;&lt;li&gt;2025年7月9日，工信部召开企业公平竞争座谈会。&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;在图上标记重大事件：&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 定义事件日期&#10;event_dates &amp;lt;- as.Date(c(&amp;quot;2025-03-07&amp;quot;, &#10; &amp;quot;2025-06-27&amp;quot;,&#10; &amp;quot;2025-07-01&amp;quot;,&#10; &amp;quot;2025-07-09&amp;quot;)&#10; )&#10;&#10;# 计算事件日期在子集中的相对索引&#10;event_index &amp;lt;- numeric(length(event_dates))&#10;for (i in seq_along(event_dates)) {&#10; event_index[i] &amp;lt;- which(index(XT) == event_dates[i])&#10;}&#10;&#10;# 添加标记点&#10;addPoints(&#10; x = event_index,&#10; y = Ad(XT[event_dates]),&#10; col = &amp;quot;blue&amp;quot;,&#10; pch = 24&#10;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2025/07/26/casestudy-etf-up/index_files/figure-html/unnamed-chunk-3-1.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;library(qmao)&#10;addVLine(index(XT[c(&amp;quot;2025-03-05::2025-03-12&amp;quot;,&#10; &amp;quot;2025-06-17::2025-06-30&amp;quot;,&#10; &amp;quot;2025-07-01::2025-07-25&amp;quot;)&#10; ]),&#10; col = &amp;quot;lightblue&amp;quot;,&#10; border = &amp;quot;lightblue&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2025/07/26/casestudy-etf-up/index_files/figure-html/unnamed-chunk-3-2.png" width="672" /&gt;&lt;/p&gt;&#10;</description></item><item><title>CVaR 和 ES 补充 VaR 的风险度量方法解析（含 R 包应用）</title><link>https://gewutang.cn/2019/07/13/cvar-es/</link><pubDate>Sat, 13 Jul 2019 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2019/07/13/cvar-es/</guid><description>&#10;&#10;&#10;&lt;div id="理论基础概述" class="section level1"&gt;&#10;&lt;h1&gt;理论基础概述&lt;/h1&gt;&#10;&lt;p&gt;在金融风险管理领域，风险价值（VaR）是一种广泛使用的风险度量工具，它衡量在一定置信水平下，某一金融资产或投资组合在未来特定时期内可能遭受的最大损失。然而，VaR 存在一些局限性，主要体现在以下几个方面：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;缺乏次可加性：在某些情况下，投资组合的 VaR 可能大于其各组成部分 VaR 之和，这与分散投资降低风险的直觉相悖。&lt;/li&gt;&#10;&lt;li&gt;对尾部风险的刻画不足：VaR 只关注损失分布的分位数点，而不考虑超过该点的损失程度。&lt;/li&gt;&#10;&lt;li&gt;不满足一致性风险度量的要求：VaR 不满足一致性风险度量公理中的次可加性、正齐次性、单调性和平移不变性。&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;为了克服 VaR 的这些局限性，条件风险价值（CVaR）和预期短缺（ES）作为更高级的风险度量方法被提出。CVaR 与 ES 的基本概念条件风险价值（Conditional Value at Risk, CVaR），也称为平均短缺（Average Shortfall, AS）或预期短缺（Expected Shortfall, ES），是指在给定置信水平下，超过 VaR 的损失的期望值。&lt;/p&gt;&#10;&lt;p&gt;它不仅考虑了损失超过 VaR 的概率，还考虑了超过部分的大小，因此能更全面地反映尾部风险。&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div id="数学公式解析" class="section level1"&gt;&#10;&lt;h1&gt;数学公式解析&lt;/h1&gt;&#10;&lt;div id="var-的数学定义" class="section level2"&gt;&#10;&lt;h2&gt;VaR 的数学定义&lt;/h2&gt;&#10;&lt;p&gt;对于给定的投资组合收益率 R 和置信水平 &lt;span class="math inline"&gt;\(\alpha\)&lt;/span&gt;，VaR 可以定义为：&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math display"&gt;\[&#10;\text{VaR}_\alpha = -\inf \{ x \in \mathbb{R} : F_R(x) \geq \alpha \}&#10;\]&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;其中，&lt;span class="math inline"&gt;\(F_R(x)\)&lt;/span&gt; 是收益率 &lt;span class="math inline"&gt;\(R\)&lt;/span&gt; 的累积分布函数。&lt;/p&gt;&#10;&lt;p&gt;在实际应用中，VaR 通常表示为：&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math display"&gt;\[&#10;P(R \leq -\text{VaR}_\alpha) = 1 - \alpha&#10;\]&lt;/span&gt;&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div id="cvares-的数学定义" class="section level2"&gt;&#10;&lt;h2&gt;CVaR/ES 的数学定义&lt;/h2&gt;&#10;&lt;p&gt;CVaR/ES 在置信水平 &lt;span class="math inline"&gt;\(\alpha\)&lt;/span&gt; 下的定义为：&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math display"&gt;\[&#10;\text{CVaR}_\alpha = \text{ES}_\alpha = \mathbb{E}[-R | R \leq -\text{VaR}_\alpha]&#10;\]&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;当收益率分布连续时，CVaR/ES 可以表示为：&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math display"&gt;\[&#10;\text{ES}_\alpha = \frac{1}{1-\alpha} \int_{0}^{1-\alpha} \text{VaR}_p \, dp&#10;\]&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;这个公式表明，ES 是所有低于 &lt;span class="math inline"&gt;\(\alpha\)&lt;/span&gt; 置信水平的 VaR 的平均值。&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div id="r-语言实现示例" class="section level1"&gt;&#10;&lt;h1&gt;R 语言实现示例&lt;/h1&gt;&#10;&lt;p&gt;下面通过 R 语言实现基于纳斯达克数据的 VaR、CVaR 和 ES 计算，使用 quantmod 包获取数据，并对比不同 R 包的计算方法。&lt;/p&gt;&#10;&lt;div id="使用-quantmod-获取数据" class="section level2"&gt;&#10;&lt;h2&gt;使用 quantmod 获取数据&lt;/h2&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 加载必要的包&#10;library(quantmod)&#10;library(PerformanceAnalytics)&#10;library(xts)&#10;library(tibble)&#10;library(dplyr)&#10;library(ggplot2)&#10;library(showtext) # 用于设置中文字体&#10;&#10;# 设置中文字体&#10;font_add(&amp;quot;SimHei&amp;quot;, &amp;quot;SimHei.ttf&amp;quot;) # 如果字体已安装&#10;# 如果字体未安装，可以尝试系统字体路径&#10;# font_add(&amp;quot;SimHei&amp;quot;, &amp;quot;/path/to/SimHei.ttf&amp;quot;) # Linux/Mac&#10;# font_add(&amp;quot;SimHei&amp;quot;, &amp;quot;C:/Windows/Fonts/simhei.ttf&amp;quot;) # Windows&#10;&#10;showtext_auto() # 自动启用showtext&#10;&#10;# 获取纳斯达克综合指数数据&#10;getSymbols(&amp;quot;^IXIC&amp;quot;, from = &amp;quot;2020-01-01&amp;quot;, to = Sys.Date())&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;IXIC&amp;quot;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 计算日对数收益率&#10;returns &amp;lt;- diff(log(Cl(IXIC)))&#10;returns &amp;lt;- na.omit(returns)&#10;&#10;# 设置置信水平&#10;alpha &amp;lt;- 0.95&#10;risk_results &amp;lt;- list()&lt;/code&gt;&lt;/pre&gt;&#10;&lt;/div&gt;&#10;&lt;div id="使用不同-r-包计算-escvar" class="section level2"&gt;&#10;&lt;h2&gt;使用不同 R 包计算 ES/CVaR&lt;/h2&gt;&#10;&lt;div id="performanceanalytics-包" class="section level3"&gt;&#10;&lt;h3&gt;PerformanceAnalytics 包&lt;/h3&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 使用PerformanceAnalytics包计算ES&#10;&#10;VaR_historical &amp;lt;- PerformanceAnalytics::VaR(returns, p = alpha , method = &amp;quot;historical&amp;quot;)&#10;VaR_gaussian &amp;lt;- PerformanceAnalytics::VaR(returns, p = alpha , method = &amp;quot;gaussian&amp;quot;)&#10;es_historical &amp;lt;- PerformanceAnalytics::ES(returns, p = alpha, method = &amp;quot;historical&amp;quot;)&#10;es_gaussian &amp;lt;- PerformanceAnalytics::ES(returns, p = alpha, method = &amp;quot;gaussian&amp;quot;)&#10;&#10;cat(&amp;quot;PerformanceAnalytics包计算结果:\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## PerformanceAnalytics包计算结果:&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(&amp;quot;历史模拟法 VaR:&amp;quot;, round(VaR_historical * 100, 2), &amp;quot;%\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 历史模拟法 VaR: -2.58 %&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(&amp;quot;正态分布假设 VaR:&amp;quot;, round(VaR_gaussian * 100, 2), &amp;quot;%\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 正态分布假设 VaR: -2.64 %&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(&amp;quot;历史模拟法 ES:&amp;quot;, round(es_historical * 100, 2), &amp;quot;%\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 历史模拟法 ES: -3.91 %&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(&amp;quot;正态分布假设 ES:&amp;quot;, round(es_gaussian * 100, 2), &amp;quot;%\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 正态分布假设 ES: -3.32 %&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;risk_results[[&amp;quot;performance&amp;quot;]] &amp;lt;- list(&#10; VaR_historical = VaR_historical,&#10; VaR_gaussian = VaR_gaussian,&#10; es_historical = es_historical,&#10; es_gaussian = es_gaussian&#10;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;/div&gt;&#10;&lt;div id="fgarch-包" class="section level3"&gt;&#10;&lt;h3&gt;fGarch 包&lt;/h3&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 使用fGarch包计算ES&#10;library(fGarch)&#10;# 拟合GARCH模型并预测&#10;garch_model &amp;lt;- garchFit(~garch(1,1), data = returns, trace = FALSE)&#10;forecast &amp;lt;- predict(garch_model, n.ahead = 1)&#10;es_garch &amp;lt;- tail(fGarch::ES(garch_model), n = 1)&#10;var_garch &amp;lt;- tail(fGarch::VaR(garch_model), n = 1)&#10;cat(&amp;quot;\nfGarch包计算结果:\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## fGarch包计算结果:&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(&amp;quot;GARCH模型预测 VaR:&amp;quot;, round(var_garch * 100, 2), &amp;quot;%\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## GARCH模型预测 VaR: 1.47 %&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(&amp;quot;GARCH模型预测 ES:&amp;quot;, round(es_garch * 100, 2), &amp;quot;%\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## GARCH模型预测 ES: 1.86 %&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;risk_results[[&amp;quot;fgarch&amp;quot;]] &amp;lt;- list(&#10; var_garch = var_garch,&#10; es_garch = es_garch&#10;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;/div&gt;&#10;&lt;div id="cvar包针对连续分布的vares计算" class="section level3"&gt;&#10;&lt;h3&gt;cvar包（针对连续分布的VaR/ES计算）&lt;/h3&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;if (!require(&amp;quot;cvar&amp;quot;)) install.packages(&amp;quot;cvar&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Loading required package: cvar&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## Attaching package: &amp;#39;cvar&amp;#39;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## The following objects are masked from &amp;#39;package:PerformanceAnalytics&amp;#39;:&#10;## &#10;## ES, VaR&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;library(cvar)&#10;&#10;# 标准正态分布计算&#10;gaussian_es &amp;lt;- list(&#10; qf = cvar::ES(qnorm, dist.type = &amp;quot;qf&amp;quot;), # 使用分位数函数&#10; cdf = cvar::ES(pnorm, dist.type = &amp;quot;cdf&amp;quot;) # 使用累积分布函数&#10;)&#10;&#10;# t分布计算（df=4）&#10;t_dist_es &amp;lt;- list(&#10; qf = cvar::ES(qt, dist.type = &amp;quot;qf&amp;quot;, df = 4),&#10; cdf = cvar::ES(pt, dist.type = &amp;quot;cdf&amp;quot;, df = 4)&#10;)&#10;&#10;risk_results[[&amp;quot;cvar&amp;quot;]] &amp;lt;- list(&#10; gaussian_es = gaussian_es,&#10; t_dist_es = t_dist_es&#10;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;ol start="5" style="list-style-type: decimal"&gt;&#10;&lt;li&gt;rugarch 包&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 加载必要的包&#10;library(rugarch)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Loading required package: parallel&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;library(xts) # 处理时间序列数据&#10;&#10;# 定义GARCH模型（使用偏态t分布）&#10;spec &amp;lt;- ugarchspec(&#10; variance.model = list(model = &amp;quot;sGARCH&amp;quot;, garchOrder = c(1, 1)),&#10; mean.model = list(armaOrder = c(0, 0), include.mean = TRUE),&#10; distribution.model = &amp;quot;sstd&amp;quot; # 偏态t分布&#10;)&#10;&#10;# 拟合模型&#10;fit &amp;lt;- ugarchfit(spec, data = returns, solver = &amp;quot;hybrid&amp;quot;)&#10;&#10;# 使用固定参数重新过滤数据&#10;spec2 &amp;lt;- spec&#10;setfixed(spec2) &amp;lt;- as.list(coef(fit))&#10;filt &amp;lt;- ugarchfilter(spec2, data = returns, n.old = 1000)&#10;&#10;# 提取拟合值和波动率&#10;mu &amp;lt;- fitted(filt) # 条件均值&#10;sigma_t &amp;lt;- sigma(filt) # 条件波动率&#10;&#10;# 获取分布参数&#10;skew &amp;lt;- coef(fit)[&amp;quot;skew&amp;quot;]&#10;shape &amp;lt;- coef(fit)[&amp;quot;shape&amp;quot;]&#10;&#10;# 计算VaR (使用向量化方法)&#10;p &amp;lt;- 0.05 # 置信水平(1-95%)&#10;VaR &amp;lt;- mu + sigma_t * qdist(&amp;quot;sstd&amp;quot;, p = p, mu = 0, sigma = 1, skew = skew, shape = shape)&#10;&#10;# 计算ES (使用数值积分)&#10;es_integrand &amp;lt;- function(x) {&#10; qdist(&amp;quot;sstd&amp;quot;, p = x, mu = 0, sigma = 1, skew = skew, shape = shape)&#10;}&#10;&#10;# 向量化积分计算（对每个时间点单独计算ES）&#10;ES &amp;lt;- numeric(length(returns))&#10;for (i in 1:length(returns)) {&#10; int_result &amp;lt;- integrate(es_integrand, lower = 0, upper = p, subdivisions = 1000)&#10; ES[i] &amp;lt;- mu[i] + sigma_t[i] * int_result$value / p&#10;}&#10;&#10;# 确保所有向量长度一致（处理可能的长度差异）&#10;min_len &amp;lt;- min(length(returns), length(VaR), length(ES))&#10;actual &amp;lt;- as.numeric(tail(returns, min_len))&#10;VaR &amp;lt;- tail(as.numeric(tail(VaR, min_len)),1)&#10;ES &amp;lt;- tail(as.numeric(tail(ES, min_len)),1)&#10;&#10;risk_results[[&amp;quot;rugarch&amp;quot;]] &amp;lt;- list(&#10; VaR = VaR,&#10; ES = ES&#10;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;ol start="4" style="list-style-type: decimal"&gt;&#10;&lt;li&gt;gets包（基于ARX模型的条件风险度量）&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 加载必要的包&#10;library(gets)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## Attaching package: &amp;#39;gets&amp;#39;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## The following objects are masked from &amp;#39;package:cvar&amp;#39;:&#10;## &#10;## ES, VaR&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## The following objects are masked from &amp;#39;package:fGarch&amp;#39;:&#10;## &#10;## ES, VaR&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## The following objects are masked from &amp;#39;package:PerformanceAnalytics&amp;#39;:&#10;## &#10;## ES, VaR&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;returns &amp;lt;- diff(log(Cl(IXIC))) &#10;returns &amp;lt;- as.vector(na.omit(returns)) # 强制转换为普通向量&#10;&#10;# 设置置信水平&#10;alpha &amp;lt;- 0.95&#10;&#10;# 构建ARX模型（滞后1阶）&#10;# 使用普通向量而非xts对象&#10;arx_model &amp;lt;- arx(returns, mc=TRUE, ar=1) # 直接使用向量格式&#10;&#10;# 计算VaR和ES&#10;risk_results[[&amp;quot;gets&amp;quot;]] &amp;lt;- list(&#10; VaR = quantile(arx_model$residuals, probs=1-alpha),&#10; ES = mean(arx_model$residuals[arx_model$residuals &amp;lt;= quantile(arx_model$residuals, probs=1-alpha)])&#10;)&#10;&#10;# 打印结果&#10;cat(&amp;quot;ARX模型风险度量结果:\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## ARX模型风险度量结果:&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(&amp;quot;VaR (&amp;quot;, alpha*100, &amp;quot;%):&amp;quot;, round(risk_results[[&amp;quot;gets&amp;quot;]]$VaR*100, 2), &amp;quot;%\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## VaR ( 95 %): -2.64 %&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(&amp;quot;ES (&amp;quot;, alpha*100, &amp;quot;%):&amp;quot;, round(risk_results[[&amp;quot;gets&amp;quot;]]$ES*100, 2), &amp;quot;%\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## ES ( 95 %): -3.93 %&lt;/code&gt;&lt;/pre&gt;&#10;&lt;ol start="5" style="list-style-type: decimal"&gt;&#10;&lt;li&gt;MSGARCH包（贝叶斯方法的风险预测）&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;if (!require(&amp;quot;MSGARCH&amp;quot;)) install.packages(&amp;quot;MSGARCH&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Loading required package: MSGARCH&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;library(MSGARCH)&#10;spec_msgarch &amp;lt;- CreateSpec()&#10;fit_msgarch &amp;lt;- FitML(spec_msgarch, data = returns)&#10;risk_msgarch &amp;lt;- Risk(fit_msgarch, n.ahead = 1, level = alpha)&#10;risk_results[[&amp;quot;MSGARCH&amp;quot;]] &amp;lt;- list(&#10; VaR = as.numeric(risk_msgarch$VaR),&#10; ES = as.numeric(risk_msgarch$ES)&#10;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;ol start="6" style="list-style-type: decimal"&gt;&#10;&lt;li&gt;VaRES包（多种参数分布的风险度量）&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;if (!require(&amp;quot;VaRES&amp;quot;)) install.packages(&amp;quot;VaRES&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Loading required package: VaRES&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;library(VaRES)&#10;&#10;returns &amp;lt;- diff(log(Cl(IXIC))) &#10;returns &amp;lt;- as.vector(na.omit(returns)) # 强制转换为普通向量&#10;&#10;# 手动计算 VaR 和 ES（假设 df = 4）&#10;df &amp;lt;- 4&#10;alpha &amp;lt;- 0.05 # 95% 置信水平&#10;&#10;# 计算 t 分布的 VaR&#10;VaR_t &amp;lt;- -quantile(rt(n = 1e6, df = df), probs = alpha) * sd(returns)&#10;&#10;# 计算 t 分布的 ES（解析解）&#10;ES_t &amp;lt;- (dt(qt(alpha, df = df), df = df) / alpha) * &#10; ((df + qt(alpha, df = df)^2) / (df - 2)) * &#10; sd(returns)&#10;&#10;risk_results[[&amp;quot;VaRES&amp;quot;]] &amp;lt;- list(VaR = VaR_t, ES = ES_t)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div id="结果对比与可视化" class="section level1"&gt;&#10;&lt;h1&gt;结果对比与可视化&lt;/h1&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 从risk_results中提取各方法的VaR和ES（统一格式：保留数值，处理符号）&#10;returns_vec &amp;lt;- as.vector(returns) # 转换为向量用于部分模型&#10;&#10;results &amp;lt;- tibble(&#10; 方法 = c(&#10; &amp;quot;历史模拟法&amp;quot;, &#10; &amp;quot;正态分布假设&amp;quot;, &#10; &amp;quot;GARCH(fGarch)&amp;quot;, &#10; &amp;quot;GARCH(rugarch)&amp;quot;, &#10; &amp;quot;MSGARCH&amp;quot;, &#10; &amp;quot;ARX模型(gets)&amp;quot;, &#10; &amp;quot;t分布(VaRES)&amp;quot;&#10; ),&#10; # 提取VaR（统一为损失幅度，取绝对值或修正符号）&#10; VaR = c(&#10; as.numeric(risk_results$performance$VaR_historical) %&amp;gt;% abs(), # 历史模拟法&#10; as.numeric(risk_results$performance$VaR_gaussian) %&amp;gt;% abs(), # 正态分布&#10; as.numeric(risk_results$fgarch$var_garch), # fGarch&#10; as.numeric(risk_results$rugarch$VaR) %&amp;gt;% abs(), # rugarch&#10; as.numeric(risk_results$MSGARCH$VaR[1]) %&amp;gt;% abs(), # MSGARCH（取第一个结果）&#10; as.numeric(risk_results$gets$VaR) %&amp;gt;% abs(), # ARX模型&#10; as.numeric(risk_results$VaRES$VaR) # VaRES包&#10; ),&#10; # 提取ES（统一为损失幅度，取绝对值或修正符号）&#10; ES = c(&#10; as.numeric(risk_results$performance$es_historical) %&amp;gt;% abs(), # 历史模拟法&#10; as.numeric(risk_results$performance$es_gaussian) %&amp;gt;% abs(), # 正态分布&#10; as.numeric(risk_results$fgarch$es_garch), # fGarch&#10; as.numeric(risk_results$rugarch$ES) %&amp;gt;% abs(), # rugarch&#10; as.numeric(risk_results$MSGARCH$ES[1]) %&amp;gt;% abs(), # MSGARCH（取第一个结果）&#10; as.numeric(risk_results$gets$ES) %&amp;gt;% abs(), # ARX模型&#10; as.numeric(risk_results$VaRES$ES) # VaRES包&#10; )&#10;)&#10;&#10;# 转换为百分比（乘以100）&#10;results &amp;lt;- results %&amp;gt;% &#10; mutate(&#10; VaR_pct = VaR * 100,&#10; ES_pct = ES * 100&#10; )&#10;&#10;&#10;&#10;# 不同方法的ES对比图&#10;ggplot(results, aes(x = 方法, y = ES_pct, fill = 方法)) +&#10; geom_col(width = 0.7, show.legend = FALSE) + # 柱状图，不显示图例&#10; geom_text(&#10; aes(label = sprintf(&amp;quot;%.2f%%&amp;quot;, ES_pct)), # 显示百分比标签&#10; vjust = -0.5, size = 4, family = &amp;quot;SimHei&amp;quot;&#10; ) +&#10; labs(&#10; title = &amp;quot;不同方法计算的预期损失(ES)对比&amp;quot;,&#10; x = &amp;quot;风险度量方法&amp;quot;,&#10; y = &amp;quot;ES（%）&amp;quot;,&#10; caption = &amp;quot;数据来源：纳斯达克指数(2020-2025)日对数收益率&amp;quot;&#10; ) +&#10; ylim(0, max(results$ES_pct) * 1.2) + # 调整y轴范围，避免标签超出&#10; theme_minimal(base_family = &amp;quot;SimHei&amp;quot;) +&#10; theme(&#10; plot.title = element_text(hjust = 0.5, face = &amp;quot;bold&amp;quot;, size = 14),&#10; axis.text.x = element_text(angle = 45, hjust = 1, size = 10),&#10; plot.caption = element_text(hjust = 0, size = 8, color = &amp;quot;gray50&amp;quot;)&#10; )&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2019/07/13/cvar-es/index_files/figure-html/unnamed-chunk-9-1.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 不同方法的VaR对比图&#10;ggplot(results, aes(x = 方法, y = VaR_pct, fill = 方法)) +&#10; geom_col(width = 0.7, show.legend = FALSE) +&#10; geom_text(&#10; aes(label = sprintf(&amp;quot;%.2f%%&amp;quot;, VaR_pct)),&#10; vjust = -0.5, size = 4, family = &amp;quot;SimHei&amp;quot;&#10; ) +&#10; labs(&#10; title = &amp;quot;不同方法计算的风险价值(VaR)对比&amp;quot;,&#10; x = &amp;quot;风险度量方法&amp;quot;,&#10; y = &amp;quot;VaR（%）&amp;quot;,&#10; caption = &amp;quot;数据来源：纳斯达克指数(2020-2025)日对数收益率&amp;quot;&#10; ) +&#10; ylim(0, max(results$VaR_pct) * 1.2) +&#10; theme_minimal(base_family = &amp;quot;SimHei&amp;quot;) +&#10; theme(&#10; plot.title = element_text(hjust = 0.5, face = &amp;quot;bold&amp;quot;, size = 14),&#10; axis.text.x = element_text(angle = 45, hjust = 1, size = 10),&#10; plot.caption = element_text(hjust = 0, size = 8, color = &amp;quot;gray50&amp;quot;)&#10; )&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2019/07/13/cvar-es/index_files/figure-html/unnamed-chunk-9-2.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 收益率分布与ES标记&#10;# 绘制收益率直方图，并标记历史模拟法ES&#10;p &amp;lt;- ggplot(data = tibble(returns = returns_vec), aes(x = returns)) +&#10; geom_histogram(&#10; aes(y = after_stat(density)), # 密度直方图&#10; bins = 50, fill = &amp;quot;lightblue&amp;quot;, color = &amp;quot;white&amp;quot;&#10; ) +&#10; # 添加核密度曲线&#10; geom_density(color = &amp;quot;darkblue&amp;quot;, linewidth = 0.8) +&#10; # 标记历史模拟法ES（取绝对值对应的收益率位置）&#10; geom_vline(&#10; xintercept = -results$ES[results$方法 == &amp;quot;历史模拟法&amp;quot;] / 100, # 转换为收益率（负值表示损失）&#10; color = &amp;quot;red&amp;quot;, linewidth = 1.2, linetype = &amp;quot;dashed&amp;quot;&#10; ) +&#10; annotate(&#10; &amp;quot;text&amp;quot;, x = -results$ES[results$方法 == &amp;quot;历史模拟法&amp;quot;] / 100, y = 5,&#10; label = sprintf(&amp;quot;历史模拟法ES: %.2f%%&amp;quot;, results$ES[results$方法 == &amp;quot;历史模拟法&amp;quot;]),&#10; color = &amp;quot;red&amp;quot;, hjust = 1.1, family = &amp;quot;SimHei&amp;quot;&#10; ) +&#10; labs(&#10; title = &amp;quot;纳斯达克指数日对数收益率分布&amp;quot;,&#10; x = &amp;quot;日对数收益率&amp;quot;,&#10; y = &amp;quot;密度&amp;quot;&#10; ) +&#10; theme_minimal(base_family = &amp;quot;SimHei&amp;quot;) +&#10; theme(&#10; plot.title = element_text(hjust = 0.5, face = &amp;quot;bold&amp;quot;)&#10; )&#10;print(p)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2019/07/13/cvar-es/index_files/figure-html/unnamed-chunk-9-3.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# ----------------------&#10;# 输出数值结果&#10;# ----------------------&#10;cat(&amp;quot;各方法风险度量结果（百分比）：\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 各方法风险度量结果（百分比）：&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;results %&amp;gt;% &#10; select(方法, VaR_pct, ES_pct) %&amp;gt;% &#10; rename(&#10; &amp;quot;风险度量方法&amp;quot; = 方法,&#10; &amp;quot;VaR（%）&amp;quot; = VaR_pct,&#10; &amp;quot;ES（%）&amp;quot; = ES_pct&#10; ) %&amp;gt;% &#10; print(n = Inf)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## # A tibble: 7 × 3&#10;## 风险度量方法 `VaR（%）` `ES（%）`&#10;## &amp;lt;chr&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;&#10;## 1 历史模拟法 2.58 3.91&#10;## 2 正态分布假设 2.64 3.32&#10;## 3 GARCH(fGarch) 1.47 1.86&#10;## 4 GARCH(rugarch) 1.48 2.07&#10;## 5 MSGARCH 2.25 2.73&#10;## 6 ARX模型(gets) 2.64 3.93&#10;## 7 t分布(VaRES) 3.47 7.87&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;结论CVaR 和 ES 作为 VaR 的补充工具，能够更全面地度量金融风险，尤其是在处理尾部风险时表现更为出色。通过结合使用 VaR、CVaR 和 ES，风险管理者可以获得更完整的风险图景，从而做出更明智的风险管理决策。在实际应用中，应根据投资组合的特性和市场环境选择合适的风险度量方法。&lt;/p&gt;&#10;&lt;p&gt;不同 R 包提供了多种计算 ES/CVaR 的方法，各有特点：PerformanceAnalytics：简单易用，支持多种分布假设RiskPortfolios：专注投资组合风险分析fGarch/rugarch：适合结合 GARCH 模型处理时变波动率ExpectedShortfall：提供 ES 回测功能建议结合数据特性（如是否存在厚尾、波动聚类等）选择合适的模型，并对比不同方法的结果以确保对极端风险的充分考虑。&lt;/p&gt;&#10;&lt;/div&gt;&#10;</description></item><item><title>在时间序列的线图上添加垂线</title><link>https://gewutang.cn/2011/05/08/add-vertical-lines-to-timeseries-plot/</link><pubDate>Sun, 08 May 2011 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2011/05/08/add-vertical-lines-to-timeseries-plot/</guid><description>&lt;pre&gt;&lt;code class="language-r"&gt;library(xts)&#10;v &amp;lt;- vector()&#10;v[1] &amp;lt;- 10&#10;for(i in 2:100){&#10; v[i] &amp;lt;- v[i-1]+rnorm(1, 0, 0.01)&#10;}&#10;X &amp;lt;- xts(v, seq(as.Date(&amp;quot;2009-01-01&amp;quot;), by=&amp;quot;day&amp;quot;, length.out=100))&#10;plot.xts(X)&#10;# abline(v=X[50,]) #不行&#10;# abline(v=50) #不行&#10;# abline(v=index(X)[50]) #不行&#10;abline(v =.index(X)[50],col=&amp;quot;red&amp;quot;) #不行&#10;abline(v = (.index(X)[30]), col = &amp;quot;blue&amp;quot;)&#10;&lt;/code&gt;&lt;/pre&gt;&#10;</description></item><item><title>符号偏误检验</title><link>https://gewutang.cn/2011/05/02/use-r-to-do-sign-bias-test/</link><pubDate>Mon, 02 May 2011 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2011/05/02/use-r-to-do-sign-bias-test/</guid><description>&lt;p&gt;Engle和Ng（1993）提出了四种检验条件方差对称性的方法，分别是：&lt;/p&gt;&#10;&lt;p&gt;1.符号偏误检验（Sign Bias Test）&lt;/p&gt;&#10;&lt;p&gt;$$&#10;\epsilon_t=a_1+b_1S_{t-1}^{-}+Z_{1t}&#10;$$&lt;/p&gt;&#10;&lt;p&gt;2.负符号偏误检验(Negative Sign Bias Test)&lt;/p&gt;&#10;&lt;p&gt;$$&#10;\epsilon_t=a_2+b_2S_{t-1}^{-}\epsilon_{t-1}+Z_{2t}&#10;$$&lt;/p&gt;&#10;&lt;p&gt;3.正符号偏误检验（Positive Sign Bias Test）&lt;/p&gt;&#10;&lt;p&gt;$$&#10;\epsilon_t=a_3+b_3S_{t-1}^{+}\epsilon_{t-1}+Z_{3t}&#10;$$&#10;其中： &lt;code&gt;\(S_{t-1}^{-}\)&lt;/code&gt; 为虚拟变量，当 &lt;code&gt;\(\epsilon_{t-1}&amp;lt;0\)&lt;/code&gt; 时， &lt;code&gt;\(S_{t-1}^{-}=1\)&lt;/code&gt; ，否则为0。 &lt;code&gt;\(S_{t-1}^{+}=1-S_{t-1}^{-}\)&lt;/code&gt; ，Z为残差。&lt;/p&gt;&#10;&lt;p&gt;4.联合检验（Joint Test）&lt;/p&gt;&#10;&lt;p&gt;$$&#10;\epsilon_t=c_0+c_1S_{t-1}^{-}+c_2S_{t-1}^{-}\epsilon_{t-1}+c_3S_{t-1}^{+}\epsilon_{t-1}+Z_t&#10;$$&#10;联合检验的统计量服从自由度为3的卡方分布。&lt;/p&gt;&#10;&lt;p&gt;在实践中，可以直接用R软件进行符号偏误检验：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;library(rgarch)&#10;data(dmbp) #载入数据&#10;spec = ugarchspec() #设定模型为默认&#10;fit = ugarchfit(data = dmbp[,1], spec = spec) # 拟合模型&#10;signbias(fit) # 提取符号偏误检验结果&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;检验结果如下：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt; t-value prob sig&#10;Sign Bias 1.50254937 0.1331156 &#10;Negative Sign Bias 0.02483478 0.9801893 &#10;Positive Sign Bias 0.79126111 0.4288869 &#10;Joint Effect 3.07511135 0.3801888 &#10;&lt;/code&gt;&lt;/pre&gt;&#10;</description></item><item><title>R与时间序列的平稳性</title><link>https://gewutang.cn/2011/01/09/r-and-the-stationary-of-time-series/</link><pubDate>Sun, 09 Jan 2011 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2011/01/09/r-and-the-stationary-of-time-series/</guid><description>&lt;p&gt;“协整”算是计量经济学里面的明星概念，不了解计量经济学的人很容易被它笼罩的计量经济学光环给吓到。但事实上，协整并不神秘，是平易近人。&lt;/p&gt;&#10;&lt;p&gt;要了解“协整”，首先得提到一个名词——平稳。&lt;/p&gt;&#10;&lt;h2 id="什么是平稳时间序列"&gt;&lt;a href="#%e4%bb%80%e4%b9%88%e6%98%af%e5%b9%b3%e7%a8%b3%e6%97%b6%e9%97%b4%e5%ba%8f%e5%88%97" class="header-anchor"&gt;&lt;/a&gt;什么是平稳时间序列&#10;&lt;/h2&gt;&lt;p&gt;金融领域有很多类型的时间序列，学者们为了研究的方便通常会对这些时间序列进行分类。比如，按照时间序列数据产生时间间隔的长短分为高频时间序列和非高频时间序列。按照时间序列的平稳性与否，便可以将时间序列分为平稳的时间序列和非平稳的时间序列。&lt;/p&gt;&#10;&lt;p&gt;判断某个时间序列平稳与否主要看一下三点：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;时间序列（随机过程）的均值是否是常数?或者说时间序列（随机过程）的均值是不是跟时间无关？如果不是常数则该时间序列是非平稳的；如果是常数，则该时间序列可能是平稳的，但不肯定，须进入第二步。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;时间序列（随机过程）的方差是否是常数？或者说时间序列（随机过程）的方差是不是跟时间无关？如果不是常数则该时间序列是非平稳的；如果是常数，则该时间序列可能是平稳的，但不肯定，须进入第三步。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;任意两个时期的时间序列之间的协方差是否仅仅依赖于两个时间序列的时间间隔。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;如果一个时间序列同时满足上述三个条件，那么，该时间序列就是平稳的。&lt;/p&gt;&#10;&lt;p&gt;由于均值、方差和协方差可以被统一的成为统计特性，因此也可以说如果时间序列的统计特性不随着时间的推移而发生变化，则说明时间序列是平稳的。&lt;/p&gt;&#10;&lt;p&gt;平稳时间序列还可以进一步细分。根据平稳时间序列进行差分的次数，可以将平稳时间序列分为不同阶的平稳时间序列。如果一个时间序列本身是平稳的，那么该时间序列可被记作I(0),括号里面的0表示该时间序列没有进行差分。如果一个时间序列一阶差分之后平稳，那么可被记作I(1),以此类推。&lt;/p&gt;&#10;&lt;h2 id="平稳性的检验"&gt;&lt;a href="#%e5%b9%b3%e7%a8%b3%e6%80%a7%e7%9a%84%e6%a3%80%e9%aa%8c" class="header-anchor"&gt;&lt;/a&gt;平稳性的检验&#10;&lt;/h2&gt;&lt;p&gt;在应用过程中，时间序列的平稳性的判断要简单的多。常用的判断时间序列平稳性的方法有两个：图示法和单位根检验法。&lt;/p&gt;&#10;&lt;p&gt;图示法，顾名思义，就是画出时间序列的时序图，来目测时间序列是否平稳。如果画出的时间序列不存在明显的趋势，那么时间序列可能是平稳的。这个方法比较随意和主观，因此，只能作为辅助判断的手段。&lt;/p&gt;&#10;&lt;p&gt;单位根检验法是一个理论基础扎实的判断手段，单位根检验的方法非常多，一般常用的有DF检验(Dickey-Fuller Test)，ADF检验(Augmented Dickey-Fuller Test)和PP检验(Phillips-Perron Test)。这三个检验的理论基础在这里不讲,因为除却数理统计的专业人员，大部分人都不必深究这些理论，现实中只要懂得这些检验用软件的实现方法就可以了。&lt;/p&gt;&#10;&lt;p&gt;下面以R为例：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;#生成两个时间序列：&#10;&#10;x=rnorm(500); #没有单位根&#10;&#10;y=cumsum(x); #有单位根&#10;&#10;# 绘制时序图&#10;&#10;plot.ts(x);&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;img src="https://gewutang.cn/2011/01/09/r-and-the-stationary-of-time-series/index_files/figure-html/unnamed-chunk-1-1.png" width="672" /&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;plot.ts(y);&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;img src="https://gewutang.cn/2011/01/09/r-and-the-stationary-of-time-series/index_files/figure-html/unnamed-chunk-1-2.png" width="672" /&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;# DF.test检验&#10;&#10;library(tseries) #载入tseries包&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Registered S3 method overwritten by 'quantmod':&#10;## method from&#10;## as.zoo.data.frame zoo&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;adf.test(x)&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Warning in adf.test(x): p-value smaller than printed p-value&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## &#9;Augmented Dickey-Fuller Test&#10;## &#10;## data: x&#10;## Dickey-Fuller = -7.863, Lag order = 7, p-value = 0.01&#10;## alternative hypothesis: stationary&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;P值等于0.01，拒绝x是原假设（原假设为非平稳），即可以认为x是平稳的。&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;adf.test(y)&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## &#9;Augmented Dickey-Fuller Test&#10;## &#10;## data: y&#10;## Dickey-Fuller = -2.6979, Lag order = 7, p-value = 0.2829&#10;## alternative hypothesis: stationary&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;P值等于0.303，因此y是非平稳的。&lt;/p&gt;&#10;&lt;p&gt;还可以用urca包中的ur.df()函数来完成上述过程：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;# install.packages('urca') #安装urca包&#10;&#10;library(urca)#载入urca包&#10;&#10;?ur.df#查看ur.df()函数的帮助文档&#10;&#10;#用uroot包中的ADF.test()函数来完成上述过程&#10;&#10;# install.packages('uroot') #没有安装的话&#10;&#10;library(uroot) #载入uroot包&#10;?ADF.test#查看ADF.test()函数的帮助文档&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 在指定的程序包和图书馆里没有与'ADF.test'有关的文档:&#10;## 你可以用用'??ADF.test'&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;h2 id="pp检验"&gt;&lt;a href="#pp%e6%a3%80%e9%aa%8c" class="header-anchor"&gt;&lt;/a&gt;PP检验&#10;&lt;/h2&gt;&lt;pre&gt;&lt;code class="language-r"&gt;library(tseries)&#10;&#10;pp.test(x)&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## Warning in pp.test(x): p-value smaller than printed p-value&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## &#9;Phillips-Perron Unit Root Test&#10;## &#10;## data: x&#10;## Dickey-Fuller Z(alpha) = -513.04, Truncation lag parameter = 5, p-value&#10;## = 0.01&#10;## alternative hypothesis: stationary&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;P值等于0.01，拒绝x为非平稳序列的假设。&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;pp.test(y)&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## &#9;Phillips-Perron Unit Root Test&#10;## &#10;## data: y&#10;## Dickey-Fuller Z(alpha) = -15.795, Truncation lag parameter = 5, p-value&#10;## = 0.2286&#10;## alternative hypothesis: stationary&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;P值等于0.2056，不能拒绝x是非平稳序列的假设，即x非平稳。&lt;/p&gt;&#10;&lt;p&gt;也可以用stats包中的PP.test()函数来完成PP检验。&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;?PP.test#查看PP.test()函数的帮助文档&#10;&lt;/code&gt;&lt;/pre&gt;&#10;</description></item><item><title>基于混合正态分布的 VaR 计算</title><link>https://gewutang.cn/2010/12/21/var-mixture-of-norms/</link><pubDate>Tue, 21 Dec 2010 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2010/12/21/var-mixture-of-norms/</guid><description>&#10;&#10;&#10;&lt;div id="一引言" class="section level1"&gt;&#10;&lt;h1&gt;一、引言&lt;/h1&gt;&#10;&lt;p&gt;风险价值（Value at Risk, 简称 VaR ）是金融风险管理中衡量市场风险的核心指标，其定义为：在一定置信水平下，某一金融资产或组合在未来特定时间段内可能遭受的最大潜在损失。传统 VaR 计算多假设资产收益率服从正态分布，但实际金融时间序列往往呈现 “尖峰厚尾” 特性（峰度高于正态分布，尾部概率更大），导致正态分布假设下的 VaR 低估尾部风险。&lt;/p&gt;&#10;&lt;p&gt;混合正态模型（Mixture of Normals Model）通过将收益率分布拟合为多个正态分布的加权组合，能够有效捕捉尖峰厚尾特征，从而更精准地估计 VaR。&lt;/p&gt;&#10;&lt;p&gt;本文详细介绍混合正态模型的构建、参数估计及 VaR 计算方法，并通过 R 语言进行实现。&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div id="二混合正态模型理论模型定义" class="section level1"&gt;&#10;&lt;h1&gt;二、混合正态模型理论模型定义&lt;/h1&gt;&#10;&lt;p&gt;假设金融资产收益率X服从两成分混合正态分布，其概率密度函数（PDF）为：&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math display"&gt;\[&#10;f(x; \Theta) = \alpha \cdot \phi(x; \mu_1, \sigma_1^2) + (1-\alpha) \cdot \phi(x; \mu_2, \sigma_2^2) \tag{1}&#10;\]&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;其中：&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math inline"&gt;\(\Theta = (\alpha, \mu_1, \sigma_1^2, \mu_2, \sigma_2^2)\)&lt;/span&gt; 为待估参数；&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math inline"&gt;\(\alpha \in (0,1)\)&lt;/span&gt; 是第一成分的权重；&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math inline"&gt;\(\phi(x; \mu, \sigma^2) = \frac{1}{\sqrt{2\pi}\sigma} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)\)&lt;/span&gt; 为正态分布密度函数；&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math inline"&gt;\(\mu_1\)&lt;/span&gt; , &lt;span class="math inline"&gt;\(\mu_2\)&lt;/span&gt; 分别为两成分的均值；&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math inline"&gt;\(\sigma_1^2\)&lt;/span&gt; , &lt;span class="math inline"&gt;\(\sigma_2^2\)&lt;/span&gt; 分别为两成分的方差。&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;参数估计&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;我们可以采用极大似然估计（MLE）求解参数 &lt;span class="math inline"&gt;\(\Theta\)&lt;/span&gt; 。设样本观测值为&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math display"&gt;\[&#10;x_1, x_2, ..., x_n&#10;\]&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;则似然函数为：&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math display"&gt;\[&#10;L(\Theta) = \prod_{i=1}^n \left[ \alpha \cdot \phi(x_i; \mu_1, \sigma_1^2) + (1-\alpha) \cdot \phi(x_i; \mu_2, \sigma_2^2) \right] \tag{2}&#10;\]&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;取对数似然函数并最大化：&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math display"&gt;\[&#10;\ln L(\Theta) = \sum_{i=1}^n \ln\left[ \alpha \cdot \phi(x_i; \mu_1, \sigma_1^2) + (1-\alpha) \cdot \phi(x_i; \mu_2, \sigma_2^2) \right] \tag{3}&#10;\]&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;实际求解中，通常采用 EM 算法（期望最大化算法）迭代计算参数估计值。&lt;/p&gt;&#10;&lt;div id="基于混合正态模型的-var-计算" class="section level2"&gt;&#10;&lt;h2&gt;基于混合正态模型的 VaR 计算&lt;/h2&gt;&#10;&lt;p&gt;对于置信水平 &lt;span class="math inline"&gt;\(1-\beta\)&lt;/span&gt; （如 95%、99%），VaR 定义为满足以下条件的损失阈值：&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math display"&gt;\[&#10;P(X \leq -VaR) = \beta \tag{4}&#10;\]&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;其中 X 为资产收益率，负号表示损失（对多头头寸而言）。结合混合正态分布的累积分布函数（CDF），式（4）可写为：&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="math display"&gt;\[&#10;F(-VaR) = \alpha \cdot \Phi\left(-VaR; \mu_1, \sigma_1^2\right) + (1-\alpha) \cdot \Phi\left(-VaR; \mu_2, \sigma_2^2\right) = \beta \tag{5} \label{eq:mix-normal}&#10;\]&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;其中 &lt;span class="math inline"&gt;\(\Phi(\cdot)\)&lt;/span&gt; 为正态分布的 CDF。&lt;/p&gt;&#10;&lt;p&gt;通过数值方法（如二分法）求解式 &lt;span class="math inline"&gt;\(\eqref{eq:mix-normal}\)&lt;/span&gt; ，即可得到混合正态模型下的 VaR。&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div id="三r-语言实证分析" class="section level1"&gt;&#10;&lt;h1&gt;三、R 语言实证分析&lt;/h1&gt;&#10;&lt;p&gt;以下通过 R 语言实现基于混合正态模型的 VaR 计算，使用quantmod获取金融数据，mixtools拟合混合正态模型。&lt;/p&gt;&#10;&lt;ol style="list-style-type: decimal"&gt;&#10;&lt;li&gt;加载所需包&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 安装并加载包&#10;if (!require(&amp;quot;quantmod&amp;quot;)) install.packages(&amp;quot;quantmod&amp;quot;)&#10;if (!require(&amp;quot;mixtools&amp;quot;)) install.packages(&amp;quot;mixtools&amp;quot;)&#10;if (!require(&amp;quot;ggplot2&amp;quot;)) install.packages(&amp;quot;ggplot2&amp;quot;)&#10;library(quantmod)&#10;library(mixtools)&#10;library(ggplot2)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;ol start="2" style="list-style-type: decimal"&gt;&#10;&lt;li&gt;获取金融数据并计算收益率&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;以特斯拉公司的股价为例，计算其对数收益率：&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 获取数据（近5年）&#10;getSymbols(&amp;quot;TSLA&amp;quot;, from = &amp;quot;2023-01-01&amp;quot;, to = &amp;quot;2025-01-01&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;TSLA&amp;quot;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;tsla &amp;lt;- na.omit(Cl(TSLA)) # 提取收盘价并去除缺失值&#10;&#10;# 计算对数收益率&#10;returns &amp;lt;- diff(log(tsla))&#10;returns &amp;lt;- na.omit(returns) # 去除NA值&#10;colnames(returns) &amp;lt;- &amp;quot;收益率&amp;quot;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;ol start="3" style="list-style-type: decimal"&gt;&#10;&lt;li&gt;拟合混合正态模型&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;使用 mixtools::normalmixEM&lt;a href="#fn1" class="footnote-ref" id="fnref1"&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt; 拟合两成分混合正态分布：&lt;/p&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 拟合混合正态模型（2个成分）&#10;set.seed(123) # 设置随机种子，保证结果可复现&#10;mix_model &amp;lt;- normalmixEM(returns, k = 2, maxit = 1000)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## number of iterations= 146&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 输出参数估计结果&#10;cat(&amp;quot;混合正态模型参数估计：\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 混合正态模型参数估计：&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(paste(&amp;quot;权重 α =&amp;quot;, round(mix_model$lambda[1], 4), &amp;quot;\n&amp;quot;))&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 权重 α = 0.839&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(paste(&amp;quot;成分1：均值 μ1 =&amp;quot;, round(mix_model$mu[1], 6), &#10; &amp;quot;，标准差 σ1 =&amp;quot;, round(mix_model$sigma[1], 6), &amp;quot;\n&amp;quot;))&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 成分1：均值 μ1 = 0.001422 ，标准差 σ1 = 0.027839&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(paste(&amp;quot;成分2：均值 μ2 =&amp;quot;, round(mix_model$mu[2], 6), &#10; &amp;quot;，标准差 σ2 =&amp;quot;, round(mix_model$sigma[2], 6), &amp;quot;\n&amp;quot;))&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 成分2：均值 μ2 = 0.008931 ，标准差 σ2 = 0.063941&lt;/code&gt;&lt;/pre&gt;&#10;&lt;ol start="4" style="list-style-type: decimal"&gt;&#10;&lt;li&gt;定义混合正态分布的 CDF 及 VaR 计算函数&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 混合正态分布的累积分布函数（CDF）&#10;mix_normal_cdf &amp;lt;- function(x, alpha, mu1, sigma1, mu2, sigma2) {&#10; alpha * pnorm(x, mean = mu1, sd = sigma1) + &#10; (1 - alpha) * pnorm(x, mean = mu2, sd = sigma2)&#10;}&#10;&#10;# 用二分法求解VaR&#10;var_mixture_normal &amp;lt;- function(conf_level, alpha, mu1, sigma1, mu2, sigma2, data) {&#10; beta &amp;lt;- 1 - conf_level # 尾概率&#10; # 确定搜索区间（基于数据的极值）&#10; lower &amp;lt;- min(data) * 2&#10; upper &amp;lt;- 0 # VaR为损失，对应收益率分布的左侧尾部&#10; # 二分法迭代求解&#10; for (i in 1:1000) {&#10; mid &amp;lt;- (lower + upper) / 2&#10; cdf_val &amp;lt;- mix_normal_cdf(mid, alpha, mu1, sigma1, mu2, sigma2)&#10; if (cdf_val &amp;lt; beta) {&#10; lower &amp;lt;- mid&#10; } else {&#10; upper &amp;lt;- mid&#10; }&#10; if (abs(cdf_val - beta) &amp;lt; 1e-6) break # 精度满足时停止&#10; }&#10; return(-upper) # 返回VaR（损失值为正）&#10;}&lt;/code&gt;&lt;/pre&gt;&#10;&lt;ol start="5" style="list-style-type: decimal"&gt;&#10;&lt;li&gt;计算 VaR 并与传统方法对比&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 计算95%和99%置信水平下的VaR&#10;conf_levels &amp;lt;- c(0.95, 0.99)&#10;var_results &amp;lt;- sapply(conf_levels, function(cl) {&#10; var_mixture_normal(conf_level = cl,&#10; alpha = mix_model$lambda[1],&#10; mu1 = mix_model$mu[1],&#10; sigma1 = mix_model$sigma[1],&#10; mu2 = mix_model$mu[2],&#10; sigma2 = mix_model$sigma[2],&#10; data = returns)&#10;})&#10;&#10;# 输出VaR结果&#10;cat(&amp;quot;\n混合正态模型VaR计算结果：\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## 混合正态模型VaR计算结果：&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;for (i in 1:length(conf_levels)) {&#10; cat(paste(conf_levels[i] * 100, &amp;quot;%置信水平下的VaR =&amp;quot;, &#10; round(var_results[i], 6), &amp;quot;\n&amp;quot;))&#10;}&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 95 %置信水平下的VaR = 0.052193 &#10;## 99 %置信水平下的VaR = 0.090665&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 与传统正态分布假设下的VaR对比&#10;var_normal_95 &amp;lt;- quantile(returns, probs = 0.05) # 正态假设下95% VaR&#10;var_normal_99 &amp;lt;- quantile(returns, probs = 0.01) # 正态假设下99% VaR&#10;cat(&amp;quot;\n传统正态分布假设下的VaR：\n&amp;quot;)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## &#10;## 传统正态分布假设下的VaR：&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(paste(&amp;quot;95%置信水平下的VaR =&amp;quot;, round(-as.numeric(var_normal_95), 6), &amp;quot;\n&amp;quot;))&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 95%置信水平下的VaR = 0.051618&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;cat(paste(&amp;quot;99%置信水平下的VaR =&amp;quot;, round(-as.numeric(var_normal_99), 6), &amp;quot;\n&amp;quot;))&lt;/code&gt;&lt;/pre&gt;&#10;&lt;pre&gt;&lt;code&gt;## 99%置信水平下的VaR = 0.091924&lt;/code&gt;&lt;/pre&gt;&#10;&lt;ol start="6" style="list-style-type: decimal"&gt;&#10;&lt;li&gt;可视化结果&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre class="r"&gt;&lt;code&gt;# 绘制收益率分布直方图及混合正态模型拟合曲线&#10;p &amp;lt;- ggplot(data = as.data.frame(returns), aes(x = 收益率)) +&#10; geom_histogram(aes(y = after_stat(density)), &#10; bins = 50, &#10; fill = &amp;quot;lightblue&amp;quot;, &#10; color = &amp;quot;black&amp;quot;, &#10; alpha = 0.7) +&#10; stat_function(fun = function(x) { # 混合正态模型密度曲线&#10; mix_model$lambda[1] * dnorm(x, &#10; mean = mix_model$mu[1], &#10; sd = mix_model$sigma[1]) +&#10; mix_model$lambda[2] * dnorm(x, &#10; mean = mix_model$mu[2], &#10; sd = mix_model$sigma[2])&#10; }, color = &amp;quot;red&amp;quot;, linewidth = 1) +&#10; geom_vline(xintercept = -var_results[1], &#10; color = &amp;quot;blue&amp;quot;, &#10; linetype = &amp;quot;dashed&amp;quot;, &#10; linewidth = 1) +&#10; geom_vline(xintercept = -var_results[2], &#10; color = &amp;quot;purple&amp;quot;, &#10; linetype = &amp;quot;dashed&amp;quot;, &#10; linewidth = 1) +&#10; labs(title = &amp;quot;特斯拉收益率分布与混合正态模型拟合&amp;quot;,&#10; x = &amp;quot;对数收益率&amp;quot;, y = &amp;quot;密度&amp;quot;) +&#10; theme_minimal()&#10;print(p)&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;&lt;img src="https://gewutang.cn/2010/12/21/var-mixture-of-norms/index_files/figure-html/unnamed-chunk-6-1.png" width="672" /&gt;&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div id="四结论" class="section level1"&gt;&#10;&lt;h1&gt;四、结论&lt;/h1&gt;&#10;&lt;p&gt;混合正态模型通过捕捉金融数据的尖峰厚尾特性，能够更准确地估计 VaR，相比传统正态分布假设更贴合实际风险特征。&lt;/p&gt;&#10;&lt;p&gt;实证结果显示，在高置信水平（如 99%）下，混合模型计算的 VaR 通常更高，更能反映极端损失的可能性，为风险管理提供更稳健的参考。实际应用中，可根据数据特征调整混合成分数量（如 3 个成分），或结合其他统计方法（如 GARCH 模型）进一步优化波动率的动态特性。&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="footnotes footnotes-end-of-document"&gt;&#10;&lt;hr /&gt;&#10;&lt;ol&gt;&#10;&lt;li id="fn1"&gt;&lt;p&gt;上述代码中，normalmixEM 可能需要多次迭代才能收敛，若结果不稳定可调整 maxit 参数；VaR 计算的二分法精度可通过迭代次数或误差阈值调整。&lt;a href="#fnref1" class="footnote-back"&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/div&gt;&#10;</description></item></channel></rss>